@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/dist/cli.js CHANGED
@@ -577,7 +577,10 @@ async function analyzeNamingGeneralized(files) {
577
577
  "HEAD"
578
578
  ].includes(exp.name))
579
579
  continue;
580
- pattern = exp.isPrimitive ? conventions.constantPattern : conventions.variablePattern;
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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  analyzeConsistency
4
- } from "./chunk-CLWNLHDB.mjs";
4
+ } from "./chunk-YHHXE2JX.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
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
- pattern = exp.isPrimitive ? conventions.constantPattern : conventions.variablePattern;
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
@@ -3,7 +3,7 @@ import {
3
3
  analyzeNamingAST,
4
4
  analyzePatterns,
5
5
  calculateConsistencyScore
6
- } from "./chunk-CLWNLHDB.mjs";
6
+ } from "./chunk-YHHXE2JX.mjs";
7
7
 
8
8
  // src/index.ts
9
9
  import { ToolRegistry } from "@aiready/core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/consistency",
3
- "version": "0.20.22",
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.23.23"
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
- // Only enforce SCREAMING_SNAKE_CASE for primitive constants (strings, numbers,
116
- // booleans). Object literals, class instances, and tool definitions are
117
- // camelCase by convention (e.g. `logger`, `githubTools`, `RemediationSwarm`).
118
- pattern = exp.isPrimitive
119
- ? conventions.constantPattern
120
- : conventions.variablePattern;
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
  }