mm_eslint 1.3.9 → 1.4.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/detector.js +14 -3
- package/package.json +1 -1
package/detector.js
CHANGED
|
@@ -542,9 +542,7 @@ Detector.prototype._checkWordLength = function (name, max_word_len, name_type) {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
var name_type_desc = this.config.name_type_map[name_type] || '名称';
|
|
545
|
-
|
|
546
|
-
var words = [];
|
|
547
|
-
|
|
545
|
+
|
|
548
546
|
// 处理私有标识符(开头的下划线)
|
|
549
547
|
var processed_name = name;
|
|
550
548
|
var has_private_prefix = false;
|
|
@@ -554,6 +552,9 @@ Detector.prototype._checkWordLength = function (name, max_word_len, name_type) {
|
|
|
554
552
|
processed_name = name.substring(1); // 去掉开头的下划线
|
|
555
553
|
}
|
|
556
554
|
|
|
555
|
+
// 分割单词(根据命名风格)
|
|
556
|
+
var words = [];
|
|
557
|
+
|
|
557
558
|
if (processed_name.includes('_')) {
|
|
558
559
|
words = processed_name.split('_');
|
|
559
560
|
} else if (processed_name.includes('-')) {
|
|
@@ -568,6 +569,16 @@ Detector.prototype._checkWordLength = function (name, max_word_len, name_type) {
|
|
|
568
569
|
words.unshift('_');
|
|
569
570
|
}
|
|
570
571
|
|
|
572
|
+
// 过滤空字符串
|
|
573
|
+
words = words.filter(function(word) {
|
|
574
|
+
return word && word.length > 0;
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// 如果是单个单词,则不检测单词长度
|
|
578
|
+
if (words.length <= 1) {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
|
|
571
582
|
for (var i = 0; i < words.length; i++) {
|
|
572
583
|
var word = words[i];
|
|
573
584
|
// 跳过空字符串和私有标识符(单个下划线)
|