-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
94 lines (91 loc) · 2.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
const OFF = 0;
const ERROR = 2;
module.exports = {
root: true,
extends: [
'airbnb',
'plugin:prettier/recommended',
],
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 10,
sourceType: 'module',
},
plugins: [
'react',
],
env: {
browser: true,
node: true,
},
rules: {
'global-require': OFF,
'import/prefer-default-export': 'off',
'no-param-reassign': 'off',
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, { args: 'none' }],
'no-restricted-syntax': OFF,
'no-use-before-define': [ERROR, { functions: false, variables: false }],
'import/no-extraneous-dependencies': [
'error',
{
'devDependencies': [
'build/**',
'test/**',
],
'optionalDependencies': false,
'peerDependencies': false,
}
],
'no-useless-concat': OFF,
'no-var': ERROR,
'jsx-quotes': [ERROR, 'prefer-double'],
'space-before-blocks': ERROR,
'space-before-function-paren': OFF,
'quotes': [
ERROR,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
}
],
'react/jsx-indent': [ERROR, 2],
'react/jsx-filename-extension': [
OFF,
{
extensions: ['.js', '.jsx'],
}
],
'import/no-unresolved': OFF,
'import/extensions': [
'.js',
'.jsx',
'.ts',
'.tsx',
'.json',
],
"prettier/prettier": [
"error",
// 针对会被 ESLint 格式化的文件类型,Prettier 会作为 ESLint 的一个规则运行并格式化文件,因此需要添加如下配置
{
// 行末分号
semi: true,
// 单引号
singleQuote: true,
// 缩进
tabWidth: 2,
// 使用tab还是空格
useTabs: false,
// 行宽
printWidth: 120,
// JSX break
jsxBracketSameLine: false,
// 指定 html 全局空白
htmlWhitespaceSensitivity: 'strict',
// 换行符
endOfLine: 'lf',
}
]
},
}