mm_eslint 1.1.0 → 1.1.1
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 +24 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1433,9 +1433,30 @@ Detector.prototype._hasBadWord = function (name, type) {
|
|
|
1433
1433
|
return false;
|
|
1434
1434
|
}
|
|
1435
1435
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1436
|
+
// 检查名称是否包含废话词作为独立的单词(而不是子字符串)
|
|
1437
|
+
return forbidden_words.some((word) => {
|
|
1438
|
+
const wordLower = word.toLowerCase();
|
|
1439
|
+
|
|
1440
|
+
// 检查是否作为独立的单词存在
|
|
1441
|
+
// 1. 作为整个名称(单个单词)
|
|
1442
|
+
if (nameLower === wordLower) {
|
|
1443
|
+
return false; // 单个单词允许使用
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// 2. 作为复合名称的一部分(以下划线分隔)
|
|
1447
|
+
if (nameLower.includes('_')) {
|
|
1448
|
+
const words = nameLower.split('_');
|
|
1449
|
+
return words.includes(wordLower);
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
// 3. 作为驼峰命名的一部分
|
|
1453
|
+
if (/^[a-z]+([A-Z][a-z]+)+$/.test(name)) {
|
|
1454
|
+
const camelWords = name.replace(/([A-Z])/g, '_$1').toLowerCase().split('_');
|
|
1455
|
+
return camelWords.includes(wordLower);
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
return false;
|
|
1459
|
+
});
|
|
1439
1460
|
};
|
|
1440
1461
|
|
|
1441
1462
|
/**
|