-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc
111 lines (111 loc) · 4.25 KB
/
.eslintrc
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
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "detect",
"flowVersion": "0.53"
},
"propWrapperFunctions": [
"forbidExtraProps",
{
"property": "freeze",
"object": "Object"
},
{
"property": "myFavoriteWrapper"
}
],
"linkComponents": [
"Hyperlink",
{
"name": "Link",
"linkAttribute": "to"
}
]
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true,
"arrowFunctions": true,
"classes": true,
"modules": true,
"defaultParams": true
}
},
"plugins": [
"@typescript-eslint",
"react",
"react-hooks"
],
"rules": {
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/jsx-indent": [2, 2],
"react/jsx-indent-props": [2, 2],
"quotes": [2, "single"], // 单引号
"no-debugger": 2, // 禁用debugger
"no-var": 2, // 对var报错
"no-class-assign": 2, // 禁止给类赋值
"no-cond-assign": 2, // 禁止在条件表达式中使用赋值语句
"no-const-assign": 2, // 禁止修改const声明的变量
"no-delete-var": 2, // 不能对var声明的变量使用delete操作符
"no-dupe-keys": 2, // 在创建对象字面量时不允许键重复
"no-duplicate-case": 2, // switch中的case标签不能重复
"no-dupe-args": 2, // 函数参数不能重复
"no-empty": 2, // 块语句中的内容不能为空
"no-func-assign": 2, // 禁止重复的函数声明
"no-invalid-this": 0, // 禁止无效的this,只能用在构造器,类,对象字面量
"no-redeclare": 2, // 禁止重复声明变量
"no-spaced-func": 2, // 函数调用时 函数名与()之间不能有空格
"no-use-before-define": 2, // 未定义前不能使用
"camelcase": 2, // 强制驼峰法命名
"jsx-quotes": [2, "prefer-double"], // 强制在JSX属性(jsx-quotes)中一致使用双引号
"react/forbid-prop-types": [2, {"forbid": ["any"]}], // 禁止某些propTypes
"react/jsx-boolean-value": 2, // 在JSX中强制布尔属性符号
"react/jsx-closing-bracket-location": 2, // 在JSX中验证右括号位置
"react/jsx-curly-spacing": [2, {"when": "never", "children": true}], // 在JSX属性和表达式中加强或禁止大括号内的空格。
"react/jsx-key": 2, // 在数组或迭代器中验证JSX具有key属性
"react/jsx-no-duplicate-props": 2, // 防止在JSX中重复的props
"react/jsx-no-undef": 2, // 在JSX中禁止未声明的变量
"react/no-direct-mutation-state": 2, // 防止this.state的直接变异
"react/no-multi-comp": 2, // 防止每个文件有多个组件定义
"react/no-unknown-property": 2, // 防止使用未知的DOM属性
"react/prefer-es6-class": 2, // 为React组件强制执行ES5或ES6类
"react/react-in-jsx-scope": 2, // 使用JSX时防止丢失React
"react/sort-comp": 2, // 强制组件方法顺序
"react/no-deprecated": 2, // 不使用弃用的方法
"react/jsx-equals-spacing": 2, // 在JSX属性中强制或禁止等号周围的空格
"comma-dangle": 2, // 对象字面量项尾不能有逗号
"prefer-arrow-callback": 2, // 比较喜欢箭头回调
"arrow-spacing": 2, // =>的前/后括号
"space-infix-ops": 2, // 操作符周围的必须有空格
"key-spacing": 2, // :周围必须有空格
"spaced-comment": 2, // 注释后必须有空格
"comma-spacing": 2, // 逗号后面必须有空格
"object-curly-spacing": [2, "always"], // 对象括号开始于结束之间要有空格
"eqeqeq": 2, // 必须用===
"react-hooks/rules-of-hooks": "error", // 检查 Hook 的规则
"react-hooks/exhaustive-deps": "warn", // 检查 effect 的依赖
"@typescript-eslint/no-empty-function": 0,
"react/prop-types": 0 // 关闭prop-types的类型检测,因为已经有typeScript了
}
}