@houheaven/eslint-config-helper 1.4.0 → 2.1.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 -21
- package/README.md +149 -28
- package/lib/format-es5.js +23 -0
- package/lib/format-es6.js +25 -0
- package/lib/format-html.js +23 -0
- package/lib/format-import.js +23 -0
- package/lib/format-typescript.js +28 -0
- package/lib/format-vue2.js +23 -0
- package/lib/format-vue3.js +23 -0
- package/lib/html.js +16 -22
- package/lib/import.js +26 -0
- package/lib/javascript-es5.js +25 -0
- package/lib/javascript-es6.js +28 -0
- package/lib/support/es5-support.js +29 -0
- package/lib/support/es6-support.js +39 -0
- package/lib/support/html-support.js +38 -0
- package/lib/support/import-bugfix.js +65 -0
- package/lib/support/import-support.js +25 -0
- package/lib/support/typescript-support.js +27 -0
- package/lib/support/vue2-support.js +43 -0
- package/lib/support/vue3-support.js +43 -0
- package/lib/support/vue3-ts-support.js +51 -0
- package/lib/typescript.js +27 -32
- package/lib/utils/utils.js +2 -0
- package/lib/vue2.js +19 -22
- package/lib/vue3-ts.js +32 -0
- package/lib/vue3.js +16 -17
- package/node_modules/@houheaven/eslint-config-helper-core/package.json +7 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/_deprecated.js +132 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/_removed.js +25 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/es6.js +365 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/layout-formatting.js +441 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/possible-errors.js +199 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/eslint/suggestions.js +666 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/html/accessibility.js +68 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/html/best-practice.js +150 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/html/seo.js +29 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/html/style.js +70 -0
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/import/helpful-warnings.js +23 -18
- package/node_modules/@houheaven/eslint-config-helper-core/rules/import/module-systems.js +33 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/import/static-analysis.js +85 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/import/style-guide.js +125 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/_deprecated.js +57 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/conflict.js +16 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/deprecated.js +41 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/extension.js +207 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/fixable.js +215 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/other.js +125 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/stylistic.js +34 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/suggestion.js +53 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/typescript/type-checked.js +263 -0
- package/node_modules/@houheaven/eslint-config-helper-core/rules/vue/_deprecated.js +37 -0
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-base.js +1 -11
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-essential.js +25 -38
- package/node_modules/@houheaven/eslint-config-helper-core/rules/vue/common-extension.js +321 -0
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-recommended.js +64 -31
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/common-strongly-recommended.js +37 -20
- package/{lib/rules/vue/common-extra.js → node_modules/@houheaven/eslint-config-helper-core/rules/vue/common-uncategorized.js} +141 -52
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue2-essential.js +16 -14
- package/node_modules/@houheaven/eslint-config-helper-core/rules/vue/vue2-uncategorized.js +15 -0
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-essential.js +54 -24
- package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vue/vue3-strongly-recommended.js +8 -10
- package/node_modules/@houheaven/eslint-config-helper-core/rules/vue/vue3-uncategorized.js +115 -0
- package/node_modules/@houheaven/eslint-config-helper-core/summary.js +57 -0
- package/node_modules/@houheaven/eslint-config-helper-core/utils/utils.js +160 -0
- package/package.json +59 -25
- package/lib/configs/eslint-es5.js +0 -24
- package/lib/configs/eslint.js +0 -23
- package/lib/configs/format-html.js +0 -22
- package/lib/configs/format-js.js +0 -134
- package/lib/configs/format-vue.js +0 -278
- package/lib/configs/html.js +0 -20
- package/lib/configs/import-bugfix.js +0 -36
- package/lib/configs/import.js +0 -44
- package/lib/configs/typescript.js +0 -10
- package/lib/configs/vue2.js +0 -28
- package/lib/configs/vue3.js +0 -28
- package/lib/eslint.js +0 -18
- package/lib/format.js +0 -40
- package/lib/rules/eslint/best-practices.js +0 -422
- package/lib/rules/eslint/es6.js +0 -196
- package/lib/rules/eslint/node.js +0 -48
- package/lib/rules/eslint/possible-errors.js +0 -190
- package/lib/rules/eslint/strict-mode.js +0 -12
- package/lib/rules/eslint/stylistic-issues.js +0 -578
- package/lib/rules/eslint/variables.js +0 -73
- package/lib/rules/html/accessibility.js +0 -44
- package/lib/rules/html/best-practice.js +0 -64
- package/lib/rules/html/seo.js +0 -24
- package/lib/rules/html/style.js +0 -32
- package/lib/rules/import/module-systems.js +0 -34
- package/lib/rules/import/static-analysis.js +0 -69
- package/lib/rules/import/style-guide.js +0 -97
- package/lib/rules/typescript/all.js +0 -193
- package/lib/rules/typescript/base.js +0 -10
- package/lib/rules/typescript/eslint-recommended.js +0 -36
- package/lib/rules/typescript/recommended-requiring-type-checking.js +0 -26
- package/lib/rules/typescript/recommended.js +0 -36
- package/lib/rules/typescript/strict.js +0 -47
- package/lib/rules/vue/common-eslint.js +0 -220
- package/lib/rules/vue/vue2-recommended.js +0 -17
- package/lib/rules/vue/vue2-strongly-recommended.js +0 -16
- package/lib/rules/vue/vue3-recommended.js +0 -17
- /package/{lib → node_modules/@houheaven/eslint-config-helper-core}/rules/vuejs-accessibility/index.js +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
// 这些来自较旧版本的 ESLint 规则已被更新的规则所取代
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
rules: {
|
|
6
|
+
"generator-star": "", // [ ✅ 已使用 ] 替换为 generator-star-spacing
|
|
7
|
+
"global-strict": "", // [ ❌ 未使用 ] 替换为 strict
|
|
8
|
+
"no-arrow-condition": "", // [ ❌ 未使用 ] 替换为 no-confusing-arrowno-constant-condition
|
|
9
|
+
"no-comma-dangle": "", // [ ❌ 未使用 ] 替换为 comma-dangle
|
|
10
|
+
"no-empty-class": "", // [ ❌ 未使用 ] 替换为 no-empty-character-class
|
|
11
|
+
"no-empty-label": "", // [ ❌ 未使用 ] 替换为 no-labels
|
|
12
|
+
"no-extra-strict": "", // [ ❌ 未使用 ] 替换为 strict
|
|
13
|
+
"no-reserved-keys": "", // [ ❌ 未使用 ] 替换为 quote-props
|
|
14
|
+
"no-space-before-semi": "", // [ ❌ 未使用 ] 替换为 semi-spacing
|
|
15
|
+
"no-wrap-func": "", // [ ❌ 未使用 ] 替换为 no-extra-parens
|
|
16
|
+
"space-after-function-name": "", // [ ❌ 未使用 ] 替换为 space-before-function-paren
|
|
17
|
+
"space-after-keywords": "", // [ ❌ 未使用 ] 替换为 keyword-spacing
|
|
18
|
+
"space-before-function-parentheses": "", // [ ❌ 未使用 ] 替换为 space-before-function-paren
|
|
19
|
+
"space-before-keywords": "", // [ ❌ 未使用 ] 替换为 keyword-spacing
|
|
20
|
+
"space-in-brackets": "", // [ ❌ 未使用 ] 替换为 object-curly-spacingarray-bracket-spacing
|
|
21
|
+
"space-return-throw-case": "", // [ ❌ 未使用 ] 替换为 keyword-spacing
|
|
22
|
+
"space-unary-word-ops": "", // [ ❌ 未使用 ] 替换为 space-unary-ops
|
|
23
|
+
"spaced-line-comment": "", // [ ❌ 未使用 ] 替换为 spaced-comment
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
|
|
2
|
+
// ==========================================================
|
|
3
|
+
// ES6
|
|
4
|
+
// 这些规则只与 ES6 有关, 即通常所说的 ES2015
|
|
5
|
+
// ==========================================================
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
rules: {
|
|
9
|
+
// ==========================================================
|
|
10
|
+
// Possible Errors
|
|
11
|
+
// 这些规则与 JavaScript 代码中可能的错误或逻辑错误有关
|
|
12
|
+
// ==========================================================
|
|
13
|
+
|
|
14
|
+
// 数组方法的回调函数必须有返回值(map、filter、reduce 等)
|
|
15
|
+
"array-callback-return": ["error", {
|
|
16
|
+
allowImplicit: false,
|
|
17
|
+
checkForEach: true,
|
|
18
|
+
}],
|
|
19
|
+
|
|
20
|
+
// 要求在构造函数中调用 super()
|
|
21
|
+
// 派生类的构造者必须调用 super(),非派生类的构造器不得调用 super(),如果不遵守这一点,JavaScript 引擎将引起运行时错误。
|
|
22
|
+
// https://zh-hans.eslint.org/docs/latest/rules/constructor-super
|
|
23
|
+
"constructor-super": "off",
|
|
24
|
+
|
|
25
|
+
// 强制 getter 方法有返回值
|
|
26
|
+
"getter-return": ["error", {
|
|
27
|
+
// 不允许用 return 语句隐式返回 undefined
|
|
28
|
+
allowImplicit: false,
|
|
29
|
+
}],
|
|
30
|
+
|
|
31
|
+
// 禁止使用异步函数作为 Promise 执行器
|
|
32
|
+
"no-async-promise-executor": "error",
|
|
33
|
+
|
|
34
|
+
// 禁止在循环内使用 await
|
|
35
|
+
"no-await-in-loop": "error",
|
|
36
|
+
|
|
37
|
+
// 禁止重新分配类成员
|
|
38
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-class-assign
|
|
39
|
+
"no-class-assign": "error",
|
|
40
|
+
|
|
41
|
+
// 禁止对 const 变量重新赋值
|
|
42
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-const-assign
|
|
43
|
+
"no-const-assign": "error",
|
|
44
|
+
|
|
45
|
+
// 在类的构造函数中,使用此规则禁用 return 语句
|
|
46
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-constructor-return
|
|
47
|
+
"no-constructor-return": "error",
|
|
48
|
+
|
|
49
|
+
// 禁止类的成员(方法、属性)名称重复
|
|
50
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-dupe-class-members
|
|
51
|
+
"no-dupe-class-members": "error",
|
|
52
|
+
|
|
53
|
+
// 禁止重复导入模块
|
|
54
|
+
// 要求所有可以合并的单个模块的导入都在于一个 import 语句中
|
|
55
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-duplicate-imports
|
|
56
|
+
"no-duplicate-imports": "off",
|
|
57
|
+
|
|
58
|
+
// 禁止空解构模式
|
|
59
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-empty-pattern
|
|
60
|
+
"no-empty-pattern": "error",
|
|
61
|
+
|
|
62
|
+
// 禁止对导入的模块赋值
|
|
63
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-import-assign
|
|
64
|
+
"no-import-assign": "error",
|
|
65
|
+
|
|
66
|
+
// Disallow new operators with global non-constructor functions
|
|
67
|
+
// 此规则旨在阻止使用 new 操作符意外调用原生 JavaScript 全局函数(Symbol、BigInt)
|
|
68
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-new-native-nonconstructor
|
|
69
|
+
"no-new-native-nonconstructor": "error",
|
|
70
|
+
|
|
71
|
+
// 禁止用 new 运算符意外地调用 Symbol
|
|
72
|
+
// 这是错误语法,因为 Symbol 是一个原始值,不是对象
|
|
73
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-new-symbol
|
|
74
|
+
"no-new-symbol": "error",
|
|
75
|
+
|
|
76
|
+
// 不允许从 Promise 执行者函数返回值
|
|
77
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-promise-executor-return
|
|
78
|
+
"no-promise-executor-return": "error",
|
|
79
|
+
|
|
80
|
+
// 禁止在 setter 中返回值
|
|
81
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-setter-return
|
|
82
|
+
"no-setter-return": "error",
|
|
83
|
+
|
|
84
|
+
// 禁止在字符串中使用模板文字占位符语法
|
|
85
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-template-curly-in-string
|
|
86
|
+
"no-template-curly-in-string": "error",
|
|
87
|
+
|
|
88
|
+
// 禁止在 super() 之前使用 this 或 super
|
|
89
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-this-before-super
|
|
90
|
+
"no-this-before-super": "error",
|
|
91
|
+
|
|
92
|
+
// 禁止不安全的可选链(?.)
|
|
93
|
+
// 可选的链式(?.)表达式可以用 undefined 的返回值进行短路。因此,将一个已评估的选项链表达式作为一个函数、对象、数字等来处理,会导致 TypeError 或意外的结果。
|
|
94
|
+
// 这条规则的目的是检测一些使用可选链的情况,这些情况不能防止运行时错误。
|
|
95
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unsafe-optional-chaining
|
|
96
|
+
"no-unsafe-optional-chaining": ["error", {
|
|
97
|
+
// 不允许对可选链式表达式进行算术运算(默认为 false)
|
|
98
|
+
disallowArithmeticOperators: true,
|
|
99
|
+
}],
|
|
100
|
+
|
|
101
|
+
// 不允许 Class 存在未使用的私有成员(属性、方法)
|
|
102
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-unused-private-class-members
|
|
103
|
+
"no-unused-private-class-members": "error",
|
|
104
|
+
|
|
105
|
+
// 禁止由于使用await或yield而导致竞争条件的赋值
|
|
106
|
+
// https://zh-hans.eslint.org/docs/latest/rules/require-atomic-updates
|
|
107
|
+
"require-atomic-updates": "error",
|
|
108
|
+
|
|
109
|
+
// ==========================================================
|
|
110
|
+
// Suggestions
|
|
111
|
+
// 这些规则提出了做事的替代方法
|
|
112
|
+
// ==========================================================
|
|
113
|
+
|
|
114
|
+
// 强制对象中的 getter/setter 成对出现
|
|
115
|
+
// https://zh-hans.eslint.org/docs/latest/rules/accessor-pairs
|
|
116
|
+
"accessor-pairs": ["error", {
|
|
117
|
+
setWithoutGet: true,
|
|
118
|
+
getWithoutSet: true,
|
|
119
|
+
enforceForClassMembers: true,
|
|
120
|
+
}],
|
|
121
|
+
|
|
122
|
+
// 箭头函数体周围的大括号风格
|
|
123
|
+
// https://zh-hans.eslint.org/docs/latest/rules/arrow-body-style
|
|
124
|
+
"arrow-body-style": ["warn", "as-needed", {
|
|
125
|
+
requireReturnForObjectLiteral: false,
|
|
126
|
+
}],
|
|
127
|
+
|
|
128
|
+
// 强制类方法使用 "this"
|
|
129
|
+
// https://zh-hans.eslint.org/docs/latest/rules/class-methods-use-this
|
|
130
|
+
"class-methods-use-this": ["off", {
|
|
131
|
+
exceptMethods: [],
|
|
132
|
+
enforceForClassFields: false,
|
|
133
|
+
}],
|
|
134
|
+
|
|
135
|
+
// 强制默认参数放在最后
|
|
136
|
+
// https://zh-hans.eslint.org/docs/latest/rules/default-param-last
|
|
137
|
+
"default-param-last": "error",
|
|
138
|
+
|
|
139
|
+
// 在对象文本和类中要求分组访问器对(getter/setter 配对出现)
|
|
140
|
+
// https://zh-hans.eslint.org/docs/latest/rules/grouped-accessor-pairs
|
|
141
|
+
"grouped-accessor-pairs": "error",
|
|
142
|
+
|
|
143
|
+
// 每个文件强制 Class 类的最大数量
|
|
144
|
+
// https://zh-hans.eslint.org/docs/latest/rules/max-classes-per-file
|
|
145
|
+
"max-classes-per-file": ["error", 1],
|
|
146
|
+
|
|
147
|
+
// 要求构造器函数首字母大写
|
|
148
|
+
// https://zh-hans.eslint.org/docs/latest/rules/new-cap
|
|
149
|
+
"new-cap": ["error", {
|
|
150
|
+
newIsCap: true,
|
|
151
|
+
newIsCapExceptions: [],
|
|
152
|
+
newIsCapExceptionPattern: "^hh[A-Z]",
|
|
153
|
+
capIsNew: false,
|
|
154
|
+
capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
|
|
155
|
+
capIsNewExceptionPattern: "",
|
|
156
|
+
properties: false,
|
|
157
|
+
}],
|
|
158
|
+
|
|
159
|
+
// 禁止在可能与比较操作符相混淆的地方使用箭头函数
|
|
160
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-confusing-arrow
|
|
161
|
+
"no-confusing-arrow": ["warn", {
|
|
162
|
+
allowParens: true,
|
|
163
|
+
onlyOneSimpleParam: false,
|
|
164
|
+
}],
|
|
165
|
+
|
|
166
|
+
// 禁止使用 __iterator__ 属性(应该使用 ECMAScript 6 迭代器和生成器来代替)
|
|
167
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-iterator
|
|
168
|
+
"no-iterator": "error",
|
|
169
|
+
|
|
170
|
+
// 禁止在 exports 导出中使用指定的名称
|
|
171
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-restricted-exports
|
|
172
|
+
"no-restricted-exports": ["error", {
|
|
173
|
+
restrictedNamedExports: [
|
|
174
|
+
"default", // use `export default` to provide a default export
|
|
175
|
+
"then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
|
|
176
|
+
],
|
|
177
|
+
}],
|
|
178
|
+
|
|
179
|
+
// 禁止 imports 导入指定的模块
|
|
180
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-restricted-imports
|
|
181
|
+
"no-restricted-imports": ["off", {
|
|
182
|
+
paths: [],
|
|
183
|
+
patterns: [],
|
|
184
|
+
}],
|
|
185
|
+
|
|
186
|
+
// 禁止无用的计算属性键
|
|
187
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-useless-computed-key
|
|
188
|
+
"no-useless-computed-key": ["warn", {
|
|
189
|
+
enforceForClassMembers: true,
|
|
190
|
+
}],
|
|
191
|
+
|
|
192
|
+
// 禁止无用的构造函数
|
|
193
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-useless-constructor
|
|
194
|
+
"no-useless-constructor": "error",
|
|
195
|
+
|
|
196
|
+
// 不允许重命名导入、导出以及以相同名称进行的解构赋值
|
|
197
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-useless-rename
|
|
198
|
+
"no-useless-rename": ["warn", {
|
|
199
|
+
ignoreDestructuring: false,
|
|
200
|
+
ignoreImport: false,
|
|
201
|
+
ignoreExport: false,
|
|
202
|
+
}],
|
|
203
|
+
|
|
204
|
+
// 要求使用 let 或 const 而不是 var
|
|
205
|
+
// https://zh-hans.eslint.org/docs/latest/rules/no-var
|
|
206
|
+
"no-var": "warn",
|
|
207
|
+
|
|
208
|
+
// 要求或禁止对象字面量的方法和属性简写语法
|
|
209
|
+
// https://zh-hans.eslint.org/docs/latest/rules/object-shorthand
|
|
210
|
+
"object-shorthand": ["warn", "properties", {
|
|
211
|
+
avoidQuotes: true,
|
|
212
|
+
// ignoreConstructors: false,
|
|
213
|
+
// methodsIgnorePattern: "",
|
|
214
|
+
// avoidExplicitReturnArrows: false,
|
|
215
|
+
}],
|
|
216
|
+
|
|
217
|
+
// 要求回调函数使用箭头函数
|
|
218
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-arrow-callback
|
|
219
|
+
"prefer-arrow-callback": ["warn", {
|
|
220
|
+
allowNamedFunctions: false,
|
|
221
|
+
allowUnboundThis: true,
|
|
222
|
+
}],
|
|
223
|
+
|
|
224
|
+
// 初始赋值后从未重新赋值的变量应该使用 const 声明
|
|
225
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-const
|
|
226
|
+
"prefer-const": ["warn", {
|
|
227
|
+
destructuring: "any",
|
|
228
|
+
ignoreReadBeforeAssign: true,
|
|
229
|
+
}],
|
|
230
|
+
|
|
231
|
+
// 优先使用数组和对象解构
|
|
232
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-destructuring
|
|
233
|
+
"prefer-destructuring": "off",
|
|
234
|
+
// "prefer-destructuring": [
|
|
235
|
+
// "warn",
|
|
236
|
+
// {
|
|
237
|
+
// VariableDeclarator: {
|
|
238
|
+
// array: false,
|
|
239
|
+
// object: true,
|
|
240
|
+
// },
|
|
241
|
+
// AssignmentExpression: {
|
|
242
|
+
// array: true,
|
|
243
|
+
// object: false,
|
|
244
|
+
// },
|
|
245
|
+
// },
|
|
246
|
+
// {
|
|
247
|
+
// enforceForRenamedProperties: false,
|
|
248
|
+
// },
|
|
249
|
+
// ],
|
|
250
|
+
|
|
251
|
+
// 不允许调用 Math.pow,建议使用 ** 运算符代替
|
|
252
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-exponentiation-operator
|
|
253
|
+
"prefer-exponentiation-operator": "warn",
|
|
254
|
+
|
|
255
|
+
// 正则表达式中建议使用命名捕获组
|
|
256
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-named-capture-group
|
|
257
|
+
"prefer-named-capture-group": "off",
|
|
258
|
+
|
|
259
|
+
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
|
260
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-numeric-literals
|
|
261
|
+
"prefer-numeric-literals": "warn",
|
|
262
|
+
|
|
263
|
+
// 要求使用 Object.hasOwn() 方法而不是 Object.prototype.hasOwnProperty.call()
|
|
264
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-object-has-own
|
|
265
|
+
"prefer-object-has-own": "warn",
|
|
266
|
+
|
|
267
|
+
// 禁止使用以对象字面量作为第一个参数的 Object.assign,优先使用对象扩展
|
|
268
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-object-spread
|
|
269
|
+
"prefer-object-spread": "off",
|
|
270
|
+
// "prefer-object-spread": "warn",
|
|
271
|
+
|
|
272
|
+
// 要求使用 Error 对象作为 Promise 拒绝的原因
|
|
273
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-promise-reject-errors
|
|
274
|
+
"prefer-promise-reject-errors": ["error", {
|
|
275
|
+
allowEmptyReject: true,
|
|
276
|
+
}],
|
|
277
|
+
|
|
278
|
+
// 要求使用 rest 参数而不是 arguments
|
|
279
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-rest-params
|
|
280
|
+
"prefer-rest-params": "error",
|
|
281
|
+
|
|
282
|
+
// 需要展开操作符而不是 .apply()
|
|
283
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-spread
|
|
284
|
+
"prefer-spread": "error",
|
|
285
|
+
|
|
286
|
+
// 要求使用模板文字进行字符串连接
|
|
287
|
+
// https://zh-hans.eslint.org/docs/latest/rules/prefer-template
|
|
288
|
+
"prefer-template": "warn",
|
|
289
|
+
|
|
290
|
+
// 要求 async 函数中含有 await 表达式
|
|
291
|
+
// https://zh-hans.eslint.org/docs/latest/rules/require-await
|
|
292
|
+
"require-await": "error",
|
|
293
|
+
|
|
294
|
+
// 要求在正则表达式中使用 u、v 标志
|
|
295
|
+
// https://zh-hans.eslint.org/docs/latest/rules/require-unicode-regexp
|
|
296
|
+
"require-unicode-regexp": "error",
|
|
297
|
+
|
|
298
|
+
// 要求生成器函数包含 yield 表达式
|
|
299
|
+
// https://zh-hans.eslint.org/docs/latest/rules/require-yield
|
|
300
|
+
"require-yield": "error",
|
|
301
|
+
|
|
302
|
+
// 在模块内对导入声明进行强制排序
|
|
303
|
+
// https://zh-hans.eslint.org/docs/latest/rules/sort-imports
|
|
304
|
+
"sort-imports": ["off", {
|
|
305
|
+
ignoreCase: false,
|
|
306
|
+
ignoreDeclarationSort: false,
|
|
307
|
+
ignoreMemberSort: false,
|
|
308
|
+
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
|
|
309
|
+
}],
|
|
310
|
+
|
|
311
|
+
// 要求在创建 Symbol 时要有描述
|
|
312
|
+
// https://zh-hans.eslint.org/docs/latest/rules/symbol-description
|
|
313
|
+
"symbol-description": "error",
|
|
314
|
+
|
|
315
|
+
// ==========================================================
|
|
316
|
+
// Layout and Formatting
|
|
317
|
+
// 这些规则关心的是代码的外观而不是执行方式
|
|
318
|
+
// ==========================================================
|
|
319
|
+
|
|
320
|
+
// 要求箭头函数的参数使用圆括号
|
|
321
|
+
// https://zh-hans.eslint.org/docs/latest/rules/arrow-parens
|
|
322
|
+
"arrow-parens": ["warn", "as-needed"],
|
|
323
|
+
|
|
324
|
+
// 要求箭头函数的箭头之前或之后有空格
|
|
325
|
+
// https://zh-hans.eslint.org/docs/latest/rules/arrow-spacing
|
|
326
|
+
"arrow-spacing": ["warn", {
|
|
327
|
+
before: true,
|
|
328
|
+
after: true,
|
|
329
|
+
}],
|
|
330
|
+
|
|
331
|
+
// 强制 generator 函数中 * 号周围使用一致的空格
|
|
332
|
+
// https://zh-hans.eslint.org/docs/latest/rules/generator-star-spacing
|
|
333
|
+
"generator-star-spacing": ["warn", {
|
|
334
|
+
before: false,
|
|
335
|
+
after: true,
|
|
336
|
+
}],
|
|
337
|
+
|
|
338
|
+
// 强制隐式返回的箭头函数体的位置
|
|
339
|
+
// https://zh-hans.eslint.org/docs/latest/rules/implicit-arrow-linebreak
|
|
340
|
+
"implicit-arrow-linebreak": ["warn", "beside"],
|
|
341
|
+
|
|
342
|
+
// 类成员之间要求或禁止空行
|
|
343
|
+
// https://zh-hans.eslint.org/docs/latest/rules/lines-between-class-members
|
|
344
|
+
"lines-between-class-members": "off",
|
|
345
|
+
|
|
346
|
+
// 强制剩余和扩展运算符及其表达式之间有空格
|
|
347
|
+
// https://zh-hans.eslint.org/docs/latest/rules/rest-spread-spacing
|
|
348
|
+
"rest-spread-spacing": ["warn", "never"],
|
|
349
|
+
|
|
350
|
+
// 要求或禁止模板字符串中的嵌入表达式周围空格的使用
|
|
351
|
+
// https://zh-hans.eslint.org/docs/latest/rules/template-curly-spacing
|
|
352
|
+
"template-curly-spacing": ["warn", "never"],
|
|
353
|
+
|
|
354
|
+
// 要求或禁止在模板标记和它们的字面量之间有空格
|
|
355
|
+
// https://zh-hans.eslint.org/docs/latest/rules/template-tag-spacing
|
|
356
|
+
"template-tag-spacing": ["warn", "never"],
|
|
357
|
+
|
|
358
|
+
// 强制在 yield* 表达式中 * 周围使用空格
|
|
359
|
+
// https://zh-hans.eslint.org/docs/latest/rules/yield-star-spacing
|
|
360
|
+
"yield-star-spacing": ["warn", {
|
|
361
|
+
before: false,
|
|
362
|
+
after: true,
|
|
363
|
+
}],
|
|
364
|
+
},
|
|
365
|
+
};
|