auto-cr-rules 1.0.9 → 1.0.11

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/dist/index.js CHANGED
@@ -4,5 +4,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.rules = void 0;
7
- const NoDeepRelativeImports_1 = __importDefault(require("./rules/NoDeepRelativeImports"));
7
+ var NoDeepRelativeImports_1 = __importDefault(require("./rules/NoDeepRelativeImports"));
8
8
  exports.rules = [NoDeepRelativeImports_1.default];
@@ -12,36 +12,36 @@ function checkRelativePath(sourceValue, path, maxDepth, report) {
12
12
  // 只检查相对路径
13
13
  if (sourceValue.startsWith('.')) {
14
14
  // 计算路径深度:通过计算 "../" 的出现次数
15
- const depth = (sourceValue.match(/\.\.\//g) || []).length;
15
+ var depth = (sourceValue.match(/\.\.\//g) || []).length;
16
16
  if (depth > maxDepth) {
17
- report(path, `导入路径 "${sourceValue}" 不能超过最大层级${maxDepth}`);
17
+ report(path, "\u5BFC\u5165\u8DEF\u5F84 \"".concat(sourceValue, "\" \u4E0D\u80FD\u8D85\u8FC7\u6700\u5927\u5C42\u7EA7").concat(maxDepth));
18
18
  }
19
19
  }
20
20
  }
21
21
  // 导出Babel插件函数
22
22
  function default_1(api, options) {
23
- const { types: t } = api;
24
- const maxDepth = 2;
23
+ var t = api.types;
24
+ var maxDepth = 2;
25
25
  // 从插件参数中获取 report 方法,如果没有提供则使用默认的 console.error
26
- const { report } = options;
26
+ var report = options.report;
27
27
  return {
28
28
  name: 'no-deep-relative-imports',
29
29
  visitor: {
30
30
  // 处理静态导入语句
31
- ImportDeclaration(path) {
32
- const sourceValue = path.node.source.value;
31
+ ImportDeclaration: function (path) {
32
+ var sourceValue = path.node.source.value;
33
33
  if (typeof sourceValue === 'string') {
34
34
  checkRelativePath(sourceValue, path, maxDepth, report);
35
35
  }
36
36
  },
37
37
  // 处理动态 import() 语句和 require() 调用
38
- CallExpression(path) {
38
+ CallExpression: function (path) {
39
39
  // 检查是否是 import() 调用
40
40
  if (t.isImport(path.node.callee)) {
41
- const firstArg = path.node.arguments[0];
41
+ var firstArg = path.node.arguments[0];
42
42
  // 确保第一个参数是字符串字面量
43
43
  if (firstArg && t.isStringLiteral(firstArg)) {
44
- const sourceValue = firstArg.value;
44
+ var sourceValue = firstArg.value;
45
45
  checkRelativePath(sourceValue, path, maxDepth, report);
46
46
  }
47
47
  }
@@ -49,10 +49,10 @@ function default_1(api, options) {
49
49
  else if (t.isIdentifier(path.node.callee, { name: 'require' }) ||
50
50
  (t.isMemberExpression(path.node.callee) &&
51
51
  t.isIdentifier(path.node.callee.object, { name: 'require' }))) {
52
- const firstArg = path.node.arguments[0];
52
+ var firstArg = path.node.arguments[0];
53
53
  // 确保第一个参数是字符串字面量
54
54
  if (firstArg && t.isStringLiteral(firstArg)) {
55
- const sourceValue = firstArg.value;
55
+ var sourceValue = firstArg.value;
56
56
  checkRelativePath(sourceValue, path, maxDepth, report);
57
57
  }
58
58
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "auto-cr-rules",
3
- "version": "1.0.9",
4
- "description": "",
5
- "type": "module",
3
+ "version": "1.0.11",
4
+ "description": "旨在帮助开发团队在代码合并或提交时快速进行智能化审查,提升代码质量与开发效率。",
5
+ "type": "commonjs",
6
6
  "main": "./dist/index.js",
7
- "types": "./dist/types/index.d.ts",
7
+ "types": "./dist/index.d.ts",
8
8
  "module": "./dist/index.js",
9
9
  "files": [
10
10
  "dist",
File without changes
File without changes