-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
.eslintrc.js
101 lines (97 loc) · 3.25 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const baseline = require('@mui/monorepo/.eslintrc');
const path = require('path');
const OneLevelImportMessage = [
'Prefer one level nested imports to avoid bundling everything in dev mode or breaking CJS/ESM split.',
'See https://github.com/mui/material-ui/pull/24147 for the kind of win it can unlock.',
].join('\n');
const NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED = [
{
group: ['@base-ui-components/react/*/*'],
message: OneLevelImportMessage,
},
];
module.exports = {
...baseline,
settings: {
'import/resolver': {
webpack: {
config: path.join(__dirname, './webpackBaseConfig.js'),
},
},
},
/**
* Sorted alphanumerically within each group. built-in and each plugin form
* their own groups.
*/
rules: {
...baseline.rules,
// TODO move to @mui/monorepo, codebase is moving away from default exports https://github.com/mui/material-ui/issues/21862
'import/prefer-default-export': 'off',
'import/export': 'off', // Mostly handled by Typescript itself. ESLint produces false positives with declaration merging.
'no-restricted-imports': [
'error',
{
patterns: NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED,
},
],
'@typescript-eslint/no-redeclare': 'off',
// We LOVE non-breaking spaces, and both straight and curly quotes here
'no-irregular-whitespace': [1, { skipJSXText: true, skipStrings: true }],
'react/no-unescaped-entities': [1, { forbid: ['>', '}'] }],
'material-ui/straight-quotes': 'off',
// This prevents us from creating components like `<h1 {...props} />`
'jsx-a11y/heading-has-content': 'off',
'jsx-a11y/anchor-has-content': 'off',
// This rule doesn't recognise <label> wrapped around custom controls
'jsx-a11y/label-has-associated-control': 'off',
},
overrides: [
...baseline.overrides.filter(
(ruleSet) => !ruleSet.rules.hasOwnProperty('filenames/match-exported'),
),
{
files: ['docs/src/app/experiments/**/*{.tsx,.js}', 'docs/pages/playground/**/*{.tsx,.js}'],
rules: {
'@typescript-eslint/no-use-before-define': 'off',
'react/prop-types': 'off',
'no-alert': 'off',
'no-console': 'off',
'import/no-relative-packages': 'off',
},
},
{
files: ['packages/**/*.test{.tsx,.js}'],
extends: ['plugin:testing-library/react'],
rules: {
'testing-library/prefer-screen-queries': 'off', // TODO: enable and fix
'testing-library/no-container': 'off', // TODO: enable and fix
'testing-library/render-result-naming-convention': 'off', // False positives
},
},
{
files: ['docs/**/*{.ts,.tsx,.js}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: NO_RESTRICTED_IMPORTS_PATTERNS_DEEPLY_NESTED,
},
],
'react/prop-types': 'off',
'@typescript-eslint/no-use-before-define': 'off',
},
},
{
files: ['docs/data/**/*{.tsx,.js}'],
excludedFiles: [
'docs/data/**/css/*{.tsx,.js}',
'docs/data/**/css-modules/*{.tsx,.js}',
'docs/data/**/system/*{.tsx,.js}',
'docs/data/**/tailwind/*{.tsx,.js}',
],
rules: {
'filenames/match-exported': ['error'],
},
},
],
};