material-ui
material-ui copied to clipboard
Add eslint-plugin-material-ui
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 🌈
- https://www.npmjs.com/package/eslint-plugin-react-hooks
- https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-plugin
- https://baseweb.design/getting-started/setup/#eslint-plugin-baseui
- https://tailwindcss.com/blog/introducing-linting-for-tailwindcss-intellisense
Motivation 🔦
Ideas:
- When using the unitless API, error with all non-integer or half-integer usage:
sx: { p: 1.4, m: 1.6 } - Warn when using an invalid import path, e.g. breaking https://mui.com/material-ui/guides/minimizing-bundle-size/
- https://github.com/mui/mui-toolpad/pull/3417/files#r1572992179
styled(Box)should really bestyled('div')
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:
- https://github.com/kajirikajiri/eslint-plugin-mui-path-imports
- https://www.npmjs.com/package/eslint-plugin-mui
- https://www.npmjs.com/package/@saswatb/eslint-plugin-sort-sx-prop
- https://www.npmjs.com/package/eslint-plugin-mui-unused-classes
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
styledis called within a component. - Error when importing internal modules (e.g.
@mui/utilsor@mui/x-data-grid/internal)