mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.51k stars 32.18k forks source link

Add eslint-plugin-material-ui #31096

Open oliviertassinari opened 2 years ago

oliviertassinari commented 2 years ago

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/

  3. styled(Box) should really be styled('div')

  4. 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 commented 7 months ago

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:

Janpot commented 4 months ago

Other rules ideas: