@aiready/consistency 0.3.4 → 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.
@@ -0,0 +1,24 @@
1
+
2
+ 
3
+ > @aiready/consistency@0.3.5 build /Users/pengcao/projects/aiready/packages/consistency
4
+ > tsup src/index.ts src/cli.ts --format cjs,esm --dts
5
+
6
+ CLI Building entry: src/cli.ts, src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.5.1
9
+ CLI Target: es2020
10
+ CJS Build start
11
+ ESM Build start
12
+ ESM dist/cli.mjs 8.54 KB
13
+ ESM dist/index.mjs 220.00 B
14
+ ESM dist/chunk-2BTBNG6X.mjs 21.88 KB
15
+ ESM ⚡️ Build success in 70ms
16
+ CJS dist/cli.js 32.02 KB
17
+ CJS dist/index.js 23.13 KB
18
+ CJS ⚡️ Build success in 71ms
19
+ DTS Build start
20
+ DTS ⚡️ Build success in 683ms
21
+ DTS dist/cli.d.ts 20.00 B
22
+ DTS dist/index.d.ts 2.60 KB
23
+ DTS dist/cli.d.mts 20.00 B
24
+ DTS dist/index.d.mts 2.60 KB
@@ -0,0 +1,81 @@
1
+
2
+ 
3
+ > @aiready/consistency@0.3.5 test /Users/pengcao/projects/aiready/packages/consistency
4
+ > vitest run
5
+
6
+
7
+  RUN  v2.1.9 /Users/pengcao/projects/aiready/packages/consistency
8
+
9
+ [?25l · should detect minimum severity filtering
10
+ · analyzeNaming (8)
11
+ · should detect single letter variables
12
+ · should NOT flag acceptable abbreviations
13
+ · should NOT flag common short English words
14
+ · should detect snake_case in TypeScript files
15
+ · should detect unclear boolean names
16
+ · should allow common abbreviations
17
+ · should NOT flag multi-line arrow function parameters (Phase 3)
18
+ · should NOT flag short-lived comparison variables (Phase 3)
19
+ · analyzePatterns (3)
20
+ · should detect mixed error handling
21
+ · should detect mixed async patterns
22
+ · should detect mixed import styles
23
+ · consistency scoring (2)
24
+ · should calculate consistency score correctly
25
+ · should weight critical issues more than info
26
+ · recommendations (3)
27
+ · should generate relevant recommendations
28
+ · should suggest standardizing error handling
29
+ · should suggest using async/await consistently
30
+ [?25l ✓ should detect minimum severity filtering
31
+ ✓ analyzeNaming (8)
32
+ ✓ should detect single letter variables
33
+ ✓ should NOT flag acceptable abbreviations
34
+ ✓ should NOT flag common short English words
35
+ ✓ should detect snake_case in TypeScript files
36
+ ✓ should detect unclear boolean names
37
+ ✓ should allow common abbreviations
38
+ ✓ should NOT flag multi-line arrow function parameters (Phase 3)
39
+ ✓ should NOT flag short-lived comparison variables (Phase 3)
40
+ ✓ analyzePatterns (3)
41
+ ✓ should detect mixed error handling
42
+ ✓ should detect mixed async patterns
43
+ ✓ should detect mixed import styles
44
+ ✓ consistency scoring (2)
45
+ ✓ should calculate consistency score correctly
46
+ ✓ should weight critical issues more than info
47
+ ✓ recommendations (3)
48
+ ✓ should generate relevant recommendations
49
+ ✓ should suggest standardizing error handling
50
+ ✓ should suggest using async/await consistently
51
+  ✓ src/__tests__/analyzer.test.ts (18)
52
+ ✓ analyzeConsistency (2)
53
+ ✓ should analyze naming issues
54
+ ✓ should detect minimum severity filtering
55
+ ✓ analyzeNaming (8)
56
+ ✓ should detect single letter variables
57
+ ✓ should NOT flag acceptable abbreviations
58
+ ✓ should NOT flag common short English words
59
+ ✓ should detect snake_case in TypeScript files
60
+ ✓ should detect unclear boolean names
61
+ ✓ should allow common abbreviations
62
+ ✓ should NOT flag multi-line arrow function parameters (Phase 3)
63
+ ✓ should NOT flag short-lived comparison variables (Phase 3)
64
+ ✓ analyzePatterns (3)
65
+ ✓ should detect mixed error handling
66
+ ✓ should detect mixed async patterns
67
+ ✓ should detect mixed import styles
68
+ ✓ consistency scoring (2)
69
+ ✓ should calculate consistency score correctly
70
+ ✓ should weight critical issues more than info
71
+ ✓ recommendations (3)
72
+ ✓ should generate relevant recommendations
73
+ ✓ should suggest standardizing error handling
74
+ ✓ should suggest using async/await consistently
75
+
76
+  Test Files  1 passed (1)
77
+  Tests  18 passed (18)
78
+  Start at  18:28:56
79
+  Duration  729ms (transform 144ms, setup 0ms, collect 339ms, tests 28ms, environment 0ms, prepare 61ms)
80
+
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 60+ standard abbreviations and won't flag them:
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.