auto-cr-cmd 2.0.66 → 2.0.71

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/config.js +29 -1
  2. package/package.json +12 -11
package/dist/config.js CHANGED
@@ -18,6 +18,7 @@ exports.setTsConfigPath = setTsConfigPath;
18
18
  exports.loadParseOptions = loadParseOptions;
19
19
  var fs_1 = __importDefault(require("fs"));
20
20
  var path_1 = __importDefault(require("path"));
21
+ var jsonc_parser_1 = require("jsonc-parser");
21
22
  var i18n_1 = require("./i18n");
22
23
  var consola_1 = __importDefault(require("consola"));
23
24
  var cachedTsConfig;
@@ -26,6 +27,22 @@ function setTsConfigPath(path) {
26
27
  tsConfigPathOverride = path ? path : null;
27
28
  cachedTsConfig = undefined;
28
29
  }
30
+ function getLineAndColumn(text, offset) {
31
+ var prefix = text.slice(0, offset);
32
+ var lines = prefix.split(/\r?\n/);
33
+ var line = lines.length;
34
+ var column = lines[lines.length - 1].length + 1;
35
+ return { line: line, column: column };
36
+ }
37
+ function formatParseErrors(errors, content) {
38
+ return errors
39
+ .map(function (_a) {
40
+ var error = _a.error, offset = _a.offset;
41
+ var _b = getLineAndColumn(content, offset), line = _b.line, column = _b.column;
42
+ return "".concat((0, jsonc_parser_1.printParseErrorCode)(error), " at ").concat(line, ":").concat(column);
43
+ })
44
+ .join('; ');
45
+ }
29
46
  function readTsConfig() {
30
47
  if (cachedTsConfig !== undefined) {
31
48
  return cachedTsConfig;
@@ -37,7 +54,18 @@ function readTsConfig() {
37
54
  }
38
55
  try {
39
56
  var raw = fs_1.default.readFileSync(tsConfigPath, 'utf-8');
40
- cachedTsConfig = JSON.parse(raw);
57
+ var errors = [];
58
+ var parsed = (0, jsonc_parser_1.parse)(raw, errors, {
59
+ allowTrailingComma: true,
60
+ disallowComments: false,
61
+ });
62
+ if (errors.length > 0) {
63
+ cachedTsConfig = null;
64
+ var t = (0, i18n_1.getTranslator)();
65
+ consola_1.default.warn(t.tsconfigReadFailed(), formatParseErrors(errors, raw));
66
+ return cachedTsConfig;
67
+ }
68
+ cachedTsConfig = parsed;
41
69
  }
42
70
  catch (error) {
43
71
  cachedTsConfig = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-cr-cmd",
3
- "version": "2.0.66",
3
+ "version": "2.0.71",
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",
@@ -45,26 +45,27 @@
45
45
  },
46
46
  "sideEffects": false,
47
47
  "dependencies": {
48
- "@swc/core": "^1.13.20",
49
- "@swc/wasm": "^1.14.0",
50
- "auto-cr-rules": "^2.0.66",
51
- "commander": "^14.0.0",
48
+ "@swc/core": "^1.15.8",
49
+ "@swc/wasm": "^1.15.8",
50
+ "auto-cr-rules": "^2.0.71",
51
+ "commander": "^14.0.2",
52
52
  "consola": "^3.4.2",
53
+ "jsonc-parser": "^3.3.1",
53
54
  "picomatch": "^4.0.3"
54
55
  },
55
56
  "devDependencies": {
56
- "@eslint/js": "^9.38.0",
57
+ "@eslint/js": "^9.39.2",
57
58
  "@swc/types": "^0.1.25",
58
- "@types/node": "^24.9.2",
59
+ "@types/node": "^25.0.3",
59
60
  "@types/picomatch": "^4.0.2",
60
- "eslint": "^9.38.0",
61
+ "eslint": "^9.39.2",
61
62
  "eslint-plugin-prettier": "^5.5.4",
62
- "globals": "^16.3.0",
63
+ "globals": "^17.0.0",
63
64
  "jiti": "^2.5.1",
64
- "prettier": "^3.6.2",
65
+ "prettier": "^3.7.4",
65
66
  "ts-node": "^10.9.2",
66
67
  "tslib": "^2.8.1",
67
68
  "typescript": "^5.9.2",
68
- "typescript-eslint": "^8.46.2"
69
+ "typescript-eslint": "^8.51.0"
69
70
  }
70
71
  }