mm_eslint 1.1.5 → 1.1.6
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 +12 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2087,18 +2087,20 @@ const constant_name_rule = {
|
|
|
2087
2087
|
return {
|
|
2088
2088
|
VariableDeclarator(node) {
|
|
2089
2089
|
if (node.id.type === "Identifier" && node.parent.kind === "const") {
|
|
2090
|
-
//
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2090
|
+
// 只对真正的常量应用常量命名规则
|
|
2091
|
+
if (isRealConstant(node)) {
|
|
2092
|
+
const constant_name = node.id.name;
|
|
2093
|
+
const detector = new Detector({ "constant-name": options });
|
|
2094
|
+
const result = detector.checkName(constant_name, "constant-name");
|
|
2094
2095
|
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2096
|
+
if (!result.valid) {
|
|
2097
|
+
result.errors.forEach((error) => {
|
|
2098
|
+
context.report({
|
|
2099
|
+
node: node.id,
|
|
2100
|
+
message: `常量名"${constant_name}"不符合规范: ${error}`,
|
|
2101
|
+
});
|
|
2100
2102
|
});
|
|
2101
|
-
}
|
|
2103
|
+
}
|
|
2102
2104
|
}
|
|
2103
2105
|
}
|
|
2104
2106
|
},
|