mm_eslint 1.3.1 → 1.3.3
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/detector.js +15 -0
- package/package.json +1 -1
package/detector.js
CHANGED
|
@@ -670,6 +670,12 @@ Detector.prototype._getPropType = function (val_node, prop_name, parent_node) {
|
|
|
670
670
|
val_node.name &&
|
|
671
671
|
val_node.name[0] === val_node.name[0].toUpperCase()
|
|
672
672
|
) {
|
|
673
|
+
// 检查是否是特殊全局变量(如__dirname、__filename、process等)
|
|
674
|
+
var special_globals = ['__dirname', '__filename', 'process', 'console', 'module', 'exports', 'require', 'global'];
|
|
675
|
+
if (special_globals.includes(val_node.name)) {
|
|
676
|
+
return 'value'; // 特殊全局变量应该识别为属性值
|
|
677
|
+
}
|
|
678
|
+
|
|
673
679
|
// 检查是否是类名引用(通常类名使用PascalCase)
|
|
674
680
|
return 'class'; // 属性类类型
|
|
675
681
|
}
|
|
@@ -772,6 +778,15 @@ Detector.prototype._checkPropertyName = function (
|
|
|
772
778
|
// 公开方法:检查是否符合公开方法命名规范
|
|
773
779
|
style_err = this._validate_naming_style(prop_name, rule.styles, rule_type);
|
|
774
780
|
}
|
|
781
|
+
} else if (rule_type === 'property-instance-class-name') {
|
|
782
|
+
// 属性实例类:支持公开实例类(camelCase)和私有实例类(_camelCase)
|
|
783
|
+
if (prop_name.startsWith('_')) {
|
|
784
|
+
// 私有实例类:检查是否符合私有实例类命名规范
|
|
785
|
+
style_err = this._validate_naming_style(prop_name, ['_camelCase'], rule_type);
|
|
786
|
+
} else {
|
|
787
|
+
// 公开实例类:检查是否符合公开实例类命名规范
|
|
788
|
+
style_err = this._validate_naming_style(prop_name, rule.styles, rule_type);
|
|
789
|
+
}
|
|
775
790
|
} else {
|
|
776
791
|
// 其他属性类型:使用原有逻辑
|
|
777
792
|
style_err = this._validate_naming_style(prop_name, rule.styles, rule_type);
|