@aiready/consistency 0.3.3 → 0.3.5
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/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-test.log +19 -14
- package/README.md +55 -7
- package/dist/chunk-2BTBNG6X.mjs +814 -0
- package/dist/chunk-Q5XMWG33.mjs +661 -0
- package/dist/chunk-TLVLM3M5.mjs +771 -0
- package/dist/cli.js +358 -52
- package/dist/cli.mjs +1 -1
- package/dist/index.js +355 -49
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/__tests__/analyzer.test.ts +41 -1
- package/src/analyzers/naming.ts +250 -65
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/consistency@0.3.
|
|
3
|
+
> @aiready/consistency@0.3.5 build /Users/pengcao/projects/aiready/packages/consistency
|
|
4
4
|
> tsup src/index.ts src/cli.ts --format cjs,esm --dts
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2020
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mCJS[39m [1mdist/cli.js [22m[32m25.23 KB[39m
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m16.34 KB[39m
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in 79ms
|
|
15
|
-
[32mESM[39m [1mdist/chunk-LUAREV6A.mjs [22m[32m15.11 KB[39m
|
|
16
12
|
[32mESM[39m [1mdist/cli.mjs [22m[32m8.54 KB[39m
|
|
17
13
|
[32mESM[39m [1mdist/index.mjs [22m[32m220.00 B[39m
|
|
18
|
-
[32mESM[39m
|
|
14
|
+
[32mESM[39m [1mdist/chunk-2BTBNG6X.mjs [22m[32m21.88 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 70ms
|
|
16
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m32.02 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.js [22m[32m23.13 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 71ms
|
|
19
19
|
DTS Build start
|
|
20
|
-
DTS ⚡️ Build success in
|
|
20
|
+
DTS ⚡️ Build success in 683ms
|
|
21
21
|
DTS dist/cli.d.ts 20.00 B
|
|
22
22
|
DTS dist/index.d.ts 2.60 KB
|
|
23
23
|
DTS dist/cli.d.mts 20.00 B
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/consistency@0.3.
|
|
3
|
+
> @aiready/consistency@0.3.5 test /Users/pengcao/projects/aiready/packages/consistency
|
|
4
4
|
> vitest run
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
[1m[7m[36m RUN [39m[27m[22m [36mv2.1.9 [39m[90m/Users/pengcao/projects/aiready/packages/consistency[39m
|
|
8
8
|
|
|
9
|
-
[?25l
|
|
10
|
-
|
|
11
|
-
[90m·[39m should detect minimum severity filtering
|
|
12
|
-
[90m·[39m analyzeNaming[2m (5)[22m
|
|
9
|
+
[?25l [90m·[39m should detect minimum severity filtering
|
|
10
|
+
[90m·[39m analyzeNaming[2m (8)[22m
|
|
13
11
|
[90m·[39m should detect single letter variables
|
|
14
12
|
[90m·[39m should NOT flag acceptable abbreviations
|
|
13
|
+
[90m·[39m should NOT flag common short English words
|
|
15
14
|
[90m·[39m should detect snake_case in TypeScript files
|
|
16
15
|
[90m·[39m should detect unclear boolean names
|
|
17
16
|
[90m·[39m should allow common abbreviations
|
|
17
|
+
[90m·[39m should NOT flag multi-line arrow function parameters (Phase 3)
|
|
18
|
+
[90m·[39m should NOT flag short-lived comparison variables (Phase 3)
|
|
18
19
|
[90m·[39m analyzePatterns[2m (3)[22m
|
|
19
20
|
[90m·[39m should detect mixed error handling
|
|
20
21
|
[90m·[39m should detect mixed async patterns
|
|
@@ -26,15 +27,16 @@
|
|
|
26
27
|
[90m·[39m should generate relevant recommendations
|
|
27
28
|
[90m·[39m should suggest standardizing error handling
|
|
28
29
|
[90m·[39m should suggest using async/await consistently
|
|
29
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G
|
|
30
|
-
|
|
31
|
-
[32m✓[39m should detect minimum severity filtering
|
|
32
|
-
[32m✓[39m analyzeNaming[2m (5)[22m
|
|
30
|
+
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m should detect minimum severity filtering
|
|
31
|
+
[32m✓[39m analyzeNaming[2m (8)[22m
|
|
33
32
|
[32m✓[39m should detect single letter variables
|
|
34
33
|
[32m✓[39m should NOT flag acceptable abbreviations
|
|
34
|
+
[32m✓[39m should NOT flag common short English words
|
|
35
35
|
[32m✓[39m should detect snake_case in TypeScript files
|
|
36
36
|
[32m✓[39m should detect unclear boolean names
|
|
37
37
|
[32m✓[39m should allow common abbreviations
|
|
38
|
+
[32m✓[39m should NOT flag multi-line arrow function parameters (Phase 3)
|
|
39
|
+
[32m✓[39m should NOT flag short-lived comparison variables (Phase 3)
|
|
38
40
|
[32m✓[39m analyzePatterns[2m (3)[22m
|
|
39
41
|
[32m✓[39m should detect mixed error handling
|
|
40
42
|
[32m✓[39m should detect mixed async patterns
|
|
@@ -46,16 +48,19 @@
|
|
|
46
48
|
[32m✓[39m should generate relevant recommendations
|
|
47
49
|
[32m✓[39m should suggest standardizing error handling
|
|
48
50
|
[32m✓[39m should suggest using async/await consistently
|
|
49
|
-
[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/__tests__/[22manalyzer[2m.test.ts[22m[2m (
|
|
51
|
+
[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/__tests__/[22manalyzer[2m.test.ts[22m[2m (18)[22m
|
|
50
52
|
[32m✓[39m analyzeConsistency[2m (2)[22m
|
|
51
53
|
[32m✓[39m should analyze naming issues
|
|
52
54
|
[32m✓[39m should detect minimum severity filtering
|
|
53
|
-
[32m✓[39m analyzeNaming[2m (
|
|
55
|
+
[32m✓[39m analyzeNaming[2m (8)[22m
|
|
54
56
|
[32m✓[39m should detect single letter variables
|
|
55
57
|
[32m✓[39m should NOT flag acceptable abbreviations
|
|
58
|
+
[32m✓[39m should NOT flag common short English words
|
|
56
59
|
[32m✓[39m should detect snake_case in TypeScript files
|
|
57
60
|
[32m✓[39m should detect unclear boolean names
|
|
58
61
|
[32m✓[39m should allow common abbreviations
|
|
62
|
+
[32m✓[39m should NOT flag multi-line arrow function parameters (Phase 3)
|
|
63
|
+
[32m✓[39m should NOT flag short-lived comparison variables (Phase 3)
|
|
59
64
|
[32m✓[39m analyzePatterns[2m (3)[22m
|
|
60
65
|
[32m✓[39m should detect mixed error handling
|
|
61
66
|
[32m✓[39m should detect mixed async patterns
|
|
@@ -69,8 +74,8 @@
|
|
|
69
74
|
[32m✓[39m should suggest using async/await consistently
|
|
70
75
|
|
|
71
76
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
72
|
-
[2m Tests [22m [1m[
|
|
73
|
-
[2m Start at [22m
|
|
74
|
-
[2m Duration [22m
|
|
77
|
+
[2m Tests [22m [1m[32m18 passed[39m[22m[90m (18)[39m
|
|
78
|
+
[2m Start at [22m 18:28:56
|
|
79
|
+
[2m Duration [22m 729ms[2m (transform 144ms, setup 0ms, collect 339ms, tests 28ms, environment 0ms, prepare 61ms)[22m
|
|
75
80
|
|
|
76
81
|
[?25h[?25h
|
package/README.md
CHANGED
|
@@ -32,11 +32,15 @@ Inconsistent code patterns confuse AI models and reduce their effectiveness. Thi
|
|
|
32
32
|
- **Function naming** - Checks for action verbs while allowing factory patterns and descriptive names
|
|
33
33
|
|
|
34
34
|
**Smart Detection:** The tool understands context and won't flag:
|
|
35
|
-
- Common abbreviations (env, api, url, max, min, now, etc.)
|
|
35
|
+
- Common abbreviations (env, api, url, max, min, now, etc.) - 100+ built-in
|
|
36
36
|
- Boolean prefixes (is, has, can used as variables)
|
|
37
|
-
- Loop iterators in appropriate contexts
|
|
37
|
+
- Loop iterators (i, j, k) in appropriate contexts
|
|
38
|
+
- Arrow function parameters in callbacks (`.map(s => ...)`)
|
|
39
|
+
- Multi-line arrow functions (detects across 3-5 line context)
|
|
40
|
+
- Short-lived comparison variables (used within 5 lines)
|
|
38
41
|
- Factory/builder patterns
|
|
39
42
|
- Long descriptive function names
|
|
43
|
+
- Project-specific abbreviations via configuration
|
|
40
44
|
|
|
41
45
|
### 🔄 Pattern Consistency
|
|
42
46
|
- **Error handling strategies** - Detects mixed approaches (try-catch vs returns vs throws)
|
|
@@ -127,7 +131,7 @@ aiready-consistency ./src --output markdown --output-file custom-report.md
|
|
|
127
131
|
|
|
128
132
|
## 📝 Configuration File
|
|
129
133
|
|
|
130
|
-
Create `aiready.json` in your project root:
|
|
134
|
+
Create `.airreadyrc.json`, `aiready.json`, or `aiready.config.json` in your project root:
|
|
131
135
|
|
|
132
136
|
```json
|
|
133
137
|
{
|
|
@@ -139,7 +143,10 @@ Create `aiready.json` in your project root:
|
|
|
139
143
|
"consistency": {
|
|
140
144
|
"checkNaming": true,
|
|
141
145
|
"checkPatterns": true,
|
|
142
|
-
"minSeverity": "minor"
|
|
146
|
+
"minSeverity": "minor",
|
|
147
|
+
"acceptedAbbreviations": ["ses", "gst", "cdk"],
|
|
148
|
+
"shortWords": ["oak", "elm"],
|
|
149
|
+
"disableChecks": []
|
|
143
150
|
}
|
|
144
151
|
},
|
|
145
152
|
"output": {
|
|
@@ -155,17 +162,58 @@ Create `aiready.json` in your project root:
|
|
|
155
162
|
| `checkNaming` | boolean | `true` | Check naming conventions |
|
|
156
163
|
| `checkPatterns` | boolean | `true` | Check code pattern consistency |
|
|
157
164
|
| `minSeverity` | string | `'info'` | Filter: `'info'`, `'minor'`, `'major'`, `'critical'` |
|
|
165
|
+
| `acceptedAbbreviations` | string[] | `[]` | Custom abbreviations to accept (e.g., domain-specific terms) |
|
|
166
|
+
| `shortWords` | string[] | `[]` | Additional full English words to accept |
|
|
167
|
+
| `disableChecks` | string[] | `[]` | Disable specific checks: `'single-letter'`, `'abbreviation'`, `'convention-mix'`, `'unclear'`, `'poor-naming'` |
|
|
168
|
+
|
|
169
|
+
### Project-Specific Configuration Examples
|
|
170
|
+
|
|
171
|
+
**React/Next.js Projects:**
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"tools": {
|
|
175
|
+
"consistency": {
|
|
176
|
+
"acceptedAbbreviations": ["jsx", "tsx", "ref", "ctx", "req", "res"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**AWS/Cloud Projects:**
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"tools": {
|
|
186
|
+
"consistency": {
|
|
187
|
+
"acceptedAbbreviations": ["ses", "sns", "sqs", "ec2", "vpc", "iam"]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**E-commerce Projects:**
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"tools": {
|
|
197
|
+
"consistency": {
|
|
198
|
+
"acceptedAbbreviations": ["gst", "vat", "sku", "upc"],
|
|
199
|
+
"shortWords": ["tax", "buy", "pay", "cart"]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
158
204
|
|
|
159
205
|
### Acceptable Abbreviations
|
|
160
206
|
|
|
161
|
-
The tool recognizes
|
|
207
|
+
The tool recognizes 100+ standard abbreviations and won't flag them:
|
|
162
208
|
|
|
163
|
-
**Web/Network:** url, uri, api, cdn, dns, ip, http, utm, seo, xhr
|
|
209
|
+
**Web/Network:** url, uri, api, cdn, dns, ip, http, utm, seo, xhr, cors, ws, wss
|
|
164
210
|
**Data:** json, xml, yaml, csv, html, css, svg, pdf, dto, dao
|
|
165
211
|
**System:** env, os, fs, cli, tmp, src, dst, bin, lib, pkg
|
|
166
212
|
**Request/Response:** req, res, ctx, err, msg
|
|
167
213
|
**Math:** max, min, avg, sum, abs, cos, sin, log, sqrt
|
|
168
|
-
**Time:** now, utc, ms, sec
|
|
214
|
+
**Time:** now, utc, ms, sec, hr, yr, mo
|
|
215
|
+
**Loop Counters:** i, j, k, n, m
|
|
216
|
+
**Cloud/Infrastructure:** s3, ec2, sqs, sns, vpc, ami, iam, aws
|
|
169
217
|
**Common:** id, uid, db, sql, orm, ui, ux, dom, ref, val, str, obj, arr, cfg, init
|
|
170
218
|
|
|
171
219
|
See [naming.ts](src/analyzers/naming.ts) for the complete list.
|