@aiready/consistency 0.20.22 → 0.21.0
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 +8 -8
- package/.turbo/turbo-test.log +16 -14
- package/coverage/clover.xml +452 -470
- package/coverage/coverage-final.json +7 -7
- package/coverage/index.html +26 -26
- package/coverage/src/analyzer.ts.html +126 -186
- package/coverage/src/analyzers/index.html +23 -23
- package/coverage/src/analyzers/naming-ast.ts.html +175 -169
- package/coverage/src/analyzers/naming-constants.ts.html +1 -1
- package/coverage/src/analyzers/naming-generalized.ts.html +63 -51
- package/coverage/src/analyzers/naming.ts.html +1 -1
- package/coverage/src/analyzers/patterns.ts.html +1 -1
- package/coverage/src/index.html +19 -19
- package/coverage/src/index.ts.html +1 -1
- package/coverage/src/provider.ts.html +1 -1
- package/coverage/src/scoring.ts.html +32 -32
- package/coverage/src/utils/ast-parser.ts.html +39 -39
- package/coverage/src/utils/config-loader.ts.html +1 -1
- package/coverage/src/utils/context-detector.ts.html +115 -115
- package/coverage/src/utils/index.html +1 -1
- package/coverage/src/utils/scope-tracker.ts.html +21 -21
- package/dist/chunk-YHHXE2JX.mjs +912 -0
- package/dist/cli.js +4 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.js +4 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/__tests__/analyzer.test.ts +52 -0
- package/src/analyzers/naming-generalized.ts +10 -6
package/dist/cli.js
CHANGED
|
@@ -577,7 +577,10 @@ async function analyzeNamingGeneralized(files) {
|
|
|
577
577
|
"HEAD"
|
|
578
578
|
].includes(exp.name))
|
|
579
579
|
continue;
|
|
580
|
-
|
|
580
|
+
if (conventions.constantPattern.test(exp.name) || conventions.variablePattern.test(exp.name)) {
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
pattern = conventions.constantPattern;
|
|
581
584
|
} else {
|
|
582
585
|
pattern = conventions.variablePattern;
|
|
583
586
|
}
|
package/dist/cli.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -585,7 +585,10 @@ async function analyzeNamingGeneralized(files) {
|
|
|
585
585
|
"HEAD"
|
|
586
586
|
].includes(exp.name))
|
|
587
587
|
continue;
|
|
588
|
-
|
|
588
|
+
if (conventions.constantPattern.test(exp.name) || conventions.variablePattern.test(exp.name)) {
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
pattern = conventions.constantPattern;
|
|
589
592
|
} else {
|
|
590
593
|
pattern = conventions.variablePattern;
|
|
591
594
|
}
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/consistency",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Detects consistency issues in naming, patterns, and architecture that confuse AI models",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@typescript-eslint/typescript-estree": "^8.53.0",
|
|
44
44
|
"chalk": "^5.3.0",
|
|
45
45
|
"commander": "^14.0.0",
|
|
46
|
-
"@aiready/core": "0.
|
|
46
|
+
"@aiready/core": "0.24.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^24.0.0",
|
|
@@ -212,6 +212,58 @@ describe('consistency scoring', () => {
|
|
|
212
212
|
});
|
|
213
213
|
});
|
|
214
214
|
|
|
215
|
+
describe('naming-generalized const naming', () => {
|
|
216
|
+
it('should allow SCREAMING_SNAKE_CASE for non-primitive constants', () => {
|
|
217
|
+
// This test verifies the fix that allows SCREAMING_SNAKE_CASE for all exported constants,
|
|
218
|
+
// not just primitives. Constants like SKILL_CONFIG, SECTION_MAP, BUILD_DIR should be valid.
|
|
219
|
+
const validConstantNames = [
|
|
220
|
+
'SKILL_CONFIG',
|
|
221
|
+
'SECTION_MAP',
|
|
222
|
+
'BUILD_DIR',
|
|
223
|
+
'API_ENDPOINT',
|
|
224
|
+
'DEFAULT_OPTIONS',
|
|
225
|
+
'MAX_RETRIES',
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
// SCREAMING_SNAKE_CASE should match the constant pattern
|
|
229
|
+
const constantPattern = /^[A-Z][A-Z0-9_]*$/;
|
|
230
|
+
for (const name of validConstantNames) {
|
|
231
|
+
expect(constantPattern.test(name)).toBe(true);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('should allow camelCase for non-primitive constants', () => {
|
|
236
|
+
// camelCase should also be valid for constants (e.g., logger, githubTools)
|
|
237
|
+
const validCamelCaseNames = [
|
|
238
|
+
'logger',
|
|
239
|
+
'githubTools',
|
|
240
|
+
'config',
|
|
241
|
+
'defaultOptions',
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
const variablePattern = /^[a-z][a-zA-Z0-9]*$/;
|
|
245
|
+
for (const name of validCamelCaseNames) {
|
|
246
|
+
expect(variablePattern.test(name)).toBe(true);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should NOT flag SCREAMING_SNAKE_CASE constants as naming issues', async () => {
|
|
251
|
+
// After the fix, SCREAMING_SNAKE_CASE constants should not generate naming issues
|
|
252
|
+
const report = await analyzeConsistency({
|
|
253
|
+
rootDir: './src',
|
|
254
|
+
checkNaming: true,
|
|
255
|
+
checkPatterns: false,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Check that naming issues are reduced after the fix
|
|
259
|
+
const namingIssues = report.summary.namingIssues;
|
|
260
|
+
|
|
261
|
+
// There should be fewer naming issues after the fix (was 105, now ~55)
|
|
262
|
+
// This is a sanity check that the fix is working
|
|
263
|
+
expect(namingIssues).toBeLessThan(100);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
215
267
|
describe('recommendations', () => {
|
|
216
268
|
it('should generate relevant recommendations', async () => {
|
|
217
269
|
const report = await analyzeConsistency({
|
|
@@ -112,12 +112,16 @@ export async function analyzeNamingGeneralized(
|
|
|
112
112
|
)
|
|
113
113
|
continue;
|
|
114
114
|
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
// Allow both SCREAMING_SNAKE_CASE and camelCase for exported constants.
|
|
116
|
+
// Module-level constants (config objects, paths, etc.) often use SCREAMING_SNAKE_CASE
|
|
117
|
+
// which is a valid convention for constants, regardless of whether they are primitives.
|
|
118
|
+
if (
|
|
119
|
+
conventions.constantPattern.test(exp.name) ||
|
|
120
|
+
conventions.variablePattern.test(exp.name)
|
|
121
|
+
) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
pattern = conventions.constantPattern;
|
|
121
125
|
} else {
|
|
122
126
|
pattern = conventions.variablePattern;
|
|
123
127
|
}
|