mm_eslint 1.0.9 → 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 +25 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -226,7 +226,7 @@ class Detector {
|
|
|
226
226
|
// 通用数据词:变量本身就是数据/值,不需要重复说明
|
|
227
227
|
"value", "data", "item", "items", "element", "elements", "entry", "entries",
|
|
228
228
|
// 临时状态词:临时变量不需要说明是临时的
|
|
229
|
-
"temp", "tmp", "temporary", "
|
|
229
|
+
"temp", "tmp", "temporary", "cached", "buffer", "buffered",
|
|
230
230
|
// 输入输出词:变量本身就有用途,不需要重复说明
|
|
231
231
|
"input", "output", "result", "source", "target", "destination",
|
|
232
232
|
// 计数索引词:变量本身就有计数/索引功能,不需要重复说明
|
|
@@ -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
|
/**
|