-
Notifications
You must be signed in to change notification settings - Fork 9
/
.eslintrc.js
148 lines (148 loc) · 4.04 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
module.exports = {
env: {
browser: true,
es2021: true,
jest: true,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['node_modules', 'packages/', 'test/'],
},
typescript: {},
},
},
extends: [
'airbnb',
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:markdown/recommended',
],
overrides: [
{
files: ['**/*.test.{ts,tsx}', '**/demo/*'],
rules: {
'import/no-extraneous-dependencies': 0,
},
},
{
files: ['**/*.types.ts'],
rules: {
'@typescript-eslint/ban-types': 0,
},
},
// .md文档使用markdown处理器
{
files: ['**/*.md'],
processor: 'markdown/markdown',
},
// 每个markdown文档中的代码块都有个虚拟文件名,针对[```tsx,```ts,```jsx,```js]代码块配置校验规则
{
files: ['**/*.md/*.tsx', '**/*.md/*.ts', '**/*.md/*.jsx', '**/*.md/*.js'],
rules: {
'import/newline-after-import': 0,
'react/react-in-jsx-scope': 0,
'react/display-name': 0,
'no-console': 0,
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'react',
'react-hooks',
'import',
'@typescript-eslint',
'prettier',
'markdown',
],
rules: {
'import/extensions': 0,
'prettier/prettier': 2,
'no-use-before-define': [
'warn',
{ functions: false, classes: true, variables: true },
],
'no-shadow': 'error',
'no-redeclare': 'error',
'no-multi-assign': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
eqeqeq: ['warn', 'always', { null: 'ignore' }],
'no-var': 'warn',
'no-undef': 'warn',
'no-inner-declarations': 'warn',
'default-param-last': 'warn',
'no-param-reassign': [
'warn',
{
props: true,
ignorePropertyModificationsFor: [
'acc', // for reduce accumulators
'e', // for e.returnvalue
'ctx', // for Koa routing
'draft', // for immer
'req', // for Express requests
'request', // for Express requests
'res', // for Express responses
'response', // for Express responses
'$scope', // for Angular 1 scopes
],
},
],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'scripts/**',
'**/*.test.js',
'**/__tests__/*',
'*.config.js',
'**/*.config.js',
'**/*.md',
'**/builder.js',
],
},
],
'no-setter-return': 'warn',
'guard-for-in': 'warn',
'no-eval': 'warn',
'no-debugger': 'warn',
'valid-typeof': ['warn', { requireStringLiterals: true }],
'import/no-cycle': ['warn', { maxDepth: Infinity }],
'no-extra-boolean-cast': 'warn',
'no-unused-vars': [2, { vars: 'all', args: 'none' }],
// 'no-unused-vars': 'warn',
'react/jsx-no-undef': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-uses-react': 'error',
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
'react/no-this-in-sfc': 'error',
'react/require-render-return': 'warn',
'react/no-children-prop': 'warn',
'react/jsx-filename-extension': [
'warn',
{ extensions: ['.jsx', '.js', '.tsx', '.ts', '.vue'] },
],
'react-hooks/rules-of-hooks': 'error',
'no-restricted-exports': 0,
// **********
'react/function-component-definition': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/label-has-associated-control': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'react/jsx-props-no-spreading': 0,
'react/no-array-index-key': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-var-requires': 0,
},
};