-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eslintrc.json
More file actions
87 lines (87 loc) · 3.09 KB
/
.eslintrc.json
File metadata and controls
87 lines (87 loc) · 3.09 KB
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
{
"env": {
"browser": true,
"es2020": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
"airbnb"
],
"parser": "@typescript-eslint/parser", // ESLint解析器,它利用TypeScript ESTree允许ESLint整理TypeScript源代码
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true, // 启用实验室特性
"jsx": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint", // 为TypeScript代码库提供lint规则
"react-hooks", // 为react hooks提供规则
"jsx-a11y" // 静态AST检查器,用于JSX元素上的可访问性规则。
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off", // 返回值不需要定义类型
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off",
"block-scoped-var": "error", // 强制把变量的使用限制在其定义的作用域范围内
"no-shadow": "error", // 禁止变量声明与外层作用域的变量同名
"import/no-anonymous-default-export": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": ["off"], // 关闭any类型时的警告
"indent": ["off", 4],
"quotes": [1, "single"], // 字符串总为一个单引号包裹
"semi": [
0
],
"@typescript-eslint/indent": ["error", 4], // 控制缩进为两个空格
"@typescript-eslint/explicit-function-return-type": "off", // 返回类型
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"import/no-unresolved": [1, { "ignore": ["^@"] }],
"react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx", "ts", "tsx"] }],
"import/no-cycle": "off",
"prefer-object-spread": "off",
"max-len": "off",
"no-console": "off",
"import/no-named-as-default": "off",
"import/prefer-default-export": "off",
"prettier/prettier": "off",
"react/jsx-indent": ["error", 4],
"react/jsx-indent-props": ["error", 4],
"import/no-extraneous-dependencies": "off",
"import/no-named-as-default-member": "off",
"import/no-self-import": "off",
"import/order": "off",
"import/no-duplicates": "off",
"import/named": "off"
},
"settings": {
"react": {
"version": "detect" // 自动选择您安装的版本
},
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
},
"typescript": {
"directory": "./tsconfig.json"
}
}
}
}