mm_eslint 1.1.7 → 1.1.8

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.
Files changed (2) hide show
  1. package/index.js +61 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -230,8 +230,8 @@ class Detector {
230
230
  "data", "result", "output", "input", "param", "params", "parameter", "parameters",
231
231
  "value", "values", "item", "items",
232
232
  // 通用处理词汇(动词已经表达了处理,这些名词是冗余的)
233
- "process", "handler", "processor", "manager", "controller", "service", "provider",
234
- "factory", "builder", "adapter", "decorator", "proxy", "facade", "mediator",
233
+ "process", "processor", "provider",
234
+ "builder", "adapter", "decorator", "proxy", "facade", "mediator",
235
235
  "observer", "strategy", "command", "visitor", "iterator", "template",
236
236
  "flyweight", "memento", "interpreter",
237
237
  // 临时缓存词汇(动词已经表达了操作,这些名词是冗余的)
@@ -407,7 +407,7 @@ class Detector {
407
407
  Object.keys(config).forEach((key) => {
408
408
  if (merged_cfg[key] && typeof merged_cfg[key] === "object" && !Array.isArray(merged_cfg[key])) {
409
409
  // 如果是对象配置(如规则配置),则深度合并
410
- merged_cfg[key] = { ...merged_cfg[key], ...config[key] };
410
+ merged_cfg[key] = this._deepMerge(merged_cfg[key], config[key]);
411
411
 
412
412
  // 处理字符串形式的正则表达式
413
413
  if (typeof merged_cfg[key].regex === "string") {
@@ -438,6 +438,37 @@ class Detector {
438
438
  this.config = merged_cfg;
439
439
  this._initRule();
440
440
  }
441
+
442
+ /**
443
+ * 深度合并两个对象
444
+ * @param {Object} target 目标对象
445
+ * @param {Object} source 源对象
446
+ * @returns {Object} 合并后的对象
447
+ * @private
448
+ */
449
+ _deepMerge(target, source) {
450
+ const result = { ...target };
451
+
452
+ Object.keys(source).forEach((key) => {
453
+ const source_val = source[key];
454
+ const target_val = target[key];
455
+
456
+ if (Array.isArray(source_val) && Array.isArray(target_val)) {
457
+ // 如果是数组,则合并数组(去重)
458
+ result[key] = [...new Set([...target_val, ...source_val])];
459
+ } else if (typeof source_val === 'object' && source_val !== null &&
460
+ typeof target_val === 'object' && target_val !== null &&
461
+ !Array.isArray(source_val) && !Array.isArray(target_val)) {
462
+ // 如果是对象,则递归深度合并
463
+ result[key] = this._deepMerge(target_val, source_val);
464
+ } else {
465
+ // 其他情况直接覆盖
466
+ result[key] = source_val;
467
+ }
468
+ });
469
+
470
+ return result;
471
+ }
441
472
  }
442
473
 
443
474
  /**
@@ -1727,6 +1758,15 @@ const class_name_rule = {
1727
1758
  single_word: { type: "boolean" },
1728
1759
  single_word_len: { type: "number" },
1729
1760
  styles: { type: "array", items: { type: "string" } },
1761
+ ignore_words: {
1762
+ type: "object",
1763
+ properties: {
1764
+ class: { type: "array", items: { type: "string" } },
1765
+ method: { type: "array", items: { type: "string" } },
1766
+ function: { type: "array", items: { type: "string" } }
1767
+ },
1768
+ additionalProperties: false
1769
+ }
1730
1770
  },
1731
1771
  additionalProperties: false,
1732
1772
  },
@@ -1775,6 +1815,15 @@ const function_name_rule = {
1775
1815
  single_word: { type: "boolean" },
1776
1816
  single_word_len: { type: "number" },
1777
1817
  styles: { type: "array", items: { type: "string" } },
1818
+ ignore_words: {
1819
+ type: "object",
1820
+ properties: {
1821
+ class: { type: "array", items: { type: "string" } },
1822
+ method: { type: "array", items: { type: "string" } },
1823
+ function: { type: "array", items: { type: "string" } }
1824
+ },
1825
+ additionalProperties: false
1826
+ }
1778
1827
  },
1779
1828
  additionalProperties: false,
1780
1829
  },
@@ -1842,6 +1891,15 @@ const method_name_rule = {
1842
1891
  single_word: { type: "boolean" },
1843
1892
  single_word_len: { type: "number" },
1844
1893
  styles: { type: "array", items: { type: "string" } },
1894
+ ignore_words: {
1895
+ type: "object",
1896
+ properties: {
1897
+ class: { type: "array", items: { type: "string" } },
1898
+ method: { type: "array", items: { type: "string" } },
1899
+ function: { type: "array", items: { type: "string" } }
1900
+ },
1901
+ additionalProperties: false
1902
+ }
1845
1903
  },
1846
1904
  additionalProperties: false,
1847
1905
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_eslint",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "ESLint plugin for naming conventions - PascalCase, camelCase, snake_case, and UPPER_SNAKE_CASE naming rules",
5
5
  "main": "index.js",
6
6
  "keywords": [