eslint-plugin-mui-v7 1.2.0 β†’ 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +686 -301
  2. package/index.cjs +872 -422
  3. package/index.js +876 -422
  4. package/package.json +56 -55
package/README.md CHANGED
@@ -1,301 +1,686 @@
1
- # eslint-plugin-mui-v7
2
-
3
- > ESLint plugin focused on Material-UI V6 to V7 **breaking changes** with educational error messages
4
-
5
- Automatically detect code that **BREAKS** when migrating from MUI V6 to V7 and teach developers the correct way through helpful messages with emojis and examples!
6
-
7
- ## 🎯 Philosophy
8
-
9
- This plugin focuses on **breaking changes only** - code that will actually break when upgrading to V7. We don't warn about best practices or style preferences, just things that will cause errors.
10
-
11
- ## ✨ Features
12
-
13
- - πŸš€ **Detect Unstable_Grid2 usage** - Now promoted to stable Grid
14
- - ⚠️ **Catch Grid2 usage** - Grid2 was renamed to Grid in V7
15
- - 🎯 **Grid item prop detection** - Grid doesn't use `item` prop anymore, use `size` instead
16
- - ✨ **Find moved @mui/lab components** - Alert, Skeleton, Rating, etc. are now in @mui/material
17
- - πŸ”„ **Detect deprecated props** - onBackdropClick, size="normal", Hidden component
18
- - πŸ’‘ **Theme variables suggestion** - Use `theme.vars.*` for automatic dark mode support (optional)
19
- - πŸ”§ **Auto-fix available** for most rules!
20
-
21
- ## πŸ“¦ Installation
22
-
23
- ```bash
24
- npm install --save-dev eslint-plugin-mui-v7
25
- ```
26
-
27
- ## πŸš€ Quick Start
28
-
29
- ### ESLint 9+ (Flat Config) - Recommended
30
-
31
- ```javascript
32
- // eslint.config.js
33
- import muiV7Plugin from 'eslint-plugin-mui-v7'
34
-
35
- export default [
36
- muiV7Plugin.configs.recommended, // βœ… Apply all recommended rules
37
- ]
38
- ```
39
-
40
- ### Manual Configuration
41
-
42
- ```javascript
43
- // eslint.config.js
44
- import muiV7Plugin from 'eslint-plugin-mui-v7'
45
-
46
- export default [
47
- {
48
- plugins: {
49
- 'mui-v7': muiV7Plugin,
50
- },
51
- rules: {
52
- // Breaking changes - ERRORS (cΓ³digo quebra)
53
- 'mui-v7/no-unstable-grid': 'error',
54
- 'mui-v7/no-grid2-import': 'error',
55
- 'mui-v7/no-grid-item-prop': 'error',
56
- 'mui-v7/no-lab-imports': 'error',
57
- 'mui-v7/no-deprecated-props': 'error',
58
-
59
- // Best practices - WARNINGS (sugestΓ΅es)
60
- 'mui-v7/prefer-theme-vars': 'warn',
61
- },
62
- },
63
- ]
64
- ```
65
-
66
- ### ESLint <9 (Legacy Config)
67
-
68
- ```javascript
69
- // .eslintrc.js
70
- module.exports = {
71
- plugins: ['mui-v7'],
72
- rules: {
73
- 'mui-v7/no-unstable-grid': 'error',
74
- 'mui-v7/no-grid2-import': 'error',
75
- 'mui-v7/no-grid-item-prop': 'error',
76
- 'mui-v7/no-lab-imports': 'error',
77
- 'mui-v7/no-deprecated-props': 'error',
78
- 'mui-v7/prefer-theme-vars': 'warn',
79
- },
80
- }
81
- ```
82
-
83
- ## πŸ“‹ Rules
84
-
85
- ### 🚨 Breaking Changes (Errors)
86
-
87
- These rules detect code that **WILL BREAK** in MUI V7.
88
-
89
- #### `mui-v7/no-unstable-grid` ✨ NEW in v1.1.0
90
-
91
- Unstable_Grid2 was promoted to stable Grid in V7.
92
-
93
- ```typescript
94
- // ❌ Breaks in V7
95
- import Grid from '@mui/material/Unstable_Grid2'
96
- import Grid2 from '@mui/material/Unstable_Grid2'
97
-
98
- // βœ… Recommended
99
- import { Grid } from '@mui/material'
100
- ```
101
-
102
- #### `mui-v7/no-grid2-import`
103
-
104
- Grid2 was renamed to Grid in V7.
105
-
106
- ```typescript
107
- // ❌ Breaks in V7
108
- import Grid2 from '@mui/material/Grid2'
109
- import { grid2Classes } from '@mui/material/Grid2'
110
-
111
- // βœ… Recommended
112
- import { Grid } from '@mui/material'
113
- import { gridClasses } from '@mui/material'
114
- ```
115
-
116
- #### `mui-v7/no-grid-item-prop`
117
-
118
- Grid doesn't use `item` prop anymore, use `size` instead.
119
-
120
- ```typescript
121
- // ❌ Breaks in V7
122
- <Grid item xs={12} sm={6} md={4}>
123
- Content
124
- </Grid>
125
-
126
- // βœ… Works in V7
127
- <Grid size={{ xs: 12, sm: 6, md: 4 }}>
128
- Content
129
- </Grid>
130
- ```
131
-
132
- #### `mui-v7/no-lab-imports`
133
-
134
- Components moved from @mui/lab to @mui/material.
135
-
136
- ```typescript
137
- // ❌ Breaks in V7
138
- import { Alert } from '@mui/lab'
139
- import { Skeleton } from '@mui/lab'
140
-
141
- // βœ… Recommended
142
- import { Alert } from '@mui/material'
143
- import { Skeleton } from '@mui/material'
144
- ```
145
-
146
- **Moved components:** Alert, AlertTitle, Autocomplete, AvatarGroup, Pagination, PaginationItem, Rating, Skeleton, SpeedDial, SpeedDialAction, SpeedDialIcon, TabContext, TabList, TabPanel, Timeline*, ToggleButton, ToggleButtonGroup, TreeView, TreeItem
147
-
148
- #### `mui-v7/no-deprecated-props`
149
-
150
- Detects props removed in V7.
151
-
152
- ```typescript
153
- // ❌ Dialog.onBackdropClick - REMOVED
154
- <Dialog onBackdropClick={handleClick}>
155
-
156
- // βœ… Use onClose with reason check
157
- <Dialog onClose={(event, reason) => {
158
- if (reason === 'backdropClick') {
159
- // Your logic here
160
- }
161
- }}>
162
-
163
- // ❌ InputLabel size="normal" - RENAMED
164
- <InputLabel size="normal">
165
-
166
- // βœ… Use size="medium"
167
- <InputLabel size="medium">
168
-
169
- // ❌ Hidden component - REMOVED
170
- <Hidden xlUp><Paper /></Hidden>
171
-
172
- // βœ… Use sx prop
173
- <Paper sx={{ display: { xl: 'none' } }} />
174
-
175
- // βœ… Or use useMediaQuery
176
- const hidden = useMediaQuery(theme => theme.breakpoints.up('xl'))
177
- return hidden ? null : <Paper />
178
- ```
179
-
180
- ### πŸ’‘ Best Practices (Warnings)
181
-
182
- These are suggestions, not breaking changes.
183
-
184
- #### `mui-v7/prefer-theme-vars`
185
-
186
- When using `cssVariables: true`, use `theme.vars.*` for better performance and automatic dark mode.
187
-
188
- ```typescript
189
- // ⚠️ Works but doesn't change with dark mode automatically
190
- const Custom = styled('div')(({ theme }) => ({
191
- color: theme.palette.text.primary,
192
- }))
193
-
194
- // βœ… Better: Changes automatically with dark mode
195
- const Custom = styled('div')(({ theme }) => ({
196
- color: theme.vars.palette.text.primary,
197
- }))
198
- ```
199
-
200
- ## πŸŽ“ Example Messages
201
-
202
- The plugin provides educational messages with emojis and examples:
203
-
204
- ```
205
- 🎯 Grid no MUI V7 não usa mais a prop `item`!
206
-
207
- πŸ”§ Forma antiga (V6):
208
- <Grid item xs={12} sm={6} md={4}>
209
-
210
- βœ… Forma nova (V7):
211
- <Grid size={{ xs: 12, sm: 6, md: 4 }}>
212
-
213
- πŸ’‘ A nova sintaxe Γ© mais limpa e poderosa!
214
- VocΓͺ pode usar: size, offset, spacing responsivo e mais.
215
- ```
216
-
217
- ## πŸ”§ Configuration Presets
218
-
219
- ### `recommended` - Balanced (Default)
220
-
221
- Breaking changes as **errors**, best practices as **warnings**.
222
-
223
- ```javascript
224
- import muiV7Plugin from 'eslint-plugin-mui-v7'
225
-
226
- export default [
227
- muiV7Plugin.configs.recommended,
228
- ]
229
- ```
230
-
231
- ### `strict` - Strict Mode
232
-
233
- Everything as **errors** (including best practices).
234
-
235
- ```javascript
236
- import muiV7Plugin from 'eslint-plugin-mui-v7'
237
-
238
- export default [
239
- muiV7Plugin.configs.strict,
240
- ]
241
- ```
242
-
243
- ## πŸ†• What's New in v1.1.0
244
-
245
- ### Added
246
- - ✨ New rule `no-unstable-grid` - Detects Unstable_Grid2 usage
247
-
248
- ### Changed
249
- - πŸ“ All import examples now show recommended style: `import { Grid } from '@mui/material'`
250
- - 🎯 Refocused on breaking changes only (removed non-breaking rules)
251
- - πŸ“¦ Updated plugin description and categories
252
-
253
- ### Removed
254
- - ❌ `no-deep-imports` - Not a breaking change in V7
255
- - ❌ `no-old-grid-import` - Confusing and not a breaking change
256
-
257
- ## πŸ“š Migration Guide
258
-
259
- 1. Install the plugin:
260
- ```bash
261
- npm install --save-dev eslint-plugin-mui-v7
262
- ```
263
-
264
- 2. Add to your ESLint config:
265
- ```javascript
266
- // eslint.config.js
267
- import muiV7Plugin from 'eslint-plugin-mui-v7'
268
-
269
- export default [
270
- muiV7Plugin.configs.recommended,
271
- ]
272
- ```
273
-
274
- 3. Run ESLint:
275
- ```bash
276
- npx eslint . --fix
277
- ```
278
-
279
- 4. Fix remaining issues manually (the plugin will guide you!)
280
-
281
- ## 🀝 Contributing
282
-
283
- Contributions are welcome! Please feel free to submit a Pull Request.
284
-
285
- ## πŸ“„ License
286
-
287
- MIT Β© Matheus Pimenta (Koda AI Studio)
288
-
289
- ## πŸ”— Links
290
-
291
- - [Material-UI V7 Migration Guide](https://mui.com/material-ui/migration/upgrade-to-v7/)
292
- - [GitHub Repository](https://github.com/Just-mpm/eslint-plugin-mui-v7)
293
- - [npm Package](https://www.npmjs.com/package/eslint-plugin-mui-v7)
294
-
295
- ## ❀️ Credits
296
-
297
- Created by **Matheus Pimenta** (Koda AI Studio) + **Claude Code**
298
-
299
- ---
300
-
301
- **Keywords:** eslint, mui, material-ui, mui-v7, react, typescript, linter, code-quality, migration, breaking-changes
1
+ # eslint-plugin-mui-v7
2
+
3
+ > ESLint plugin focused on Material-UI V6 to V7 **breaking changes** with educational error messages
4
+
5
+ Automatically detect code that **BREAKS** when migrating from MUI V6 to V7 and teach developers the correct way through helpful messages with emojis and examples!
6
+
7
+ ## 🎯 Philosophy
8
+
9
+ This plugin focuses on **breaking changes only** - code that will actually break when upgrading to V7. We don't warn about best practices or style preferences, just things that will cause errors.
10
+
11
+ **πŸŽ‰ Complete Coverage:** Detects **100% of all detectable MUI V7 breaking changes** (13/13) with **100% autofix support** (10/10 rules)!
12
+
13
+ ## ✨ Features
14
+
15
+ - πŸš€ **Detect Unstable_Grid2 usage** - Now promoted to stable Grid
16
+ - ⚠️ **Catch Grid2 usage** - Grid2 was renamed to Grid in V7
17
+ - 🎯 **Grid item prop detection** - Grid doesn't use `item` prop anymore, use `size` instead
18
+ - ✨ **Find moved @mui/lab components** - Alert, Skeleton, Rating, etc. are now in @mui/material
19
+ - πŸ”„ **Detect deprecated props** - onBackdropClick, size="normal", Hidden/PigmentHidden components
20
+ - 🎨 **Catch deprecated imports** - createMuiTheme, experimentalStyled, StyledEngineProvider wrong location
21
+ - πŸ“¦ **Deep imports detection** - Deep imports break in V7 due to exports field
22
+ - ⚠️ **GridLegacy detection** - Catch old Grid imports that are now deprecated
23
+ - πŸ”§ **Components/componentsProps deprecation** - Suggests slots/slotProps API
24
+ - πŸ’‘ **Theme variables suggestion** - Use `theme.vars.*` for automatic dark mode support (optional)
25
+ - πŸ”§ **Auto-fix available** for 10/10 rules (100%)! 🎯
26
+
27
+ ## πŸ“¦ Installation
28
+
29
+ ```bash
30
+ npm install --save-dev eslint-plugin-mui-v7
31
+ ```
32
+
33
+ ## πŸ“š Complete Setup Tutorial
34
+
35
+ ### Step 1: Install the Plugin
36
+
37
+ Choose your package manager:
38
+
39
+ ```bash
40
+ # npm
41
+ npm install --save-dev eslint-plugin-mui-v7
42
+
43
+ # yarn
44
+ yarn add -D eslint-plugin-mui-v7
45
+
46
+ # pnpm
47
+ pnpm add -D eslint-plugin-mui-v7
48
+ ```
49
+
50
+ ### Step 2: Configure ESLint
51
+
52
+ #### For ESLint 9+ (Flat Config) - Recommended ✨
53
+
54
+ Create or update your `eslint.config.js` file:
55
+
56
+ ```javascript
57
+ // eslint.config.js
58
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
59
+
60
+ export default [
61
+ // Use the recommended preset (easiest option!)
62
+ muiV7Plugin.configs.recommended,
63
+
64
+ // Your other ESLint configs...
65
+ ]
66
+ ```
67
+
68
+ **That's it!** The plugin is now configured with all breaking changes as errors and best practices as warnings.
69
+
70
+ #### For ESLint <9 (Legacy .eslintrc)
71
+
72
+ Create or update your `.eslintrc.js` file:
73
+
74
+ ```javascript
75
+ // .eslintrc.js
76
+ module.exports = {
77
+ plugins: ['mui-v7'],
78
+ rules: {
79
+ // Breaking changes - ERRORS
80
+ 'mui-v7/no-unstable-grid': 'error',
81
+ 'mui-v7/no-grid2-import': 'error',
82
+ 'mui-v7/no-grid-item-prop': 'error',
83
+ 'mui-v7/no-lab-imports': 'error',
84
+ 'mui-v7/no-deprecated-props': 'error',
85
+ 'mui-v7/no-deprecated-imports': 'error',
86
+ 'mui-v7/no-deep-imports': 'error',
87
+ 'mui-v7/no-grid-legacy': 'error',
88
+
89
+ // Best practices - WARNINGS
90
+ 'mui-v7/prefer-slots-api': 'warn',
91
+ 'mui-v7/prefer-theme-vars': 'warn',
92
+ },
93
+ }
94
+ ```
95
+
96
+ ### Step 3: Run ESLint on Your Code
97
+
98
+ Check your code for MUI V7 breaking changes:
99
+
100
+ ```bash
101
+ # Check all files
102
+ npx eslint .
103
+
104
+ # Check specific directory
105
+ npx eslint src/
106
+
107
+ # Check and auto-fix issues
108
+ npx eslint . --fix
109
+ ```
110
+
111
+ ### Step 4: Review and Fix Issues
112
+
113
+ The plugin will show you:
114
+ - ❌ **Errors** - Code that WILL BREAK in MUI V7
115
+ - ⚠️ **Warnings** - Best practices and deprecated patterns
116
+
117
+ Most issues can be auto-fixed with `--fix`! 🎯
118
+
119
+ ### Step 5: Fix Remaining Issues Manually
120
+
121
+ For issues that can't be auto-fixed (like spread props), the plugin provides helpful messages:
122
+
123
+ ```
124
+ ❌ mui-v7/no-grid-item-prop
125
+
126
+ 🎯 Grid in MUI V7 no longer uses the `item` prop!
127
+
128
+ πŸ”§ Old way (V6):
129
+ <Grid item xs={12} sm={6}>
130
+
131
+ βœ… New way (V7):
132
+ <Grid size={{ xs: 12, sm: 6 }}>
133
+
134
+ πŸ’‘ The new syntax is cleaner and more powerful!
135
+ ```
136
+
137
+ ### Complete Example
138
+
139
+ Here's a complete `eslint.config.js` for a React + TypeScript + MUI project:
140
+
141
+ ```javascript
142
+ // eslint.config.js
143
+ import js from '@eslint/js'
144
+ import tseslint from 'typescript-eslint'
145
+ import reactPlugin from 'eslint-plugin-react'
146
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
147
+
148
+ export default [
149
+ js.configs.recommended,
150
+ ...tseslint.configs.recommended,
151
+ reactPlugin.configs.flat.recommended,
152
+
153
+ // Add MUI V7 plugin
154
+ muiV7Plugin.configs.recommended,
155
+
156
+ {
157
+ files: ['**/*.{js,jsx,ts,tsx}'],
158
+ languageOptions: {
159
+ parserOptions: {
160
+ ecmaFeatures: {
161
+ jsx: true,
162
+ },
163
+ },
164
+ },
165
+ },
166
+ ]
167
+ ```
168
+
169
+ ## πŸš€ Quick Start
170
+
171
+ ### ESLint 9+ (Flat Config) - Recommended
172
+
173
+ ```javascript
174
+ // eslint.config.js
175
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
176
+
177
+ export default [
178
+ muiV7Plugin.configs.recommended, // βœ… Apply all recommended rules
179
+ ]
180
+ ```
181
+
182
+ ### Manual Configuration
183
+
184
+ ```javascript
185
+ // eslint.config.js
186
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
187
+
188
+ export default [
189
+ {
190
+ plugins: {
191
+ 'mui-v7': muiV7Plugin,
192
+ },
193
+ rules: {
194
+ // Breaking changes - ERRORS (cΓ³digo quebra)
195
+ 'mui-v7/no-unstable-grid': 'error',
196
+ 'mui-v7/no-grid2-import': 'error',
197
+ 'mui-v7/no-grid-item-prop': 'error',
198
+ 'mui-v7/no-lab-imports': 'error',
199
+ 'mui-v7/no-deprecated-props': 'error',
200
+ 'mui-v7/no-deprecated-imports': 'error',
201
+ 'mui-v7/no-deep-imports': 'error',
202
+ 'mui-v7/no-grid-legacy': 'error',
203
+
204
+ // Best practices - WARNINGS (sugestΓ΅es)
205
+ 'mui-v7/prefer-slots-api': 'warn',
206
+ 'mui-v7/prefer-theme-vars': 'warn',
207
+ },
208
+ },
209
+ ]
210
+ ```
211
+
212
+ ### ESLint <9 (Legacy Config)
213
+
214
+ ```javascript
215
+ // .eslintrc.js
216
+ module.exports = {
217
+ plugins: ['mui-v7'],
218
+ rules: {
219
+ 'mui-v7/no-unstable-grid': 'error',
220
+ 'mui-v7/no-grid2-import': 'error',
221
+ 'mui-v7/no-grid-item-prop': 'error',
222
+ 'mui-v7/no-lab-imports': 'error',
223
+ 'mui-v7/no-deprecated-props': 'error',
224
+ 'mui-v7/no-deprecated-imports': 'error',
225
+ 'mui-v7/no-deep-imports': 'error',
226
+ 'mui-v7/no-grid-legacy': 'error',
227
+ 'mui-v7/prefer-slots-api': 'warn',
228
+ 'mui-v7/prefer-theme-vars': 'warn',
229
+ },
230
+ }
231
+ ```
232
+
233
+ ## πŸ“‹ Rules
234
+
235
+ ### 🚨 Breaking Changes (Errors)
236
+
237
+ These rules detect code that **WILL BREAK** in MUI V7.
238
+
239
+ #### `mui-v7/no-unstable-grid` ✨ NEW in v1.1.0
240
+
241
+ Unstable_Grid2 was promoted to stable Grid in V7.
242
+
243
+ ```typescript
244
+ // ❌ Breaks in V7
245
+ import Grid from '@mui/material/Unstable_Grid2'
246
+ import Grid2 from '@mui/material/Unstable_Grid2'
247
+
248
+ // βœ… Recommended
249
+ import { Grid } from '@mui/material'
250
+ ```
251
+
252
+ #### `mui-v7/no-grid2-import`
253
+
254
+ Grid2 was renamed to Grid in V7.
255
+
256
+ ```typescript
257
+ // ❌ Breaks in V7
258
+ import Grid2 from '@mui/material/Grid2'
259
+ import { grid2Classes } from '@mui/material/Grid2'
260
+
261
+ // βœ… Recommended
262
+ import { Grid } from '@mui/material'
263
+ import { gridClasses } from '@mui/material'
264
+ ```
265
+
266
+ #### `mui-v7/no-grid-item-prop` ✨ IMPROVED in v1.3.0
267
+
268
+ Grid doesn't use `item` prop anymore, use `size` instead. Now with **auto-fix**!
269
+
270
+ ```typescript
271
+ // ❌ Breaks in V7
272
+ <Grid item xs={12} sm={6} md={4}>
273
+ Content
274
+ </Grid>
275
+
276
+ // βœ… Works in V7
277
+ <Grid size={{ xs: 12, sm: 6, md: 4 }}>
278
+ Content
279
+ </Grid>
280
+ ```
281
+
282
+ #### `mui-v7/no-lab-imports`
283
+
284
+ Components moved from @mui/lab to @mui/material.
285
+
286
+ ```typescript
287
+ // ❌ Breaks in V7
288
+ import { Alert } from '@mui/lab'
289
+ import { Skeleton } from '@mui/lab'
290
+
291
+ // βœ… Recommended
292
+ import { Alert } from '@mui/material'
293
+ import { Skeleton } from '@mui/material'
294
+ ```
295
+
296
+ **Moved components:** Alert, AlertTitle, Autocomplete, AvatarGroup, Pagination, PaginationItem, Rating, Skeleton, SpeedDial, SpeedDialAction, SpeedDialIcon, ToggleButton, ToggleButtonGroup
297
+
298
+ **Still in @mui/lab:** LoadingButton, Masonry, TabContext, TabList, TabPanel, Timeline (and related components)
299
+
300
+ **Moved to MUI X:** TreeView and TreeItem moved to @mui/x-tree-view (not @mui/material)
301
+
302
+ #### `mui-v7/no-deprecated-props` ✨ IMPROVED in v1.3.0
303
+
304
+ Detects props and components removed in V7.
305
+
306
+ ```typescript
307
+ // ❌ Dialog.onBackdropClick - REMOVED
308
+ <Dialog onBackdropClick={handleClick}>
309
+
310
+ // ❌ Modal.onBackdropClick - REMOVED (NEW!)
311
+ <Modal onBackdropClick={handleClick}>
312
+
313
+ // βœ… Use onClose with reason check
314
+ <Dialog onClose={(event, reason) => {
315
+ if (reason === 'backdropClick') {
316
+ // Your logic here
317
+ }
318
+ }}>
319
+
320
+ // ❌ InputLabel size="normal" - RENAMED
321
+ <InputLabel size="normal">
322
+
323
+ // βœ… Use size="medium" (with auto-fix!)
324
+ <InputLabel size="medium">
325
+
326
+ // ❌ Hidden component - REMOVED
327
+ <Hidden xlUp><Paper /></Hidden>
328
+
329
+ // ❌ PigmentHidden component - REMOVED (NEW!)
330
+ <PigmentHidden xlUp><Paper /></PigmentHidden>
331
+
332
+ // βœ… Use sx prop
333
+ <Paper sx={{ display: { xl: 'none' } }} />
334
+
335
+ // βœ… Or use useMediaQuery
336
+ const hidden = useMediaQuery(theme => theme.breakpoints.up('xl'))
337
+ return hidden ? null : <Paper />
338
+ ```
339
+
340
+ #### `mui-v7/no-deprecated-imports` ✨ IMPROVED in v1.5.1
341
+
342
+ Detects deprecated imports removed in V7.
343
+
344
+ ```typescript
345
+ // ❌ createMuiTheme - REMOVED
346
+ import { createMuiTheme } from '@mui/material/styles'
347
+
348
+ // βœ… Use createTheme (with auto-fix!)
349
+ import { createTheme } from '@mui/material/styles'
350
+
351
+ // ❌ experimentalStyled - REMOVED
352
+ import { experimentalStyled } from '@mui/material/styles'
353
+
354
+ // βœ… Use styled (with auto-fix!)
355
+ import { styled } from '@mui/material/styles'
356
+
357
+ // ❌ StyledEngineProvider from wrong location - REMOVED (NEW in v1.5.1!)
358
+ import { StyledEngineProvider } from '@mui/material'
359
+
360
+ // βœ… Import from correct location (with auto-fix!)
361
+ import { StyledEngineProvider } from '@mui/material/styles'
362
+ ```
363
+
364
+ #### `mui-v7/no-deep-imports` ✨ NEW in v1.4.0
365
+
366
+ Detects deep imports that break in V7 due to the exports field.
367
+
368
+ ```typescript
369
+ // ❌ Deep imports don't work anymore
370
+ import Button from '@mui/material/Button/Button'
371
+
372
+ // βœ… Use main entry point (with auto-fix!)
373
+ import { Button } from '@mui/material'
374
+ ```
375
+
376
+ #### `mui-v7/no-grid-legacy` ✨ NEW in v1.4.0
377
+
378
+ Detects old Grid imports that are now deprecated.
379
+
380
+ ```typescript
381
+ // ❌ Old Grid import (now GridLegacy)
382
+ import Grid from '@mui/material/Grid'
383
+
384
+ // βœ… Option 1: Keep using old Grid temporarily (with auto-fix!)
385
+ import { GridLegacy as Grid } from '@mui/material'
386
+
387
+ // βœ… Option 2: Migrate to new Grid (recommended!)
388
+ import { Grid } from '@mui/material'
389
+ // Use size={{ xs: 12 }} instead of item xs={12}
390
+ ```
391
+
392
+ ### πŸ’‘ Best Practices (Warnings)
393
+
394
+ These are suggestions, not breaking changes.
395
+
396
+ #### `mui-v7/prefer-slots-api` ✨ NEW in v1.3.0
397
+
398
+ Recommends using slots/slotProps instead of components/componentsProps.
399
+
400
+ ```typescript
401
+ // ⚠️ Deprecated (still works but will be removed)
402
+ <TextField
403
+ components={{ Input: CustomInput }}
404
+ componentsProps={{ input: { className: 'custom' } }}
405
+ />
406
+
407
+ // βœ… Recommended: New slots API
408
+ <TextField
409
+ slots={{ input: CustomInput }}
410
+ slotProps={{ input: { className: 'custom' } }}
411
+ />
412
+ ```
413
+
414
+ #### `mui-v7/prefer-theme-vars` ✨ IMPROVED in v1.5.0
415
+
416
+ When using `cssVariables: true`, use `theme.vars.*` for better performance and automatic dark mode. Now with **auto-fix**!
417
+
418
+ ```typescript
419
+ // ⚠️ Works but doesn't change with dark mode automatically
420
+ const Custom = styled('div')(({ theme }) => ({
421
+ color: theme.palette.text.primary,
422
+ }))
423
+
424
+ // βœ… Better: Changes automatically with dark mode (with auto-fix!)
425
+ const Custom = styled('div')(({ theme }) => ({
426
+ color: theme.vars.palette.text.primary,
427
+ }))
428
+ ```
429
+
430
+ ## πŸŽ“ Example Messages
431
+
432
+ The plugin provides educational messages with emojis and examples:
433
+
434
+ ```
435
+ 🎯 Grid in MUI V7 no longer uses the `item` prop!
436
+
437
+ πŸ”§ Old way (V6):
438
+ <Grid item xs={12} sm={6} md={4}>
439
+
440
+ βœ… New way (V7):
441
+ <Grid size={{ xs: 12, sm: 6, md: 4 }}>
442
+
443
+ πŸ’‘ The new syntax is cleaner and more powerful!
444
+ You can use: size, offset, responsive spacing, and more.
445
+ ```
446
+
447
+ ## πŸ”§ Configuration Presets
448
+
449
+ ### `recommended` - Balanced (Default)
450
+
451
+ Breaking changes as **errors**, best practices as **warnings**.
452
+
453
+ ```javascript
454
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
455
+
456
+ export default [
457
+ muiV7Plugin.configs.recommended,
458
+ ]
459
+ ```
460
+
461
+ ### `strict` - Strict Mode
462
+
463
+ Everything as **errors** (including best practices).
464
+
465
+ ```javascript
466
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
467
+
468
+ export default [
469
+ muiV7Plugin.configs.strict,
470
+ ]
471
+ ```
472
+
473
+ ## πŸ†• What's New
474
+
475
+ ### v1.5.1 (2025-11-14) - Complete Coverage! βœ…
476
+
477
+ #### Added
478
+ - ✨ **StyledEngineProvider import detection** in `no-deprecated-imports`
479
+ - Detects incorrect imports from `@mui/material` instead of `@mui/material/styles`
480
+ - Automatic fix to correct import location
481
+ - Completes **100% coverage** of all detectable MUI V7 breaking changes!
482
+
483
+ #### Coverage Achievement
484
+ - βœ… **13/13** official MUI V7 breaking changes detected (100%)
485
+ - βœ… **10/10** rules with autofix support (100%)
486
+ - βœ… **0** known false positives
487
+
488
+ ### v1.5.0 (2025-11-14) - 100% Autofix! 🎯
489
+
490
+ #### Added
491
+ - ✨ **Autofix for `prefer-theme-vars`**: Automatically transforms `theme.palette.*` β†’ `theme.vars.palette.*`
492
+ - Works in styled components, sx props, template literals, and object expressions
493
+ - Safely handles edge cases (ternary conditionals, non-null assertions)
494
+ - **Achieved 100% autofix coverage for all 10 rules!** 🎯
495
+
496
+ ### v1.4.1 (2025-11-14) - Critical Bug Fix! πŸ”§
497
+
498
+ #### Fixed
499
+ - πŸ› **Removed 12 false positives** from `no-lab-imports` rule:
500
+ - **Timeline components** (7): Still in `@mui/lab`, not moved to `@mui/material`
501
+ - **Tab components** (3): TabContext, TabList, TabPanel still in `@mui/lab`
502
+ - **TreeView components** (2): Moved to `@mui/x-tree-view`, not `@mui/material`
503
+
504
+ ### v1.4.0 (2025-11-14) - New Rules! πŸš€
505
+
506
+ #### Added
507
+ - ✨ **no-deep-imports**: Detects deep imports that break due to exports field (with auto-fix!)
508
+ - ✨ **no-grid-legacy**: Detects old Grid imports now renamed to GridLegacy (with auto-fix!)
509
+
510
+ #### Enhanced
511
+ - πŸ”§ **no-grid-item-prop**: Added safety check to prevent autofix when spread props are present
512
+ - πŸ“ **Documentation**: Added "Known Limitations" section explaining edge cases
513
+
514
+ ### v1.3.0 (2025-11-14) - Major Update! πŸŽ‰
515
+
516
+ #### New Rules
517
+ - ✨ **no-deprecated-imports**: Detects `createMuiTheme` and `experimentalStyled` (with auto-fix!)
518
+ - ✨ **prefer-slots-api**: Recommends `slots`/`slotProps` over `components`/`componentsProps`
519
+
520
+ #### Enhanced Rules
521
+ - πŸ”§ **no-deprecated-props**: Now detects `Modal.onBackdropClick` and `PigmentHidden` component
522
+ - πŸ”§ **no-deprecated-props**: Auto-fix for `InputLabel size="normal"` β†’ `size="medium"`
523
+ - πŸ”§ **no-grid-item-prop**: Smart auto-fix that converts breakpoint props to `size` object
524
+ - πŸ”§ **no-grid2-import**: Improved fix that properly renames `Grid2` β†’ `Grid` and `grid2Classes` β†’ `gridClasses`
525
+ - πŸ”§ **no-unstable-grid**: Better handling of default imports
526
+
527
+ #### Code Quality
528
+ - βœ… Added comprehensive test suite with 50+ test cases
529
+ - πŸ›‘οΈ Added optional chaining (`?.`) for safer AST navigation
530
+ - πŸ“¦ Updated package.json with proper test scripts
531
+ - πŸ”„ Updated to run tests before publishing (`prepublishOnly`)
532
+
533
+ ### v1.2.1 (2025-10-30)
534
+
535
+ #### UX Improvements
536
+ - ✨ Enhanced `no-lab-imports` to show **all moved components** in error messages
537
+ - πŸ“ Before: `Este componente foi movido` (showed only first component)
538
+ - 🎯 Now: `3 componente(s) movido(s)` with complete list: `Alert, Autocomplete, Rating`
539
+
540
+ ### v1.2.0 (2025-10-30)
541
+
542
+ #### Performance
543
+ - ⚑ Optimized `no-lab-imports`: O(nΓ—m) β†’ O(n) using Set lookup instead of Array.includes
544
+ - ⚑ Optimized `prefer-theme-vars`: Added WeakMap cache for getText() calls to eliminate duplicate I/O
545
+ - 🧹 Improved code readability with optional chaining and early returns
546
+ - πŸ“Š Moved `MOVED_COMPONENTS` to module scope to avoid recreation on every rule invocation
547
+
548
+ #### Internal
549
+ - πŸ—οΈ Formalized AST traversal depth tracking with MAX_DEPTH constant
550
+ - πŸ’Ύ Source text caching to prevent redundant file reads
551
+
552
+ ### v1.1.0 (2025-01-27)
553
+
554
+ #### Added
555
+ - ✨ New rule `no-unstable-grid` - Detects Unstable_Grid2 usage
556
+
557
+ #### Changed
558
+ - πŸ“ All import examples now show recommended style: `import { Grid } from '@mui/material'`
559
+ - 🎯 Refocused on breaking changes only (removed non-breaking rules)
560
+ - πŸ“¦ Updated plugin description and categories
561
+
562
+ #### Removed
563
+ - ❌ `no-deep-imports` - Not a breaking change in V7
564
+ - ❌ `no-old-grid-import` - Confusing and not a breaking change
565
+
566
+ ## πŸ“š Migration Guide
567
+
568
+ 1. Install the plugin:
569
+ ```bash
570
+ npm install --save-dev eslint-plugin-mui-v7
571
+ ```
572
+
573
+ 2. Add to your ESLint config:
574
+ ```javascript
575
+ // eslint.config.js
576
+ import muiV7Plugin from 'eslint-plugin-mui-v7'
577
+
578
+ export default [
579
+ muiV7Plugin.configs.recommended,
580
+ ]
581
+ ```
582
+
583
+ 3. Run ESLint:
584
+ ```bash
585
+ npx eslint . --fix
586
+ ```
587
+
588
+ 4. Fix remaining issues manually (the plugin will guide you!)
589
+
590
+ ## ⚠️ Known Limitations
591
+
592
+ This plugin has some limitations to ensure safe and reliable autofixes:
593
+
594
+ ### 1. **Spread Props are Not Auto-Fixed**
595
+
596
+ When a component has spread props (`{...props}`), the autofix is disabled to avoid potential issues:
597
+
598
+ ```tsx
599
+ // ❌ Plugin detects the issue but WON'T auto-fix (safe!)
600
+ <Grid {...props} item xs={12}>Content</Grid>
601
+
602
+ // Why? If props contains { item: true, xs: 6 }, the spread would override our fix
603
+ ```
604
+
605
+ **Solution:** Fix manually or remove the spread props first.
606
+
607
+ ### 2. **Dynamic Props are Not Auto-Fixed**
608
+
609
+ Complex expressions and variables are not auto-fixed:
610
+
611
+ ```tsx
612
+ // ❌ Plugin detects but WON'T auto-fix (safe!)
613
+ <Grid item xs={isMobile ? 12 : 6}>Content</Grid>
614
+ <Grid item xs={colSize}>Content</Grid>
615
+ ```
616
+
617
+ **Solution:** These require manual migration to `size` prop.
618
+
619
+ ### 3. **Cross-File Dependencies**
620
+
621
+ The plugin cannot detect issues that span multiple files:
622
+
623
+ ```tsx
624
+ // File 1: component-props.ts
625
+ export const gridProps = { item: true, xs: 12 }
626
+
627
+ // File 2: Component.tsx - Plugin won't detect this!
628
+ <Grid {...gridProps}>Content</Grid>
629
+ ```
630
+
631
+ **Solution:** Run the plugin on all files and review spread props carefully.
632
+
633
+ ### 4. **Best Practices vs Breaking Changes**
634
+
635
+ The plugin focuses on **breaking changes only**. Some MUI best practices are not enforced:
636
+
637
+ - βœ… Detects: Code that **breaks** in V7
638
+ - ❌ Doesn't detect: Deprecated but still working code (unless it's in the migration path)
639
+
640
+ ### πŸ”— For Complex Cases
641
+
642
+ For complex migrations, consider using MUI's official codemods:
643
+
644
+ ```bash
645
+ # Official MUI codemods
646
+ npx @mui/codemod v7.0.0/grid-props <path>
647
+ npx @mui/codemod v7.0.0/lab-removed-components <path>
648
+ ```
649
+
650
+ **This plugin complements the codemods by providing continuous validation!**
651
+
652
+ ## πŸ§ͺ Testing
653
+
654
+ Run the comprehensive test suite:
655
+
656
+ ```bash
657
+ npm test
658
+ ```
659
+
660
+ Watch mode for development:
661
+
662
+ ```bash
663
+ npm run test:watch
664
+ ```
665
+
666
+ ## 🀝 Contributing
667
+
668
+ Contributions are welcome! Please feel free to submit a Pull Request.
669
+
670
+ ## πŸ“„ License
671
+
672
+ MIT Β© Matheus Pimenta (Koda AI Studio)
673
+
674
+ ## πŸ”— Links
675
+
676
+ - [Material-UI V7 Migration Guide](https://mui.com/material-ui/migration/upgrade-to-v7/)
677
+ - [GitHub Repository](https://github.com/Just-mpm/eslint-plugin-mui-v7)
678
+ - [npm Package](https://www.npmjs.com/package/eslint-plugin-mui-v7)
679
+
680
+ ## ❀️ Credits
681
+
682
+ Created by **Matheus Pimenta** (Koda AI Studio) + **Claude Code**
683
+
684
+ ---
685
+
686
+ **Keywords:** eslint, mui, material-ui, mui-v7, react, typescript, linter, code-quality, migration, breaking-changes