-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
156 lines (154 loc) · 5.24 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
const baseline = require('@mui/monorepo/.eslintrc');
const path = require('path');
const buildPackageRestrictedImports = (packageName, root) => ({
files: [`packages/${root}/src/**/*{.ts,.tsx,.js}`],
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx', '**.test.tx', '**.test.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: packageName,
message: 'Use relative import instead',
},
{
name: '@mui/material',
message: 'Use @mui/utils or a more specific import instead',
},
],
patterns: [
// TODO move rule into main repo to allow deep @mui/monorepo imports
{
group: ['@mui/*/*/*'],
message: 'Use less deep import instead',
},
{
group: [`${packageName}/*`, `${packageName}/**`],
message: 'Use relative import instead',
},
],
},
],
},
});
module.exports = {
...baseline,
plugins: [...baseline.plugins, 'eslint-plugin-jsdoc'],
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,
'import/prefer-default-export': 'off',
// TODO move rule into the main repo once it has upgraded
'@typescript-eslint/return-await': 'off',
'no-restricted-imports': 'off',
'jsdoc/require-param': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/require-param-type': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/require-param-name': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/require-param-description': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/require-returns': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/require-returns-type': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/require-returns-description': ['error', { contexts: ['TSFunctionType'] }],
'jsdoc/no-bad-blocks': [
'error',
{
ignore: [
'ts-check',
'ts-expect-error',
'ts-ignore',
'ts-nocheck',
'typescript-to-proptypes-ignore',
],
},
],
// Fixes false positive when using both `inputProps` and `InputProps` on the same example
// See https://stackoverflow.com/questions/42367236/why-am-i-getting-this-warning-no-duplicate-props-allowed-react-jsx-no-duplicate
'react/jsx-no-duplicate-props': [1, { ignoreCase: false }],
'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
},
overrides: [
...baseline.overrides,
{
files: [
// matching the pattern of the test runner
'*.test.js',
'*.test.ts',
'*.test.tsx',
'test/**',
],
rules: {
'no-restricted-imports': [
'error',
{
paths: ['@testing-library/react', 'test/utils/index'],
},
],
},
},
{
files: ['packages/grid/**/*.ts', 'packages/grid/**/*.js', 'docs/src/pages/**/*.tsx'],
excludedFiles: [
'packages/grid/x-data-grid/src/themeAugmentation/index.js', // TypeScript ignores JS files with the same name as the TS file
'packages/grid/x-data-grid-pro/src/themeAugmentation/index.js',
'packages/grid/x-data-grid-premium/src/themeAugmentation/index.js',
],
rules: {
'material-ui/no-direct-state-access': 'error',
},
parserOptions: { tsconfigRootDir: __dirname, project: ['./tsconfig.json'] },
},
{
files: ['*.tsx'],
excludedFiles: '*.spec.tsx',
rules: {
'react/prop-types': 'off',
},
},
{
files: ['docs/data/**/*.js', 'docs/data/**/*.tsx'],
rules: {
'filenames/match-exported': ['error'],
},
},
{
files: ['packages/*/src/**/*{.ts,.tsx,.js}'],
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx'],
rules: {
'material-ui/mui-name-matches-component-name': [
'error',
{
customHooks: [
'useDatePickerProcessedProps',
'useDatePickerDefaultizedProps',
'useTimePickerDefaultizedProps',
'useDateTimePickerDefaultizedProps',
'useDateRangePickerDefaultizedProps',
'useDateCalendarDefaultizedProps',
'useMonthCalendarDefaultizedProps',
'useYearCalendarDefaultizedProps',
'useDateRangeCalendarDefaultizedProps',
],
},
],
},
},
buildPackageRestrictedImports('@mui/x-charts', 'x-charts'),
buildPackageRestrictedImports('@mui/x-data-grid', 'grid/x-data-grid'),
buildPackageRestrictedImports('@mui/x-data-grid-pro', 'grid/x-data-grid-pro'),
buildPackageRestrictedImports('@mui/x-data-grid-premium', 'grid/x-data-grid-premium'),
buildPackageRestrictedImports('@mui/x-data-grid-generator', 'grid/x-data-grid-generator'),
buildPackageRestrictedImports('@mui/x-pickers', 'x-pickers'),
buildPackageRestrictedImports('@mui/x-pickers-pro', 'x-pickers-pro'),
buildPackageRestrictedImports('@mui/x-license-pro', 'x-license-pro'),
],
};