-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy path.eslintrc.js
128 lines (122 loc) · 4.33 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const baseline = require('@mui/monorepo/.eslintrc');
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': {
typescript: {
project: ['docs/tsconfig.json', 'packages/*/tsconfig.test.json'],
},
},
},
/**
* 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',
// An overzealous rule that shouts at <a href="#"> in demos.
'jsx-a11y/anchor-is-valid': 'off',
},
overrides: [
...baseline.overrides.filter(
(ruleSet) =>
!ruleSet.rules.hasOwnProperty('filenames/match-exported') &&
!ruleSet.extends?.includes('plugin:mocha/recommended'),
),
{
files: [
// matching the pattern of the test runner
'*.test.?(c|m)[jt]s?(x)',
],
rules: {
// disable eslint-plugin-jsx-a11y
// tests are not driven by assistive technology
// add `jsx-a11y` rules once you encounter them in tests
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/control-has-associated-label': 'off',
'jsx-a11y/iframe-has-title': 'off',
'jsx-a11y/label-has-associated-control': 'off',
'jsx-a11y/mouse-events-have-key-events': 'off',
'jsx-a11y/no-noninteractive-tabindex': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/tabindex-no-positive': 'off',
// In tests this is generally intended.
'react/button-has-type': 'off',
// They are accessed to test custom validator implementation with PropTypes.checkPropTypes
'react/forbid-foreign-prop-types': 'off',
// components that are defined in test are isolated enough
// that they don't need type-checking
'react/prop-types': 'off',
'react/no-unused-prop-types': 'off',
},
},
{
files: ['docs/src/app/(private)/experiments/**/*{.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: ['test/**/*{.ts,.tsx}'],
rules: {
'react/prop-types': 'off',
'guard-for-in': 'off',
},
},
],
};