mm_eslint 1.5.6 → 1.5.7

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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * JavaScript内置函数列表
3
+ * 这些函数不应该被命名规范检测器检测
4
+ */
5
+
6
+ /**
7
+ * 获取内置函数列表
8
+ * @returns {Array} 内置函数名称数组
9
+ */
10
+ function getBuiltinFunctions() {
11
+ return [
12
+ 'decodeURIComponent',
13
+ 'encodeURIComponent',
14
+ 'setImmediate',
15
+ 'clearImmediate',
16
+ 'requestAnimationFrame',
17
+ 'cancelAnimationFrame',
18
+ 'queueMicrotask'
19
+ ];
20
+ }
21
+
22
+ /**
23
+ * 检查是否为内置函数
24
+ * @param {string} name 函数名
25
+ * @returns {boolean} 是否为内置函数
26
+ */
27
+ function isBuiltinFunction(name) {
28
+ if (!name || typeof name !== 'string') {
29
+ return false;
30
+ }
31
+
32
+ const builtinFunctions = getBuiltinFunctions();
33
+ return builtinFunctions.includes(name);
34
+ }
35
+
36
+ module.exports = {
37
+ getBuiltinFunctions,
38
+ isBuiltinFunction
39
+ };
@@ -1,4 +1,5 @@
1
1
  const { Name } = require('./name.js');
2
+ const { isBuiltinFunction } = require('../builtin_functions.js');
2
3
 
3
4
  /**
4
5
  * 函数名检测器类
@@ -231,6 +232,12 @@ FunctionName.prototype.CallExpression = function (node) {
231
232
  // 检测函数调用中的函数名
232
233
  if (node.callee && node.callee.type === 'Identifier') {
233
234
  let name = node.callee.name;
235
+
236
+ // 如果是内置函数,忽略检测
237
+ if (isBuiltinFunction(name)) {
238
+ return undefined;
239
+ }
240
+
234
241
  let original_type = 'use-function';
235
242
  let error = this.check(node, name, original_type);
236
243
  this.report(node, error, original_type);
@@ -3,6 +3,7 @@ const { Validator } = require('../validator.js');
3
3
  const { Corrector } = require('../corrector.js');
4
4
  const { Tip } = require('../tip.js');
5
5
  const { Fix } = require('../fix.js');
6
+ const { isBuiltinFunction } = require('../builtin_functions.js');
6
7
 
7
8
  /**
8
9
  * 函数名检测器类
@@ -207,6 +208,11 @@ Name.prototype._isFunctionInScope = function (name, node) {
207
208
  return false;
208
209
  }
209
210
 
211
+ // 如果是内置函数,不认为是作用域内定义的函数
212
+ if (isBuiltinFunction(name)) {
213
+ return false;
214
+ }
215
+
210
216
  // 获取AST根节点
211
217
  let program_node = this._getProgramNode(node);
212
218
  if (!program_node || !program_node.body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_eslint",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "ESLint plugin for personal naming conventions - supports PascalCase, camelCase, snake_case, and UPPER_SNAKE_CASE naming rules with intelligent recommendations",
5
5
  "main": "index.js",
6
6
  "keywords": [