-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.js
101 lines (98 loc) · 2.93 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
// yarn add eslint eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-jsx-control-statements babel-eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser husky lint-staged prettier -D
/*
// .prettierrc.js
module.exports = {
printWidth: 120,
tabWidth: 2,
singleQuote: false,
semi: true,
trailingComma: 'es5',
bracketSpacing: true,
jsxBracketSameLine: true,
arrowParens: 'always',
parser: 'typescript'
};
// package.json
"scripts": {
"eslint": "eslint --ext .tsx,.ts --fix ./src",
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"npm run eslint",
"prettier .prettierrc.js --write",
"git add"
]
},
*/
// .eslintrc.js
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
extends: [
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:react/recommended",
"plugin:jsx-control-statements/recommended",
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
"plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
"prettier/react",
],
settings: {
react: {
version: "detect",
},
},
plugins: [
"@typescript-eslint",
"react",
"jsx-control-statements",
"prettier",
],
env: {
browser: true,
node: true,
es6: true,
mocha: true,
"jsx-control-statements/jsx-control-statements": true,
},
globals: {
$: true,
},
rules: {
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-module-boundary-types": "off",
"prettier/prettier": 1,
"no-console": ["warn", { allow: ["warn", "error"] }],
eqeqeq: ["warn", "always"],
"prefer-const": [
"error",
{ destructuring: "all", ignoreReadBeforeAssign: true },
],
"@typescript-eslint/indent": [
"error",
2,
{ VariableDeclarator: 4, SwitchCase: 1 },
],
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/no-triple-slash-reference": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/no-this-alias": 0,
"@typescript-eslint/triple-slash-reference": [
"error",
{ path: "always", types: "never", lib: "never" },
],
// React相关校验规则
"react/jsx-indent": [2, 4],
"react/jsx-no-undef": [2, { allowGlobals: true }],
"jsx-control-statements/jsx-use-if-tag": 0,
},
};