mm_eslint 1.3.2 → 1.3.4
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/config.js +6 -2
- package/detector.js +15 -0
- package/package.json +1 -1
package/config.js
CHANGED
|
@@ -13,7 +13,8 @@ class Config {
|
|
|
13
13
|
'class-name': [],
|
|
14
14
|
'method-name': [],
|
|
15
15
|
'variable-name': [],
|
|
16
|
-
'constant-name': []
|
|
16
|
+
'constant-name': [],
|
|
17
|
+
'property-value-name': [] // 忽略$符号的属性值名
|
|
17
18
|
},
|
|
18
19
|
// 禁止词
|
|
19
20
|
forbidden_words: {
|
|
@@ -498,10 +499,13 @@ Config.prototype.getIgnoredWords = function (name_type) {
|
|
|
498
499
|
'Middleware', 'Component', 'Controller', 'Repository', 'Interface', 'Transform', 'Template'
|
|
499
500
|
],
|
|
500
501
|
'variable-name': [
|
|
501
|
-
'i', 'k', 'x', 'y', 'z', 'n', 'm', 'o', 'middleware', 'component', 'controller', 'repository', 'interface', 'transformer', 'template'
|
|
502
|
+
'i', 'k', 'x', 'y', 'z', 'n', 'm', 'o', 'middleware', 'component', 'controller', 'repository', 'interface', 'transformer', 'template', '$'
|
|
502
503
|
],
|
|
503
504
|
'param-name': [
|
|
504
505
|
'middleware', 'component', 'controller', 'repository', 'interface', 'transformer', 'template'
|
|
506
|
+
],
|
|
507
|
+
'property-value-name': [
|
|
508
|
+
'$' // 忽略$符号的属性值名
|
|
505
509
|
]
|
|
506
510
|
};
|
|
507
511
|
|
package/detector.js
CHANGED
|
@@ -751,6 +751,12 @@ Detector.prototype._checkPropertyName = function (
|
|
|
751
751
|
break;
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
+
// 检查忽略词
|
|
755
|
+
var ignored_words = this.config.getIgnoredWords(rule_type);
|
|
756
|
+
if (ignored_words && ignored_words.includes(prop_name)) {
|
|
757
|
+
return null; // 忽略词不进行命名规范检测
|
|
758
|
+
}
|
|
759
|
+
|
|
754
760
|
var rule = this.config.getRule(rule_type);
|
|
755
761
|
if (!rule) {
|
|
756
762
|
return null;
|
|
@@ -778,6 +784,15 @@ Detector.prototype._checkPropertyName = function (
|
|
|
778
784
|
// 公开方法:检查是否符合公开方法命名规范
|
|
779
785
|
style_err = this._validate_naming_style(prop_name, rule.styles, rule_type);
|
|
780
786
|
}
|
|
787
|
+
} else if (rule_type === 'property-instance-class-name') {
|
|
788
|
+
// 属性实例类:支持公开实例类(camelCase)和私有实例类(_camelCase)
|
|
789
|
+
if (prop_name.startsWith('_')) {
|
|
790
|
+
// 私有实例类:检查是否符合私有实例类命名规范
|
|
791
|
+
style_err = this._validate_naming_style(prop_name, ['_camelCase'], rule_type);
|
|
792
|
+
} else {
|
|
793
|
+
// 公开实例类:检查是否符合公开实例类命名规范
|
|
794
|
+
style_err = this._validate_naming_style(prop_name, rule.styles, rule_type);
|
|
795
|
+
}
|
|
781
796
|
} else {
|
|
782
797
|
// 其他属性类型:使用原有逻辑
|
|
783
798
|
style_err = this._validate_naming_style(prop_name, rule.styles, rule_type);
|