-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.js
105 lines (104 loc) · 3.03 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
/*
* @Author: [email protected]
* @Date: 2019-09-29 14:16:33
* @LastEditors : Please set LastEditors
* @LastEditTime : 2020-02-10 12:37:58
*/
module.exports = {
env: {
//指定代码的运行环境
browser: true,
es6: true,
node: true,
},
extends: [
'airbnb',
'plugin:@typescript-eslint/recommended', //使用@typescript-eslint/recommended推荐的规则
'react-app',
'prettier/react',
'plugin:import/typescript',
'prettier/@typescript-eslint', // 使用 eslint-config-prettier 禁用 @typescript-eslint/eslint-plugin 中与prettier中冲突的规则
'plugin:prettier/recommended', // 必须在配置文件的extends 的最后一行。启用eslint-plugin-prettier,并且把prettier的错误提示展示为Eslint错误
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
settings: {
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
//自动发现React的版本,从而进行规范react代码
react: {
pragma: 'React',
version: 'detect',
},
},
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-angle-bracket-type-assertion': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: false },
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'as' },
],
'react/jsx-wrap-multilines': [
'error',
{ declaration: false, assignment: false, arrow: true, return: true },
],
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'no-param-reassign': [2, { props: false }],
'dot-notation': [2, { allowKeywords: false, allowPattern: '' }],
'import/prefer-default-export': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-props-no-spreading': 'off',
'react-hooks/rules-of-hooks': 'error', // 检查 Hook 的规则
'react-hooks/exhaustive-deps': 'warn', // 检查 effect 的依赖
'react/jsx-filename-extension': [
1,
{ extensions: ['.js', '.jsx', '.ts', '.tsx'] },
],
'no-plusplus': 0,
'no-console': 0,
'comma-dangle': [
'error',
{
arrays: 'only-multiline',
objects: 'only-multiline',
imports: 'only-multiline',
exports: 'only-multiline',
functions: 'only-multiline',
},
],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
},
};