@houheaven/eslint-config-helper 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/eslint/eslint-fix.js +29 -0
- package/eslint/file-bof-eof.js +22 -0
- package/eslint/index.js +18 -0
- package/eslint/legacy.js +34 -0
- package/eslint/prettier.js +414 -0
- package/eslint/rules/best-practices.js +422 -0
- package/eslint/rules/es6.js +197 -0
- package/eslint/rules/imports.js +279 -0
- package/eslint/rules/node.js +48 -0
- package/eslint/rules/possible-errors.js +185 -0
- package/eslint/rules/strict-mode.js +12 -0
- package/eslint/rules/stylistic-issues.js +573 -0
- package/eslint/rules/variables.js +71 -0
- package/eslint/rules/vue.js +23 -0
- package/package.json +28 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
env: {
|
|
4
|
+
es6: true,
|
|
5
|
+
},
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaVersion: 6,
|
|
8
|
+
sourceType: "module",
|
|
9
|
+
},
|
|
10
|
+
plugins: [
|
|
11
|
+
"import"
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
settings: {
|
|
15
|
+
"import/resolver": {
|
|
16
|
+
node: {
|
|
17
|
+
extensions: [".mjs", ".js", ".json"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
"import/extensions": [
|
|
21
|
+
".js",
|
|
22
|
+
".mjs",
|
|
23
|
+
".jsx"
|
|
24
|
+
],
|
|
25
|
+
"import/core-modules": [
|
|
26
|
+
],
|
|
27
|
+
"import/ignore": [
|
|
28
|
+
"node_modules",
|
|
29
|
+
"\\.(coffee|scss|css|less|hbs|svg|json)$"
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
rules: {
|
|
34
|
+
// Static analysis:
|
|
35
|
+
|
|
36
|
+
// ensure imports point to files/modules that can be resolved
|
|
37
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
|
|
38
|
+
// 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
|
|
39
|
+
"import/no-unresolved": "off",
|
|
40
|
+
|
|
41
|
+
// ensure named imports coupled with named exports
|
|
42
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
|
|
43
|
+
"import/named": "error",
|
|
44
|
+
|
|
45
|
+
// ensure default import coupled with default export
|
|
46
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
|
|
47
|
+
"import/default": "off",
|
|
48
|
+
|
|
49
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
|
|
50
|
+
"import/namespace": "off",
|
|
51
|
+
|
|
52
|
+
// Helpful warnings:
|
|
53
|
+
|
|
54
|
+
// disallow invalid exports, e.g. multiple defaults
|
|
55
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
|
|
56
|
+
"import/export": "error",
|
|
57
|
+
|
|
58
|
+
// do not allow a default import name to match a named export
|
|
59
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
|
|
60
|
+
"import/no-named-as-default": "error",
|
|
61
|
+
|
|
62
|
+
// warn on accessing default export property names that are also named exports
|
|
63
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
|
|
64
|
+
"import/no-named-as-default-member": "error",
|
|
65
|
+
|
|
66
|
+
// disallow use of jsdoc-marked-deprecated imports
|
|
67
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
|
|
68
|
+
"import/no-deprecated": "off",
|
|
69
|
+
|
|
70
|
+
// Forbid the use of extraneous packages
|
|
71
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
72
|
+
// paths are treated both as absolute paths, and relative to process.cwd()
|
|
73
|
+
"import/no-extraneous-dependencies": ["error", {
|
|
74
|
+
devDependencies: [
|
|
75
|
+
"test/**", // tape, common npm pattern
|
|
76
|
+
"tests/**", // also common npm pattern
|
|
77
|
+
"spec/**", // mocha, rspec-like pattern
|
|
78
|
+
"**/__tests__/**", // jest pattern
|
|
79
|
+
"**/__mocks__/**", // jest pattern
|
|
80
|
+
"test.{js,jsx}", // repos with a single test file
|
|
81
|
+
"test-*.{js,jsx}", // repos with multiple top-level test files
|
|
82
|
+
"**/*{.,_}{test,spec}.{js,jsx}", // tests where the extension or filename suffix denotes that it is a test
|
|
83
|
+
"**/jest.config.js", // jest config
|
|
84
|
+
"**/jest.setup.js", // jest setup
|
|
85
|
+
"**/vue.config.js", // vue-cli config
|
|
86
|
+
"**/webpack.config.js", // webpack config
|
|
87
|
+
"**/webpack.config.*.js", // webpack config
|
|
88
|
+
"**/rollup.config.js", // rollup config
|
|
89
|
+
"**/rollup.config.*.js", // rollup config
|
|
90
|
+
"**/gulpfile.js", // gulp config
|
|
91
|
+
"**/gulpfile.*.js", // gulp config
|
|
92
|
+
"**/Gruntfile{,.js}", // grunt config
|
|
93
|
+
"**/protractor.conf.js", // protractor config
|
|
94
|
+
"**/protractor.conf.*.js", // protractor config
|
|
95
|
+
"**/karma.conf.js", // karma config
|
|
96
|
+
"**/.eslintrc.js" // eslint config
|
|
97
|
+
],
|
|
98
|
+
optionalDependencies: false,
|
|
99
|
+
}],
|
|
100
|
+
|
|
101
|
+
// Forbid mutable exports
|
|
102
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
|
|
103
|
+
"import/no-mutable-exports": "error",
|
|
104
|
+
|
|
105
|
+
// Module systems:
|
|
106
|
+
|
|
107
|
+
// disallow require()
|
|
108
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
|
|
109
|
+
"import/no-commonjs": "off",
|
|
110
|
+
|
|
111
|
+
// disallow AMD require/define
|
|
112
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
|
|
113
|
+
"import/no-amd": "error",
|
|
114
|
+
|
|
115
|
+
// No Node.js builtin modules
|
|
116
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
|
|
117
|
+
// TODO: enable?
|
|
118
|
+
"import/no-nodejs-modules": "off",
|
|
119
|
+
|
|
120
|
+
// Style guide:
|
|
121
|
+
|
|
122
|
+
// disallow non-import statements appearing before import statements
|
|
123
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
|
|
124
|
+
"import/first": "error",
|
|
125
|
+
|
|
126
|
+
// disallow non-import statements appearing before import statements
|
|
127
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
|
|
128
|
+
// deprecated: use `import/first`
|
|
129
|
+
"import/imports-first": "off",
|
|
130
|
+
|
|
131
|
+
// disallow duplicate imports
|
|
132
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
|
|
133
|
+
"import/no-duplicates": "error",
|
|
134
|
+
|
|
135
|
+
// disallow namespace imports
|
|
136
|
+
// TODO: enable?
|
|
137
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
|
|
138
|
+
"import/no-namespace": "off",
|
|
139
|
+
|
|
140
|
+
// 文件后缀名
|
|
141
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
|
|
142
|
+
"import/extensions": "off",
|
|
143
|
+
// 'import/extensions': ['error', 'ignorePackages', {
|
|
144
|
+
// js: 'never',
|
|
145
|
+
// mjs: 'never',
|
|
146
|
+
// jsx: 'never',
|
|
147
|
+
// }],
|
|
148
|
+
|
|
149
|
+
// ensure absolute imports are above relative imports and that unassigned imports are ignored
|
|
150
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
|
|
151
|
+
// TODO: enforce a stricter convention in module import order?
|
|
152
|
+
"import/order": ["error", { groups: [["builtin", "external", "internal"]]}],
|
|
153
|
+
|
|
154
|
+
// import 之后需要换行
|
|
155
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
|
|
156
|
+
"import/newline-after-import": "off",
|
|
157
|
+
// 'import/newline-after-import': 'error',
|
|
158
|
+
|
|
159
|
+
// Require modules with a single export to use a default export
|
|
160
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
|
|
161
|
+
"import/prefer-default-export": "error",
|
|
162
|
+
|
|
163
|
+
// Restrict which files can be imported in a given folder
|
|
164
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
|
|
165
|
+
"import/no-restricted-paths": "off",
|
|
166
|
+
|
|
167
|
+
// Forbid modules to have too many dependencies
|
|
168
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
|
|
169
|
+
"import/max-dependencies": ["off", { max: 10 }],
|
|
170
|
+
|
|
171
|
+
// Forbid import of modules using absolute paths
|
|
172
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
|
|
173
|
+
"import/no-absolute-path": "error",
|
|
174
|
+
|
|
175
|
+
// 动态加载
|
|
176
|
+
// Forbid require() calls with expressions
|
|
177
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
|
|
178
|
+
// 'import/no-dynamic-require': 'error',
|
|
179
|
+
"import/no-dynamic-require": "off",
|
|
180
|
+
|
|
181
|
+
// prevent importing the submodules of other modules
|
|
182
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
|
|
183
|
+
"import/no-internal-modules": ["off", {
|
|
184
|
+
allow: [],
|
|
185
|
+
}],
|
|
186
|
+
|
|
187
|
+
// Warn if a module could be mistakenly parsed as a script by a consumer
|
|
188
|
+
// leveraging Unambiguous JavaScript Grammar
|
|
189
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
|
|
190
|
+
// this should not be enabled until this proposal has at least been *presented* to TC39.
|
|
191
|
+
// At the moment, it's not a thing.
|
|
192
|
+
"import/unambiguous": "off",
|
|
193
|
+
|
|
194
|
+
// Forbid Webpack loader syntax in imports
|
|
195
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
|
|
196
|
+
"import/no-webpack-loader-syntax": "error",
|
|
197
|
+
|
|
198
|
+
// Prevent unassigned imports
|
|
199
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
|
|
200
|
+
// importing for side effects is perfectly acceptable, if you need side effects.
|
|
201
|
+
"import/no-unassigned-import": "off",
|
|
202
|
+
|
|
203
|
+
// Prevent importing the default as if it were named
|
|
204
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
|
|
205
|
+
"import/no-named-default": "error",
|
|
206
|
+
|
|
207
|
+
// Reports if a module's default export is unnamed
|
|
208
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
|
|
209
|
+
"import/no-anonymous-default-export": ["off", {
|
|
210
|
+
allowArray: false,
|
|
211
|
+
allowArrowFunction: false,
|
|
212
|
+
allowAnonymousClass: false,
|
|
213
|
+
allowAnonymousFunction: false,
|
|
214
|
+
allowLiteral: false,
|
|
215
|
+
allowObject: false,
|
|
216
|
+
}],
|
|
217
|
+
|
|
218
|
+
// This rule enforces that all exports are declared at the bottom of the file.
|
|
219
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
|
|
220
|
+
// TODO: enable?
|
|
221
|
+
"import/exports-last": "off",
|
|
222
|
+
|
|
223
|
+
// Reports when named exports are not grouped together in a single export declaration
|
|
224
|
+
// or when multiple assignments to CommonJS module.exports or exports object are present
|
|
225
|
+
// in a single file.
|
|
226
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
|
|
227
|
+
"import/group-exports": "off",
|
|
228
|
+
|
|
229
|
+
// forbid default exports. this is a terrible rule, do not use it.
|
|
230
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
|
|
231
|
+
"import/no-default-export": "off",
|
|
232
|
+
|
|
233
|
+
// Prohibit named exports. this is a terrible rule, do not use it.
|
|
234
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
|
|
235
|
+
"import/no-named-export": "off",
|
|
236
|
+
|
|
237
|
+
// Forbid a module from importing itself
|
|
238
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
|
|
239
|
+
"import/no-self-import": "error",
|
|
240
|
+
|
|
241
|
+
// Forbid cyclical dependencies between modules
|
|
242
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
|
|
243
|
+
"import/no-cycle": ["error", { maxDepth: "∞" }],
|
|
244
|
+
|
|
245
|
+
// Ensures that there are no useless path segments
|
|
246
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
|
|
247
|
+
"import/no-useless-path-segments": ["error", { commonjs: true }],
|
|
248
|
+
|
|
249
|
+
// dynamic imports require a leading comment with a webpackChunkName
|
|
250
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
|
|
251
|
+
"import/dynamic-import-chunkname": ["off", {
|
|
252
|
+
importFunctions: [],
|
|
253
|
+
webpackChunknameFormat: "[0-9a-zA-Z-_/.]+",
|
|
254
|
+
}],
|
|
255
|
+
|
|
256
|
+
// Use this rule to prevent imports to folders in relative parent paths.
|
|
257
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
|
|
258
|
+
"import/no-relative-parent-imports": "off",
|
|
259
|
+
|
|
260
|
+
// Reports modules without any exports, or with unused exports
|
|
261
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
|
|
262
|
+
// TODO: enable once it supports CJS
|
|
263
|
+
"import/no-unused-modules": ["off", {
|
|
264
|
+
ignoreExports: [],
|
|
265
|
+
missingExports: true,
|
|
266
|
+
unusedExports: true,
|
|
267
|
+
}],
|
|
268
|
+
|
|
269
|
+
// Reports the use of import declarations with CommonJS exports in any module except for the main module.
|
|
270
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
|
|
271
|
+
"import/no-import-module-exports": ["error", {
|
|
272
|
+
exceptions: [],
|
|
273
|
+
}],
|
|
274
|
+
|
|
275
|
+
// Use this rule to prevent importing packages through relative paths.
|
|
276
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
|
|
277
|
+
"import/no-relative-packages": "error",
|
|
278
|
+
},
|
|
279
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// Node.js and CommonJS
|
|
4
|
+
// 这些规则是关于Node.js 或 在浏览器中使用CommonJS 的
|
|
5
|
+
// ==========================================================
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
env: {
|
|
9
|
+
node: true,
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
// enforce return after a callback
|
|
13
|
+
"callback-return": "off",
|
|
14
|
+
|
|
15
|
+
// 强制在模块顶部调用
|
|
16
|
+
// https://eslint.org/docs/rules/global-require
|
|
17
|
+
"global-require": "off",
|
|
18
|
+
|
|
19
|
+
// enforces error handling in callbacks (node environment)
|
|
20
|
+
"handle-callback-err": "off",
|
|
21
|
+
|
|
22
|
+
// disallow use of the Buffer() constructor
|
|
23
|
+
// https://eslint.org/docs/rules/no-buffer-constructor
|
|
24
|
+
"no-buffer-constructor": "error",
|
|
25
|
+
|
|
26
|
+
// disallow mixing regular variable and require declarations
|
|
27
|
+
"no-mixed-requires": ["off", false],
|
|
28
|
+
|
|
29
|
+
// disallow use of new operator with the require function
|
|
30
|
+
"no-new-require": "error",
|
|
31
|
+
|
|
32
|
+
// disallow string concatenation with __dirname and __filename
|
|
33
|
+
// https://eslint.org/docs/rules/no-path-concat
|
|
34
|
+
"no-path-concat": "error",
|
|
35
|
+
|
|
36
|
+
// disallow use of process.env
|
|
37
|
+
"no-process-env": "off",
|
|
38
|
+
|
|
39
|
+
// disallow process.exit()
|
|
40
|
+
"no-process-exit": "off",
|
|
41
|
+
|
|
42
|
+
// restrict usage of specified node modules
|
|
43
|
+
"no-restricted-modules": "off",
|
|
44
|
+
|
|
45
|
+
// disallow use of synchronous methods (off by default)
|
|
46
|
+
"no-sync": "off",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// Possible Errors
|
|
4
|
+
// 这些规则与 JavaScript 代码中可能的错误或逻辑错误有关
|
|
5
|
+
// ==========================================================
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
rules: {
|
|
9
|
+
// Enforce “for” loop update clause moving the counter in the right direction
|
|
10
|
+
// https://eslint.org/docs/rules/for-direction
|
|
11
|
+
// "for-direction": "error",
|
|
12
|
+
|
|
13
|
+
// Enforces that a return statement is present in property getters
|
|
14
|
+
// https://eslint.org/docs/rules/getter-return
|
|
15
|
+
// "getter-return": ["error", { allowImplicit: true }],
|
|
16
|
+
|
|
17
|
+
// disallow using an async function as a Promise executor
|
|
18
|
+
// https://eslint.org/docs/rules/no-async-promise-executor
|
|
19
|
+
// "no-async-promise-executor": "error",
|
|
20
|
+
|
|
21
|
+
// Disallow await inside of loops
|
|
22
|
+
// https://eslint.org/docs/rules/no-await-in-loop
|
|
23
|
+
// "no-await-in-loop": "error",
|
|
24
|
+
|
|
25
|
+
// Disallow comparisons to negative zero
|
|
26
|
+
// https://eslint.org/docs/rules/no-compare-neg-zero
|
|
27
|
+
// "no-compare-neg-zero": "error",
|
|
28
|
+
|
|
29
|
+
// disallow assignment in conditional expressions
|
|
30
|
+
// "no-cond-assign": ["error", "always"],
|
|
31
|
+
|
|
32
|
+
// 禁用 console
|
|
33
|
+
"no-console": "error",
|
|
34
|
+
|
|
35
|
+
// disallow use of constant expressions in conditions
|
|
36
|
+
// "no-constant-condition": "warn",
|
|
37
|
+
|
|
38
|
+
// disallow control characters in regular expressions
|
|
39
|
+
// "no-control-regex": "error",
|
|
40
|
+
|
|
41
|
+
// 禁用 debugger
|
|
42
|
+
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
|
|
43
|
+
|
|
44
|
+
// disallow duplicate arguments in functions
|
|
45
|
+
// "no-dupe-args": "error",
|
|
46
|
+
|
|
47
|
+
// Disallow duplicate conditions in if-else-if chains
|
|
48
|
+
// https://eslint.org/docs/rules/no-dupe-else-if
|
|
49
|
+
// "no-dupe-else-if": "error",
|
|
50
|
+
|
|
51
|
+
// disallow duplicate keys when creating object literals
|
|
52
|
+
// "no-dupe-keys": "error",
|
|
53
|
+
|
|
54
|
+
// disallow a duplicate case label.
|
|
55
|
+
// "no-duplicate-case": "error",
|
|
56
|
+
|
|
57
|
+
// disallow empty statements
|
|
58
|
+
// "no-empty": "error",
|
|
59
|
+
|
|
60
|
+
// disallow the use of empty character classes in regular expressions
|
|
61
|
+
// "no-empty-character-class": "error",
|
|
62
|
+
|
|
63
|
+
// disallow assigning to the exception in a catch block
|
|
64
|
+
// "no-ex-assign": "error",
|
|
65
|
+
|
|
66
|
+
// 禁止不必要的布尔转换
|
|
67
|
+
// https://eslint.org/docs/rules/no-extra-boolean-cast
|
|
68
|
+
"no-extra-boolean-cast": "off",
|
|
69
|
+
|
|
70
|
+
// 禁止冗余的括号
|
|
71
|
+
// https://eslint.org/docs/rules/no-extra-parens
|
|
72
|
+
"no-extra-parens": ["off", "all", {
|
|
73
|
+
conditionalAssign: true,
|
|
74
|
+
nestedBinaryExpressions: false,
|
|
75
|
+
returnAssign: false,
|
|
76
|
+
ignoreJSX: "all", // delegate to eslint-plugin-react
|
|
77
|
+
enforceForArrowConditionals: false,
|
|
78
|
+
}],
|
|
79
|
+
|
|
80
|
+
// 禁止不必要的分号
|
|
81
|
+
"no-extra-semi": "warn",
|
|
82
|
+
|
|
83
|
+
// disallow overwriting functions written as function declarations
|
|
84
|
+
// "no-func-assign": "error",
|
|
85
|
+
|
|
86
|
+
// https://eslint.org/docs/rules/no-import-assign
|
|
87
|
+
// "no-import-assign": "error",
|
|
88
|
+
|
|
89
|
+
// disallow function or variable declarations in nested blocks
|
|
90
|
+
// "no-inner-declarations": "error",
|
|
91
|
+
|
|
92
|
+
// disallow invalid regular expression strings in the RegExp constructor
|
|
93
|
+
// "no-invalid-regexp": "error",
|
|
94
|
+
|
|
95
|
+
// disallow irregular whitespace outside of strings and comments
|
|
96
|
+
// "no-irregular-whitespace": "error",
|
|
97
|
+
|
|
98
|
+
// Disallow Number Literals That Lose Precision
|
|
99
|
+
// https://eslint.org/docs/rules/no-loss-of-precision
|
|
100
|
+
// "no-loss-of-precision": "error",
|
|
101
|
+
|
|
102
|
+
// Disallow characters which are made with multiple code points in character class syntax
|
|
103
|
+
// https://eslint.org/docs/rules/no-misleading-character-class
|
|
104
|
+
// "no-misleading-character-class": "error",
|
|
105
|
+
|
|
106
|
+
// disallow the use of object properties of the global object (Math and JSON) as functions
|
|
107
|
+
// "no-obj-calls": "error",
|
|
108
|
+
|
|
109
|
+
// Disallow returning values from Promise executor functions
|
|
110
|
+
// https://eslint.org/docs/rules/no-promise-executor-return
|
|
111
|
+
// "no-promise-executor-return": "error",
|
|
112
|
+
|
|
113
|
+
// disallow use of Object.prototypes builtins directly
|
|
114
|
+
// https://eslint.org/docs/rules/no-prototype-builtins
|
|
115
|
+
// "no-prototype-builtins": "error",
|
|
116
|
+
|
|
117
|
+
// disallow multiple spaces in a regular expression literal
|
|
118
|
+
// "no-regex-spaces": "error",
|
|
119
|
+
|
|
120
|
+
// Disallow returning values from setters
|
|
121
|
+
// https://eslint.org/docs/rules/no-setter-return
|
|
122
|
+
// "no-setter-return": "error",
|
|
123
|
+
|
|
124
|
+
// disallow sparse arrays
|
|
125
|
+
// "no-sparse-arrays": "error",
|
|
126
|
+
|
|
127
|
+
// Disallow template literal placeholder syntax in regular strings
|
|
128
|
+
// https://eslint.org/docs/rules/no-template-curly-in-string
|
|
129
|
+
// "no-template-curly-in-string": "error",
|
|
130
|
+
|
|
131
|
+
// 禁止出现令人困惑的多行表达式
|
|
132
|
+
// https://eslint.org/docs/rules/no-unexpected-multiline
|
|
133
|
+
"no-unexpected-multiline": "error",
|
|
134
|
+
|
|
135
|
+
// disallow unreachable statements after a return, throw, continue, or break statement
|
|
136
|
+
// "no-unreachable": "error",
|
|
137
|
+
|
|
138
|
+
// Disallow loops with a body that allows only one iteration
|
|
139
|
+
// https://eslint.org/docs/rules/no-unreachable-loop
|
|
140
|
+
// "no-unreachable-loop": ["error", {
|
|
141
|
+
// ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
142
|
+
// }],
|
|
143
|
+
|
|
144
|
+
// disallow return/throw/break/continue inside finally blocks
|
|
145
|
+
// https://eslint.org/docs/rules/no-unsafe-finally
|
|
146
|
+
// "no-unsafe-finally": "error",
|
|
147
|
+
|
|
148
|
+
// disallow negating the left operand of relational operators
|
|
149
|
+
// https://eslint.org/docs/rules/no-unsafe-negation
|
|
150
|
+
// "no-unsafe-negation": "error",
|
|
151
|
+
|
|
152
|
+
// disallow use of optional chaining in contexts where the undefined value is not allowed
|
|
153
|
+
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
|
|
154
|
+
// "no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
155
|
+
|
|
156
|
+
// Disallow Unused Private Class Members
|
|
157
|
+
// https://eslint.org/docs/rules/no-unused-private-class-members
|
|
158
|
+
// TODO: enable once eslint 7 is dropped (which is semver-major)
|
|
159
|
+
// "no-unused-private-class-members": "off",
|
|
160
|
+
|
|
161
|
+
// Disallow useless backreferences in regular expressions
|
|
162
|
+
// https://eslint.org/docs/rules/no-useless-backreference
|
|
163
|
+
// "no-useless-backreference": "error",
|
|
164
|
+
|
|
165
|
+
// disallow negation of the left operand of an in expression
|
|
166
|
+
// deprecated in favor of no-unsafe-negation
|
|
167
|
+
// "no-negated-in-lhs": "off",
|
|
168
|
+
|
|
169
|
+
// Disallow assignments that can lead to race conditions due to usage of await or yield
|
|
170
|
+
// https://eslint.org/docs/rules/require-atomic-updates
|
|
171
|
+
// note: not enabled because it is very buggy
|
|
172
|
+
// "require-atomic-updates": "off",
|
|
173
|
+
|
|
174
|
+
// disallow comparisons with the value NaN
|
|
175
|
+
// "use-isnan": "error",
|
|
176
|
+
|
|
177
|
+
// ensure JSDoc comments are valid
|
|
178
|
+
// https://eslint.org/docs/rules/valid-jsdoc
|
|
179
|
+
// "valid-jsdoc": "off",
|
|
180
|
+
|
|
181
|
+
// ensure that the results of typeof are compared against a valid string
|
|
182
|
+
// https://eslint.org/docs/rules/valid-typeof
|
|
183
|
+
// "valid-typeof": ["error", { requireStringLiterals: true }],
|
|
184
|
+
},
|
|
185
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// Strict Mode
|
|
4
|
+
// 严格模式
|
|
5
|
+
// ==========================================================
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
rules: {
|
|
9
|
+
// babel inserts `'use strict';` for us
|
|
10
|
+
strict: ["error", "never"],
|
|
11
|
+
},
|
|
12
|
+
};
|