forked from bytedance/guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
72 lines (72 loc) · 1.63 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
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parserOptions: {
ecmaFeatures: {
legacyDecorators: true,
},
},
plugins: [
'@typescript-eslint',
'babel',
'react',
'promise',
'standard',
'react-hooks',
'prettier',
],
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
rules: {
// 检查 Hook 的规则
'react-hooks/rules-of-hooks': 'error',
// jsx里import的react未被使用则报错
'react/jsx-uses-react': 'error',
// jsx里import的组件未被使用则报错
'react/jsx-uses-vars': 'error',
// 允许require
'@typescript-eslint/no-var-requires': 'off',
// 函数必须有返回值,数组的map、some等除外
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
'no-unused-vars': 'off',
// 已声明的变量未被使用则报错
'@typescript-eslint/no-unused-vars': 'error',
// interface定义的接口以I开头,增强可读性
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
],
// 不允许有console,error和warn除外
'no-console': [
'off',
{
allow: ['warn', 'error'],
},
],
'@typescript-eslint/no-empty-function': 'off',
// 驼峰
camelcase: [
'error',
{
allow: ['^UNSAFE_'],
},
],
},
};