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

Add eslint-plugin-material-ui #31096

Open
oliviertassinari opened this issue Feb 15, 2022 · 2 comments
Open

Add eslint-plugin-material-ui #31096

oliviertassinari opened this issue Feb 15, 2022 · 2 comments
Labels
discussion new feature New feature or request

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 15, 2022

Summary 💡

This issue is mostly here as an opportunity to evaluate the opposite to have a linter for Material UI, Base UI, Pigment CSS, etc. This linter would very likely be implemented with eslint.

Examples 🌈

Motivation 🔦

Ideas:

  1. When using the unitless API, error with all non-integer or half-integer usage: sx: { p: 1.4, m: 1.6 }
  2. Warn when using an invalid import path, e.g. breaking https://mui.com/material-ui/guides/minimizing-bundle-size/
  1. styled(Box) should really be styled('div')
  2. Providing render functions to slots, this is wrong:
  <TimePicker
    defaultValue={time}
    slots={{
      textField: (props) => (
        <TextField sx={{ width: 100 }} {...props} size='small' />
      ),
    }}
  />

Explored with a warning in #14748 but has false-positive, false-negative.

@lewxdev
Copy link

lewxdev commented Feb 20, 2024

I've been looking for this for some time.
Could MUI just swallow the existing plugins currently available so it can be maintained by the core team and have greater recognition from the community so we can help support as well:

@oliviertassinari oliviertassinari added the new feature New feature or request label Apr 19, 2024
@oliviertassinari oliviertassinari changed the title Add eslint-plugin-mui Add eslint-plugin-material-ui Apr 19, 2024
@Janpot
Copy link
Member

Janpot commented May 15, 2024

Other rules ideas:

  • Some of the components have an accessibility section that we could potentially build eslint rules around.
  • Error when an unstable component is passed to a slot.
  • Error when styled is called within a component.
  • Error when importing internal modules (e.g. @mui/utils or @mui/x-data-grid/internal)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants