-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.ts&react.js
93 lines (89 loc) · 2.75 KB
/
.eslintrc.ts&react.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
/**
* .eslintrc.js
* @author gya747
* @description
* @date 2020-06-16T15:17:41.905Z+08:00
* @lastModifier gya747
* @lastModified 2020-06-16T15:17:41.905Z+08:00
* @NOTES 安装以下依赖
1. @typescript-eslint/parser
2. @typescript-eslint/eslint-plugin
3. react-hooks
* @TODOS
*/
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
extends: [
// "airbnb-typescript",
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
// @gya-todos:为什么一加入下面两项,eslint检查就无法响应了,好像卡死了一样
"plugin:react/recommended",
"plugin:react-hooks/recommended",
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
plugins: [
'@typescript-eslint',
'react',
"react-hooks"
],
env: {
browser: true,
// node: true,
es6: true,
// mocha: true,
// jest: true,
// jasmine: true,
},
globals: {
},
rules: {
// 'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
// 'react/jsx-wrap-multilines': 0,
// 'react/prop-types': 0,
// 'react/forbid-prop-types': 0,
// 'react/jsx-one-expression-per-line': 0,
// // react无状态的纯函数:从Error改为Warning
// 'react/prefer-stateless-function': 1,
// 'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }],
// 'import/no-extraneous-dependencies': [
// 2,
// {
// optionalDependencies: true,
// devDependencies: ['**/tests/**.js', '/mock/**.js', '**/**.test.js'],
// },
// ],
// 'jsx-a11y/no-noninteractive-element-interactions': 0,
// 'jsx-a11y/click-events-have-key-events': 0,
// 'jsx-a11y/no-static-element-interactions': 0,
// 'jsx-a11y/anchor-is-valid': 0,
// 'linebreak-style': 0,
// "import/no-extraneous-dependencies": ["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}],
// "react-hooks/rules-of-hooks": "error",
// "react-hooks/exhaustive-deps": "error"
// note you must disable the base rule as it can report incorrect errors
// "no-unused-vars": "off",
// "@typescript-eslint/no-unused-vars": ["error", {
// "vars": "all",
// "args": "after-used",
// "ignoreRestSiblings": false
// }],
'@typescript-eslint/no-array-constructor': 'warn',
// disable the rule for all files
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"overrides": [
{
// enable the rule specifically for TypeScript files
// disable the rule for tsx because tsx exports React Component
"files": ["*.ts"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": ["warn"]
}
}
]
};