Skip to content

Commit 6a48ed1

Browse files
authored
[code-infra] Lint json through eslint (#47056)
1 parent 1367a94 commit 6a48ed1

File tree

7 files changed

+668
-366
lines changed

7 files changed

+668
-366
lines changed

.circleci/config.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ jobs:
162162
- run:
163163
name: Stylelint
164164
command: pnpm stylelint
165-
- run:
166-
name: Lint JSON
167-
command: pnpm jsonlint
168165
- run:
169166
name: Lint Markdown
170167
command: pnpm markdownlint

apps/pigment-css-next-app/src/components/Box.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const atomics = generateAtomics(({ theme }) => ({
5050
},
5151
}));
5252

53-
// eslint-disable-next-line react/prop-types
5453
export function Box({ children, as = 'div', className = '', style = undefined, ...other }) {
5554
const Component = as;
5655
const atomicsResult = atomics(other);
@@ -60,7 +59,6 @@ export function Box({ children, as = 'div', className = '', style = undefined, .
6059
...style,
6160
};
6261
return (
63-
// eslint-disable-next-line react/jsx-filename-extension
6462
<Component className={componentClass} style={finalStyles}>
6563
{children}
6664
</Component>

apps/pigment-css-vite-app/src/Box.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const atomics = generateAtomics(({ theme }) => ({
5050
},
5151
}));
5252

53-
// eslint-disable-next-line react/prop-types
5453
export function Box({ children, as = 'div', className = '', style = undefined, ...other }) {
5554
const Component = as;
5655
const atomicsResult = atomics(other);
@@ -60,7 +59,6 @@ export function Box({ children, as = 'div', className = '', style = undefined, .
6059
...style,
6160
};
6261
return (
63-
// eslint-disable-next-line react/jsx-filename-extension
6462
<Component className={componentClass} style={finalStyles}>
6563
{children}
6664
</Component>

eslint.config.mjs

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createDocsConfig,
66
EXTENSION_TS,
77
EXTENSION_TEST_FILE,
8+
EXTENSION_DTS,
89
} from '@mui/internal-code-infra/eslint';
910
import { defineConfig } from 'eslint/config';
1011
import eslintPluginConsistentName from 'eslint-plugin-consistent-default-export-name';
@@ -53,12 +54,20 @@ const NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED = [
5354
];
5455

5556
export default defineConfig(
57+
createBaseConfig({
58+
enableReactCompiler: ENABLE_REACT_COMPILER_PLUGIN,
59+
baseDirectory: dirname,
60+
}),
5661
{
57-
name: 'Base ESLint Configuration',
58-
extends: createBaseConfig({
59-
enableReactCompiler: ENABLE_REACT_COMPILER_PLUGIN,
60-
baseDirectory: dirname,
61-
}),
62+
name: 'Material UI overrides',
63+
files: [`**/*${EXTENSION_TS}`],
64+
settings: {
65+
'import/resolver': {
66+
typescript: {
67+
project: ['tsconfig.json'],
68+
},
69+
},
70+
},
6271
rules: {
6372
'import/prefer-default-export': 'error',
6473
'material-ui/straight-quotes': 'error',
@@ -71,6 +80,7 @@ export default defineConfig(
7180
'react/sort-prop-types': 'off', // 228
7281
'@typescript-eslint/ban-ts-comment': 'off', // 117
7382
'@typescript-eslint/no-require-imports': 'off', // 133
83+
'react/jsx-filename-extension': 'off',
7484
},
7585
},
7686
...['mui-material', 'mui-system', 'mui-utils', 'mui-lab', 'mui-utils', 'mui-styled-engine'].map(
@@ -91,9 +101,16 @@ export default defineConfig(
91101
},
92102
}),
93103
),
104+
{
105+
files: [`packages/**/*${EXTENSION_TS}`],
106+
rules: {
107+
// Our packages write .js + .d.ts files manually.
108+
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
109+
},
110+
},
94111
// Test start
95112
{
96-
files: [`**/*${EXTENSION_TEST_FILE}`, 'packages/mui-codemod/testUtils/**/*'],
113+
files: [`**/*${EXTENSION_TEST_FILE}`, `packages/mui-codemod/testUtils/**/*${EXTENSION_TS}`],
97114
extends: createTestConfig({
98115
useMocha: true,
99116
}),
@@ -113,7 +130,7 @@ export default defineConfig(
113130
// Test end
114131
// Docs start
115132
{
116-
files: ['docs/**/*'],
133+
files: [`docs/**/*${EXTENSION_TS}`],
117134
extends: createDocsConfig(),
118135
rules: {
119136
'@next/next/no-img-element': 'off',
@@ -128,7 +145,7 @@ export default defineConfig(
128145
},
129146
// Moved from docs/data/material/components/.eslintrc.js
130147
{
131-
files: ['docs/data/material/components/**/*'],
148+
files: [`docs/data/material/components/**/*${EXTENSION_TS}`],
132149
rules: {
133150
// useful for interactions feedback
134151
'no-console': ['off', { allow: ['info'] }],
@@ -138,7 +155,7 @@ export default defineConfig(
138155
},
139156
// demos
140157
{
141-
files: ['docs/src/pages/**/*', 'docs/data/**/*'],
158+
files: [`docs/src/pages/**/*${EXTENSION_TS}`, `docs/data/**/*${EXTENSION_TS}`],
142159
rules: {
143160
// This most often reports data that is defined after the component definition.
144161
// This is safe to do and helps readability of the demo code since the data is mostly irrelevant.
@@ -150,14 +167,14 @@ export default defineConfig(
150167
},
151168
// Next.js entry points pages
152169
{
153-
files: ['docs/pages/**/*', 'packages/*/src/**/*.tsx'],
170+
files: [`docs/pages/**/*${EXTENSION_TS}`, `packages/*/src/**/*.tsx`],
154171
ignores: ['**/*.spec.tsx'],
155172
rules: {
156173
'react/prop-types': 'off',
157174
},
158175
},
159176
{
160-
files: ['docs/data/**/*'],
177+
files: [`docs/data/**/*${EXTENSION_TS}`],
161178
ignores: [
162179
// filenames/match-exported sees filename as 'file-name.d'
163180
// Plugin looks unmaintain, find alternative? (e.g. eslint-plugin-project-structure)
@@ -174,7 +191,7 @@ export default defineConfig(
174191
},
175192
// Docs end
176193
{
177-
files: ['**/*.d.ts'],
194+
files: [`**/*${EXTENSION_DTS}`],
178195
rules: {
179196
'import/export': 'off', // Not sure why it doesn't work
180197
},
@@ -240,7 +257,7 @@ export default defineConfig(
240257
},
241258
// Migrated config from packages/mui-icons-material/.eslintrc.js
242259
{
243-
files: ['packages/mui-icons-material/custom/**/*'],
260+
files: [`packages/mui-icons-material/custom/**/*${EXTENSION_TS}`],
244261
rules: {
245262
'import/no-unresolved': 'off',
246263
'import/extensions': 'off',
@@ -249,54 +266,47 @@ export default defineConfig(
249266
// Migrated config from packages/api-docs-builder/.eslintrc.js
250267
{
251268
files: [
252-
'packages/api-docs-builder/**/*',
269+
`packages/api-docs-builder/**/*${EXTENSION_TS}`,
253270
// Allow named exports for locales: https://github.com/mui/material-ui/pull/46933
254-
'packages/mui-material/src/locale/*',
271+
`packages/mui-material/src/locale/*${EXTENSION_TS}`,
255272
],
256273
rules: {
257274
'import/prefer-default-export': 'off',
258275
},
259276
},
260277
// Migrated config from packages/api-docs-builder-core/.eslintrc.js
261278
{
262-
files: ['packages/api-docs-builder-core/**/*'],
279+
files: [`packages/api-docs-builder-core/**/*${EXTENSION_TS}`],
263280
rules: {
264281
'import/no-default-export': 'error',
265282
'import/prefer-default-export': 'off',
266283
},
267284
},
268285
// Migrated config from apps/bare-next-app/.eslintrc.js
269286
{
270-
files: ['apps/**/*', 'examples/**/*'],
287+
files: [`apps/**/*${EXTENSION_TS}`, `examples/**/*${EXTENSION_TS}`],
271288
rules: {
272289
'import/no-relative-packages': 'off',
273290
'react/react-in-jsx-scope': 'off',
274291
'react/prop-types': 'off',
292+
'import/prefer-default-export': 'off',
275293
},
276294
},
277295
{
278-
files: ['examples/**/*'],
296+
files: [`apps/bare-next-app/**/*${EXTENSION_TS}`],
297+
extends: [eslintPluginReact.configs.flat['jsx-runtime']],
279298
rules: {
280299
'import/extensions': 'off',
281300
'import/no-unresolved': 'off',
282-
'no-console': 'off',
283-
},
284-
},
285-
{
286-
files: ['apps/pigment-css-vite-app/**/*'],
287-
rules: {
288-
'react/jsx-filename-extension': 'off',
289-
'import/prefer-default-export': 'off',
301+
'react/no-unknown-property': ['error', { ignore: ['sx'] }],
290302
},
291303
},
292304
{
293-
files: ['apps/bare-next-app/**/*'],
294-
extends: [eslintPluginReact.configs.flat['jsx-runtime']],
305+
files: [`examples/**/*${EXTENSION_TS}`],
295306
rules: {
296-
'import/prefer-default-export': 'off',
297307
'import/extensions': 'off',
298308
'import/no-unresolved': 'off',
299-
'react/no-unknown-property': ['error', { ignore: ['sx'] }],
309+
'no-console': 'off',
300310
},
301311
},
302312
);

examples/material-ui-vite/src/main.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import * as React from 'react';
2-
import { createRoot } from 'react-dom/client';
2+
import * as ReactDOM from 'react-dom/client';
33
import CssBaseline from '@mui/material/CssBaseline';
44
import { ThemeProvider } from '@mui/material/styles';
55
import App from './App';
66
import theme from './theme';
77

88
const rootElement = document.getElementById('root');
9-
const root = createRoot(rootElement);
9+
const root = ReactDOM.createRoot(rootElement);
1010

1111
root.render(
1212
<React.StrictMode>

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"docs:zipRules": "cd docs && rm mui-vale.zip && zip -r mui-vale.zip mui-vale && cd ../ && pnpm vale sync",
3737
"extract-error-codes": "code-infra extract-error-codes --errorCodesPath docs/public/static/error-codes.json --skip @mui/core-downloads-tracker @mui/envinfo @mui/docs @mui/codemod @mui/icons-material",
3838
"template:screenshot": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/generateTemplateScreenshots",
39-
"jsonlint": "code-infra jsonlint",
4039
"eslint": "eslint . --cache --report-unused-disable-directives --ext .js,.ts,.tsx --max-warnings 0",
4140
"eslint:ci": "eslint . --report-unused-disable-directives --ext .js,.ts,.tsx --max-warnings 0",
4241
"stylelint": "stylelint --reportInvalidScopeDisables --reportNeedlessDisables \"docs/**/*.?(c|m)[jt]s?(x)\" \"docs/**/*.css\" --ignore-path .lintignore",
@@ -110,7 +109,7 @@
110109
"@mui-internal/api-docs-builder-core": "workspace:^",
111110
"@mui/internal-bundle-size-checker": "^1.0.9-canary.47",
112111
"@mui/internal-babel-plugin-minify-errors": "^2.0.8-canary.10",
113-
"@mui/internal-code-infra": "^0.0.3-canary.19",
112+
"@mui/internal-code-infra": "^0.0.3-canary.26",
114113
"@mui/internal-docs-utils": "workspace:^",
115114
"@mui/internal-netlify-cache": "^0.0.2-canary.0",
116115
"@mui/internal-scripts": "workspace:^",

0 commit comments

Comments
 (0)