auto-cr-rules 2.0.64 → 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.
package/README.md CHANGED
@@ -43,6 +43,9 @@ Common flags:
43
43
  - `--language <zh|en>`: Switch CLI output language (defaults to auto-detection).
44
44
  - `--rule-dir <directory>`: Load additional custom rules from a directory or package.
45
45
  - `--output <text|json>`: Choose between human-friendly text logs or structured JSON results (defaults to `text`).
46
+ - `--config <path>`: Point to a `.autocrrc.json` or `.autocrrc.js` file to enable/disable rules.
47
+ - `--ignore-path <path>`: Point to a `.autocrignore.json` or `.autocrignore.js` file to exclude files/directories from scanning.
48
+ - `--tsconfig <path>`: Use a custom `tsconfig.json` (defaults to `<cwd>/tsconfig.json`).
46
49
  - `--help`: Display the full command reference.
47
50
 
48
51
  Sample output:
@@ -108,6 +111,45 @@ npx auto-cr-cmd --output json -- ./src | jq
108
111
  }
109
112
  ```
110
113
 
114
+ ## Configuration (.autocrrc)
115
+
116
+ - Place `.autocrrc.json` or `.autocrrc.js` in your repo root (search order as listed). Use `--config <path>` to point elsewhere.
117
+ - `rules` accepts `off | warning | error | optimizing | true/false | 0/1/2`; unspecified rules keep their default severity.
118
+
119
+ ```jsonc
120
+ // .autocrrc.json
121
+ {
122
+ "rules": {
123
+ "no-deep-relative-imports": "error",
124
+ "no-swallowed-errors": "off"
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### Ignore paths (.autocrignore)
130
+
131
+ - Place `.autocrignore.json` or `.autocrignore.js` in repo root (search order as listed), or pass `--ignore-path <file>`.
132
+ - Supports glob patterns (picomatch) via JSON/JS arrays (`{ ignore: [...] }`).
133
+
134
+ ```js
135
+ // .autocrignore.js
136
+ module.exports = {
137
+ ignore: ['node_modules', 'dist/**', '**/*.test.ts', 'public/**']
138
+ }
139
+ ```
140
+
141
+ ```json
142
+ // .autocrignore.json
143
+ {
144
+ "ignore": [
145
+ "node_modules",
146
+ "dist/**",
147
+ "**/*.test.ts",
148
+ "public/**"
149
+ ]
150
+ }
151
+ ```
152
+
111
153
  ## Writing Custom Rules
112
154
 
113
155
  The CLI consumes rules from the `auto-cr-rules` package by default, and you can extend it with your own logic.
package/README.zh-CN.md CHANGED
@@ -43,6 +43,9 @@ npx auto-cr-cmd --language zh [需要扫描的代码目录]
43
43
  - `--language <zh|en>`:切换 CLI 输出语言(默认为自动检测)。
44
44
  - `--rule-dir <directory>`:加载额外的自定义规则目录或包。
45
45
  - `--output <text|json>`:选择输出格式,`text` 为友好的终端日志,`json` 用于集成脚本(默认为 `text`)。
46
+ - `--config <path>`:指定 `.autocrrc.json` 或 `.autocrrc.js` 配置文件路径,用于开启/关闭规则。
47
+ - `--ignore-path <path>`:指定 `.autocrignore.json` 或 `.autocrignore.js` 忽略文件路径,用于排除扫描。
48
+ - `--tsconfig <path>`:指定自定义 `tsconfig.json` 路径(默认读取 `<cwd>/tsconfig.json`)。
46
49
  - `--help`:查看完整命令说明。
47
50
 
48
51
  示例输出:
@@ -108,6 +111,55 @@ npx auto-cr-cmd --output json -- ./src | jq
108
111
  }
109
112
  ```
110
113
 
114
+ ## 配置(.autocrrc)
115
+
116
+ - 在仓库根目录放置 `.autocrrc.json` 或 `.autocrrc.js`(按此顺序查找);如需放在其他位置,可通过 `--config <path>` 指定。
117
+ - `rules` 支持的值:`off | warning | error | optimizing | true/false | 0/1/2`,未写明的规则沿用默认严重级别。
118
+
119
+ ```jsonc
120
+ // .autocrrc.json
121
+ {
122
+ "rules": {
123
+ "no-deep-relative-imports": "error",
124
+ "no-swallowed-errors": "off"
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### 忽略文件(.autocrignore)
130
+
131
+ - 在仓库根目录放置 `.autocrignore.json` 或 `.autocrignore.js`(按此顺序查找),或通过 `--ignore-path <file>` 指定自定义路径。
132
+ - 仅支持 JSON/JS 写法,基于 picomatch 的 glob 模式,数组键为 `ignore`。
133
+
134
+ ```js
135
+ // .autocrignore.js
136
+ module.exports = {
137
+ ignore: ['node_modules', 'dist/**', '**/*.test.ts', 'public/**']
138
+ }
139
+ ```
140
+
141
+ ```json
142
+ // .autocrignore.json
143
+ {
144
+ "ignore": [
145
+ "node_modules",
146
+ "dist/**",
147
+ "**/*.test.ts",
148
+ "public/**"
149
+ ]
150
+ }
151
+ ```
152
+
153
+ ```js
154
+ // .autocrrc.js
155
+ module.exports = {
156
+ rules: {
157
+ 'no-swallowed-errors': 'warning', // 覆盖严重级别
158
+ 'no-deep-relative-imports': true // 保持规则默认严重级别
159
+ }
160
+ }
161
+ ```
162
+
111
163
  ## 编写自定义规则
112
164
 
113
165
  CLI 默认使用 `auto-cr-rules` 包提供的规则,你也可以扩展自己的逻辑。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-cr-rules",
3
- "version": "2.0.64",
3
+ "version": "2.0.71",
4
4
  "description": "Extensible static analysis rule set for the auto-cr automated code review toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",