mm_eslint 1.1.8 → 1.1.9
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/index.js +16 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -205,6 +205,10 @@ class Detector {
|
|
|
205
205
|
function: [
|
|
206
206
|
"middleware", "controller", "component", "repository", "validator",
|
|
207
207
|
"transformer", "serializer", "interceptor", "decorator", "provider"
|
|
208
|
+
],
|
|
209
|
+
variable: [
|
|
210
|
+
"middleware", "controller", "component", "repository", "validator",
|
|
211
|
+
"transformer", "serializer", "interceptor", "decorator", "provider"
|
|
208
212
|
]
|
|
209
213
|
},
|
|
210
214
|
|
|
@@ -1586,6 +1590,8 @@ Detector.prototype._isIgnoreWord = function (name, rule_type) {
|
|
|
1586
1590
|
ignore_list = ignore_words_config.method || [];
|
|
1587
1591
|
} else if (rule_type === "function-name") {
|
|
1588
1592
|
ignore_list = ignore_words_config.function || [];
|
|
1593
|
+
} else if (rule_type === "variable-name") {
|
|
1594
|
+
ignore_list = ignore_words_config.variable || [];
|
|
1589
1595
|
}
|
|
1590
1596
|
|
|
1591
1597
|
// 检查名称是否完全匹配忽略词列表中的任何一个词
|
|
@@ -1984,6 +1990,13 @@ const variable_name_rule = {
|
|
|
1984
1990
|
single_word: { type: "boolean" },
|
|
1985
1991
|
single_word_len: { type: "number" },
|
|
1986
1992
|
styles: { type: "array", items: { type: "string" } },
|
|
1993
|
+
ignore_words: {
|
|
1994
|
+
type: "object",
|
|
1995
|
+
properties: {
|
|
1996
|
+
variable: { type: "array", items: { type: "string" } }
|
|
1997
|
+
},
|
|
1998
|
+
additionalProperties: false
|
|
1999
|
+
}
|
|
1987
2000
|
},
|
|
1988
2001
|
additionalProperties: false,
|
|
1989
2002
|
},
|
|
@@ -2592,9 +2605,9 @@ const instance_property_rule = {
|
|
|
2592
2605
|
!node.left.property.name.startsWith("_")
|
|
2593
2606
|
) {
|
|
2594
2607
|
const prop_name = node.left.property.name;
|
|
2595
|
-
//
|
|
2596
|
-
const detector = new Detector({ "
|
|
2597
|
-
const result = detector.checkName(prop_name, "
|
|
2608
|
+
// 实例属性应该符合变量命名规范(小写蛇形)
|
|
2609
|
+
const detector = new Detector({ "variable-name": options });
|
|
2610
|
+
const result = detector.checkName(prop_name, "variable-name");
|
|
2598
2611
|
|
|
2599
2612
|
if (!result.valid) {
|
|
2600
2613
|
result.errors.forEach((error) => {
|