-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy patheslint.config.mjs
150 lines (149 loc) · 5.32 KB
/
eslint.config.mjs
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
import js from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import tseslint from 'typescript-eslint';
import cypress from 'eslint-plugin-cypress';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
export default defineConfig([
globalIgnores([
'**/node_modules',
'**/build',
'**/lib',
'**/esm',
'**/prism.js',
'packages/create-react-admin/templates/**/*',
]),
{
name: 'eslint-js-recommended-rules',
plugins: {
js,
},
extends: ['js/recommended'],
},
tseslint.configs.recommended.map(conf => ({
...conf,
files: ['**/*.ts', '**/*.tsx'],
})),
{
...jsxA11y.flatConfigs.recommended,
ignores: ['**/*.spec.*', '**/*.stories.*'],
},
eslintPluginPrettierRecommended,
{
name: 'react',
...react.configs.flat.recommended,
},
reactHooks.configs['recommended-latest'],
{
name: 'react-admin-rules',
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
'no-use-before-define': 'off',
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@mui/material',
importNames: ['makeStyles', 'createMuiTheme'],
message:
'Please import from @mui/material/styles instead. See https://material-ui.com/guides/minimizing-bundle-size/#option-2 for more information',
},
{
name: '@mui/icons-material',
message:
"Named import from @mui/icons-material should be avoided for performance reasons. Use a default import instead. E.g. `import Dashboard from '@mui/icons-material/Dashboard';` instead of `import { Dashboard } from '@mui/icons-material';`.See https://mui.com/material-ui/guides/minimizing-bundle-size/#development-environment for more information.",
},
{
name: 'lodash',
message:
"Named import from lodash should be avoided for performance reasons. Use a default import instead. E.g. `import merge from 'lodash/merge';` instead of `import { merge } from 'lodash';`.",
},
],
},
],
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
caughtErrors: 'none',
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/prefer-as-const': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
enforceForJSX: false,
},
],
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-function-types': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-unnecessary-type-constraints': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-empty-object-types': 'off',
'react/prop-types': 'off',
'react/display-name': 'off',
'react/jsx-key': 'off',
'react/no-unescaped-entities': 'off',
'react/no-children-prop': 'off',
'react/no-children-props': 'off',
'react/react-in-jsx-scope': 'off',
eqeqeq: ['warn', 'smart'],
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
'prefer-spread': 'off',
'jsx-a11y/no-autofocus': 'off',
},
settings: {
react: {
version: 'detect',
},
},
},
{
name: 'test-rules',
files: ['**/*.spec.*'],
languageOptions: {
globals: {
...globals.jest,
},
},
rules: {
'react-hooks/rules-of-hooks': 'off',
},
},
{
name: 'cypress-rules',
files: ['cypress/**/*'],
plugins: {
cypress,
},
languageOptions: {
globals: {
...cypress.environments.globals.globals,
},
},
},
]);