auto-cr-cmd 2.0.76 → 2.0.78

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/dist/index.js +16 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -81,10 +81,19 @@ var consolaLoggers = {
81
81
  warn: consola_1.consola.warn.bind(consola_1.consola),
82
82
  error: consola_1.consola.error.bind(consola_1.consola),
83
83
  };
84
+ // 仅扫描 JS/TS 源码扩展名,避免把配置文件/JSON/图片等送进 SWC 解析导致报错。
84
85
  var SCANNABLE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
86
+ // 单文件路径也走扩展名过滤,保证与目录扫描的行为一致。
85
87
  var isScannableFile = function (filePath) {
86
88
  return SCANNABLE_EXTENSIONS.some(function (extension) { return filePath.endsWith(extension); });
87
89
  };
90
+ /**
91
+ * CLI 主流程:
92
+ * 1. 校验输入路径并应用 ignore;
93
+ * 2. 展开目录为可扫描文件列表;
94
+ * 3. 加载规则 + 规则配置;
95
+ * 4. 逐文件扫描并汇总输出。
96
+ */
88
97
  function run() {
89
98
  return __awaiter(this, arguments, void 0, function (filePaths, ruleDir, format, configPath, ignorePath) {
90
99
  var t, notifications, log, validPaths, ignoreConfig, isIgnored_1, allFiles, _i, validPaths_1, targetPath, stat, directoryFiles, scannableFiles, customRules, rcConfig, rules, filesWithErrors, filesWithWarnings, filesWithOptimizing, totalViolations, totalErrorViolations, totalWarningViolations, totalOptimizingViolations, fileSummaries, _a, scannableFiles_1, file, summary, error_1;
@@ -266,6 +275,13 @@ function run() {
266
275
  });
267
276
  });
268
277
  }
278
+ /**
279
+ * 单文件扫描流程:
280
+ * - 读取源码并解析 AST;
281
+ * - 基于语言/源码构建规则上下文;
282
+ * - 逐条执行规则,收集 reporter 输出;
283
+ * - 汇总为文件级统计。
284
+ */
269
285
  function analyzeFile(file, rules, format, log) {
270
286
  return __awaiter(this, void 0, void 0, function () {
271
287
  var source, reporter, t, ast, parseOptions, language, baseContext, sharedHelpers, _loop_1, _i, rules_1, rule, summary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-cr-cmd",
3
- "version": "2.0.76",
3
+ "version": "2.0.78",
4
4
  "description": "Fast automated code review CLI powered by SWC-based static analysis",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@swc/core": "^1.15.8",
49
49
  "@swc/wasm": "^1.15.8",
50
- "auto-cr-rules": "workspace:^",
50
+ "auto-cr-rules": "^2.0.76",
51
51
  "commander": "^14.0.2",
52
52
  "consola": "^3.4.2",
53
53
  "jsonc-parser": "^3.3.1",