Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: add lint rule which warn unused makeStyles classes #491

Open
1 task done
taisei-13046 opened this issue Jan 14, 2024 · 2 comments
Open
1 task done

lint: add lint rule which warn unused makeStyles classes #491

taisei-13046 opened this issue Jan 14, 2024 · 2 comments
Labels
💅 enhancement New feature or request

Comments

@taisei-13046
Copy link

Library

React Components / v9 (@fluentui/react-components)

Describe the feature that you would like added

Currently, I use @fluentui/react-components and style by using makeStyles.
This feature proposal is making the new ESLint Rules.

For example.

export const Component = () => {
  const styles = useStyles()
  return (
    <div className={styles.wrapper}>
      <p>hello</p>
    </div>
  )
}

const useStyles = makeStyles({
  wrapper: {},
  // ⚠️ this class should be warned because it's not used
  form: {}
})

This above example means that the makeStyles code should be warned because it has unused styles.
Please consider it.

Have you discussed this feature with our team

no

Additional context

no

Validations

  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Priority

Normal

@Hotell
Copy link
Contributor

Hotell commented Jan 15, 2024

fluent v9 core doesn't contain css in js implementation anymore ( we use griffel for css in js ), thus can you please open this issue on griffel repo ?

the rule could be added to eslint-plugin https://github.com/microsoft/griffel/tree/main/packages/eslint-plugin

Last but not least, I'd suggest to add "motivation" behind this rule to provide better motivation. for example: shipping less JS for unused rule definitions etc.

ty!

@layershifter layershifter transferred this issue from microsoft/fluentui Jan 19, 2024
@layershifter layershifter changed the title [Feature]: Add new ESLint rule which warn unused makeStyles classes lint: add lint rule which warn unused makeStyles classes Jan 19, 2024
@layershifter layershifter added the 💅 enhancement New feature or request label Jan 19, 2024
@layershifter
Copy link
Member

FYI I transferred the issue to Griffel repository.


This rule could be easily implemented for a case when makeStyles() and useStyles() call are in the same file. However, it's more complicated for a case when useStyles() gets imported from a different file:

import { useStyles } from './x.styles'

function App() {
  const styles = useStyles();
}

I don't think that there is an easy way on how to handle the second case, but I am opened for suggestions.

@layershifter layershifter removed their assignment Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💅 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants