@aiready/consistency 0.3.5 → 0.5.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/PHASE4-RESULTS.md +122 -0
- package/PHASE5-RESULTS.md +277 -0
- package/dist/chunk-CZUJTDNH.mjs +848 -0
- package/dist/chunk-TXHPUU7A.mjs +863 -0
- package/dist/cli.js +54 -5
- package/dist/cli.mjs +1 -1
- package/dist/index.js +54 -5
- package/dist/index.mjs +1 -1
- package/package.json +13 -12
- package/src/analyzers/naming.ts +34 -10
- package/.turbo/turbo-build.log +0 -24
- package/.turbo/turbo-test.log +0 -81
package/dist/cli.js
CHANGED
|
@@ -89,6 +89,13 @@ var COMMON_SHORT_WORDS = /* @__PURE__ */ new Set([
|
|
|
89
89
|
"tmp",
|
|
90
90
|
"ext",
|
|
91
91
|
"sep",
|
|
92
|
+
// Prepositions and conjunctions
|
|
93
|
+
"and",
|
|
94
|
+
"from",
|
|
95
|
+
"how",
|
|
96
|
+
"pad",
|
|
97
|
+
"bar",
|
|
98
|
+
"non",
|
|
92
99
|
// Additional full words commonly flagged
|
|
93
100
|
"tax",
|
|
94
101
|
"cat",
|
|
@@ -335,6 +342,17 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
335
342
|
"alb",
|
|
336
343
|
"nlb",
|
|
337
344
|
"aws",
|
|
345
|
+
"ses",
|
|
346
|
+
"gst",
|
|
347
|
+
"cdk",
|
|
348
|
+
"btn",
|
|
349
|
+
"buf",
|
|
350
|
+
"agg",
|
|
351
|
+
"ocr",
|
|
352
|
+
"ai",
|
|
353
|
+
"cf",
|
|
354
|
+
"cfn",
|
|
355
|
+
"ga",
|
|
338
356
|
// Metrics/Performance
|
|
339
357
|
"fcp",
|
|
340
358
|
"lcp",
|
|
@@ -346,12 +364,14 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
346
364
|
"qps",
|
|
347
365
|
"rps",
|
|
348
366
|
"tps",
|
|
367
|
+
"wpm",
|
|
349
368
|
// Testing & i18n
|
|
350
369
|
"po",
|
|
351
370
|
"e2e",
|
|
352
371
|
"a11y",
|
|
353
372
|
"i18n",
|
|
354
373
|
"l10n",
|
|
374
|
+
"spy",
|
|
355
375
|
// Domain-specific abbreviations (context-aware)
|
|
356
376
|
"sk",
|
|
357
377
|
"fy",
|
|
@@ -361,6 +381,16 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
361
381
|
"cta",
|
|
362
382
|
"roi",
|
|
363
383
|
"kpi",
|
|
384
|
+
"ttl",
|
|
385
|
+
"pct",
|
|
386
|
+
// Technical abbreviations
|
|
387
|
+
"mac",
|
|
388
|
+
"hex",
|
|
389
|
+
"esm",
|
|
390
|
+
"git",
|
|
391
|
+
"rec",
|
|
392
|
+
"loc",
|
|
393
|
+
"dup",
|
|
364
394
|
// Boolean helpers (these are intentional short names)
|
|
365
395
|
"is",
|
|
366
396
|
"has",
|
|
@@ -371,7 +401,18 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
371
401
|
// Date/Time context (when in date contexts)
|
|
372
402
|
"d",
|
|
373
403
|
"t",
|
|
374
|
-
"dt"
|
|
404
|
+
"dt",
|
|
405
|
+
// Coverage metrics (industry standard: statements/branches/functions/lines)
|
|
406
|
+
"s",
|
|
407
|
+
"b",
|
|
408
|
+
"f",
|
|
409
|
+
"l",
|
|
410
|
+
// Common media/content abbreviations
|
|
411
|
+
"vid",
|
|
412
|
+
"pic",
|
|
413
|
+
"img",
|
|
414
|
+
"doc",
|
|
415
|
+
"msg"
|
|
375
416
|
]);
|
|
376
417
|
async function analyzeNaming(files) {
|
|
377
418
|
const issues = [];
|
|
@@ -419,6 +460,10 @@ function analyzeFileNaming(file, content, customAbbreviations, customShortWords,
|
|
|
419
460
|
const singleLetterMatches = line.matchAll(/\b(?:const|let|var)\s+([a-hm-z])\s*=/gi);
|
|
420
461
|
for (const match of singleLetterMatches) {
|
|
421
462
|
const letter = match[1].toLowerCase();
|
|
463
|
+
const isCoverageContext = /coverage|summary|metrics|pct|percent/i.test(line) || /\.(?:statements|branches|functions|lines)\.pct/i.test(line);
|
|
464
|
+
if (isCoverageContext && ["s", "b", "f", "l"].includes(letter)) {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
422
467
|
const isInLoopContext = line.includes("for") || /\.(map|filter|forEach|reduce|find|some|every)\s*\(/.test(line) || line.includes("=>") || // Arrow function
|
|
423
468
|
/\w+\s*=>\s*/.test(line);
|
|
424
469
|
const isI18nContext = line.includes("useTranslation") || line.includes("i18n.t") || /\bt\s*\(['"]/.test(line);
|
|
@@ -523,14 +568,18 @@ function analyzeFileNaming(file, content, customAbbreviations, customShortWords,
|
|
|
523
568
|
if (isEntryPoint) {
|
|
524
569
|
continue;
|
|
525
570
|
}
|
|
526
|
-
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator)$/);
|
|
571
|
+
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator|Provider|Adapter|Mock)$/);
|
|
527
572
|
const isEventHandler = name.match(/^on[A-Z]/);
|
|
528
573
|
const isDescriptiveLong = name.length > 15;
|
|
529
|
-
const
|
|
574
|
+
const isReactHook = name.match(/^use[A-Z]/);
|
|
575
|
+
const isDescriptivePattern = name.match(/^(default|total|count|sum|avg|max|min|initial|current|previous|next)\w+/) || name.match(/\w+(Count|Total|Sum|Average|List|Map|Set|Config|Settings|Options|Props|Data|Info|Details|State|Status|Response|Result)$/);
|
|
576
|
+
const isHelperPattern = name.match(/^(to|from|with|without|for|as|into)\w+/) || // toMetadata, withLogger, forPath
|
|
577
|
+
name.match(/^\w+(To|From|With|Without|For|As|Into)\w*$/);
|
|
578
|
+
const isUtilityName = ["cn", "proxy", "sitemap", "robots", "gtag"].includes(name);
|
|
530
579
|
const capitalCount = (name.match(/[A-Z]/g) || []).length;
|
|
531
580
|
const isCompoundWord = capitalCount >= 3;
|
|
532
|
-
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount)/);
|
|
533
|
-
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isDescriptivePattern && !isCompoundWord) {
|
|
581
|
+
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount|track|store|persist|upsert|derive|classify|combine|discover|activate|require|assert|expect|mask|escape|sign|put|list|complete|page|safe|mock|pick|pluralize|text)/);
|
|
582
|
+
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isDescriptivePattern && !isCompoundWord && !isHelperPattern && !isUtilityName && !isReactHook) {
|
|
534
583
|
issues.push({
|
|
535
584
|
file,
|
|
536
585
|
line: lineNumber,
|
package/dist/cli.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -90,6 +90,13 @@ var COMMON_SHORT_WORDS = /* @__PURE__ */ new Set([
|
|
|
90
90
|
"tmp",
|
|
91
91
|
"ext",
|
|
92
92
|
"sep",
|
|
93
|
+
// Prepositions and conjunctions
|
|
94
|
+
"and",
|
|
95
|
+
"from",
|
|
96
|
+
"how",
|
|
97
|
+
"pad",
|
|
98
|
+
"bar",
|
|
99
|
+
"non",
|
|
93
100
|
// Additional full words commonly flagged
|
|
94
101
|
"tax",
|
|
95
102
|
"cat",
|
|
@@ -336,6 +343,17 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
336
343
|
"alb",
|
|
337
344
|
"nlb",
|
|
338
345
|
"aws",
|
|
346
|
+
"ses",
|
|
347
|
+
"gst",
|
|
348
|
+
"cdk",
|
|
349
|
+
"btn",
|
|
350
|
+
"buf",
|
|
351
|
+
"agg",
|
|
352
|
+
"ocr",
|
|
353
|
+
"ai",
|
|
354
|
+
"cf",
|
|
355
|
+
"cfn",
|
|
356
|
+
"ga",
|
|
339
357
|
// Metrics/Performance
|
|
340
358
|
"fcp",
|
|
341
359
|
"lcp",
|
|
@@ -347,12 +365,14 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
347
365
|
"qps",
|
|
348
366
|
"rps",
|
|
349
367
|
"tps",
|
|
368
|
+
"wpm",
|
|
350
369
|
// Testing & i18n
|
|
351
370
|
"po",
|
|
352
371
|
"e2e",
|
|
353
372
|
"a11y",
|
|
354
373
|
"i18n",
|
|
355
374
|
"l10n",
|
|
375
|
+
"spy",
|
|
356
376
|
// Domain-specific abbreviations (context-aware)
|
|
357
377
|
"sk",
|
|
358
378
|
"fy",
|
|
@@ -362,6 +382,16 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
362
382
|
"cta",
|
|
363
383
|
"roi",
|
|
364
384
|
"kpi",
|
|
385
|
+
"ttl",
|
|
386
|
+
"pct",
|
|
387
|
+
// Technical abbreviations
|
|
388
|
+
"mac",
|
|
389
|
+
"hex",
|
|
390
|
+
"esm",
|
|
391
|
+
"git",
|
|
392
|
+
"rec",
|
|
393
|
+
"loc",
|
|
394
|
+
"dup",
|
|
365
395
|
// Boolean helpers (these are intentional short names)
|
|
366
396
|
"is",
|
|
367
397
|
"has",
|
|
@@ -372,7 +402,18 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
|
372
402
|
// Date/Time context (when in date contexts)
|
|
373
403
|
"d",
|
|
374
404
|
"t",
|
|
375
|
-
"dt"
|
|
405
|
+
"dt",
|
|
406
|
+
// Coverage metrics (industry standard: statements/branches/functions/lines)
|
|
407
|
+
"s",
|
|
408
|
+
"b",
|
|
409
|
+
"f",
|
|
410
|
+
"l",
|
|
411
|
+
// Common media/content abbreviations
|
|
412
|
+
"vid",
|
|
413
|
+
"pic",
|
|
414
|
+
"img",
|
|
415
|
+
"doc",
|
|
416
|
+
"msg"
|
|
376
417
|
]);
|
|
377
418
|
async function analyzeNaming(files) {
|
|
378
419
|
const issues = [];
|
|
@@ -420,6 +461,10 @@ function analyzeFileNaming(file, content, customAbbreviations, customShortWords,
|
|
|
420
461
|
const singleLetterMatches = line.matchAll(/\b(?:const|let|var)\s+([a-hm-z])\s*=/gi);
|
|
421
462
|
for (const match of singleLetterMatches) {
|
|
422
463
|
const letter = match[1].toLowerCase();
|
|
464
|
+
const isCoverageContext = /coverage|summary|metrics|pct|percent/i.test(line) || /\.(?:statements|branches|functions|lines)\.pct/i.test(line);
|
|
465
|
+
if (isCoverageContext && ["s", "b", "f", "l"].includes(letter)) {
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
423
468
|
const isInLoopContext = line.includes("for") || /\.(map|filter|forEach|reduce|find|some|every)\s*\(/.test(line) || line.includes("=>") || // Arrow function
|
|
424
469
|
/\w+\s*=>\s*/.test(line);
|
|
425
470
|
const isI18nContext = line.includes("useTranslation") || line.includes("i18n.t") || /\bt\s*\(['"]/.test(line);
|
|
@@ -524,14 +569,18 @@ function analyzeFileNaming(file, content, customAbbreviations, customShortWords,
|
|
|
524
569
|
if (isEntryPoint) {
|
|
525
570
|
continue;
|
|
526
571
|
}
|
|
527
|
-
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator)$/);
|
|
572
|
+
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator|Provider|Adapter|Mock)$/);
|
|
528
573
|
const isEventHandler = name.match(/^on[A-Z]/);
|
|
529
574
|
const isDescriptiveLong = name.length > 15;
|
|
530
|
-
const
|
|
575
|
+
const isReactHook = name.match(/^use[A-Z]/);
|
|
576
|
+
const isDescriptivePattern = name.match(/^(default|total|count|sum|avg|max|min|initial|current|previous|next)\w+/) || name.match(/\w+(Count|Total|Sum|Average|List|Map|Set|Config|Settings|Options|Props|Data|Info|Details|State|Status|Response|Result)$/);
|
|
577
|
+
const isHelperPattern = name.match(/^(to|from|with|without|for|as|into)\w+/) || // toMetadata, withLogger, forPath
|
|
578
|
+
name.match(/^\w+(To|From|With|Without|For|As|Into)\w*$/);
|
|
579
|
+
const isUtilityName = ["cn", "proxy", "sitemap", "robots", "gtag"].includes(name);
|
|
531
580
|
const capitalCount = (name.match(/[A-Z]/g) || []).length;
|
|
532
581
|
const isCompoundWord = capitalCount >= 3;
|
|
533
|
-
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount)/);
|
|
534
|
-
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isDescriptivePattern && !isCompoundWord) {
|
|
582
|
+
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount|track|store|persist|upsert|derive|classify|combine|discover|activate|require|assert|expect|mask|escape|sign|put|list|complete|page|safe|mock|pick|pluralize|text)/);
|
|
583
|
+
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isDescriptivePattern && !isCompoundWord && !isHelperPattern && !isUtilityName && !isReactHook) {
|
|
535
584
|
issues.push({
|
|
536
585
|
file,
|
|
537
586
|
line: lineNumber,
|
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.5.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",
|
|
@@ -15,6 +15,15 @@
|
|
|
15
15
|
"import": "./dist/index.mjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts src/cli.ts --format cjs,esm --dts",
|
|
20
|
+
"dev": "tsup src/index.ts src/cli.ts --format cjs,esm --dts --watch",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"lint": "eslint src",
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"prepublishOnly": "pnpm build",
|
|
25
|
+
"release": "pnpm build && pnpm publish --no-git-checks"
|
|
26
|
+
},
|
|
18
27
|
"keywords": [
|
|
19
28
|
"aiready",
|
|
20
29
|
"consistency",
|
|
@@ -39,9 +48,9 @@
|
|
|
39
48
|
},
|
|
40
49
|
"homepage": "https://github.com/caopengau/aiready-consistency",
|
|
41
50
|
"dependencies": {
|
|
51
|
+
"@aiready/core": "workspace:*",
|
|
42
52
|
"chalk": "^5.3.0",
|
|
43
|
-
"commander": "^12.1.0"
|
|
44
|
-
"@aiready/core": "0.7.1"
|
|
53
|
+
"commander": "^12.1.0"
|
|
45
54
|
},
|
|
46
55
|
"devDependencies": {
|
|
47
56
|
"@types/node": "^22.10.5",
|
|
@@ -51,13 +60,5 @@
|
|
|
51
60
|
},
|
|
52
61
|
"engines": {
|
|
53
62
|
"node": ">=18.0.0"
|
|
54
|
-
},
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build": "tsup src/index.ts src/cli.ts --format cjs,esm --dts",
|
|
57
|
-
"dev": "tsup src/index.ts src/cli.ts --format cjs,esm --dts --watch",
|
|
58
|
-
"test": "vitest run",
|
|
59
|
-
"lint": "eslint src",
|
|
60
|
-
"clean": "rm -rf dist",
|
|
61
|
-
"release": "pnpm build && pnpm publish --no-git-checks"
|
|
62
63
|
}
|
|
63
|
-
}
|
|
64
|
+
}
|
package/src/analyzers/naming.ts
CHANGED
|
@@ -9,8 +9,8 @@ const COMMON_SHORT_WORDS = new Set([
|
|
|
9
9
|
'run', 'try', 'use', 'get', 'set', 'add', 'put', 'map', 'log', 'row', 'col',
|
|
10
10
|
'tab', 'box', 'div', 'nav', 'tag', 'any', 'all', 'one', 'two', 'out', 'off',
|
|
11
11
|
'on', 'yes', 'no', 'now', 'max', 'min', 'sum', 'avg', 'ref', 'src', 'dst',
|
|
12
|
-
'raw', 'def', 'sub', 'pub', 'pre', 'mid', 'alt', 'opt', 'tmp', 'ext', 'sep',
|
|
13
|
-
// Additional full words commonly flagged
|
|
12
|
+
'raw', 'def', 'sub', 'pub', 'pre', 'mid', 'alt', 'opt', 'tmp', 'ext', 'sep', // Prepositions and conjunctions
|
|
13
|
+
'and', 'from', 'how', 'pad', 'bar', 'non', // Additional full words commonly flagged
|
|
14
14
|
'tax', 'cat', 'dog', 'car', 'bus', 'web', 'app', 'war', 'law', 'pay', 'buy',
|
|
15
15
|
'win', 'cut', 'hit', 'hot', 'pop', 'job', 'age', 'act', 'let', 'lot', 'bad',
|
|
16
16
|
'big', 'far', 'few', 'own', 'per', 'red', 'low', 'see', 'six', 'ten', 'way',
|
|
@@ -55,16 +55,23 @@ const ACCEPTABLE_ABBREVIATIONS = new Set([
|
|
|
55
55
|
'ts', 'js', 'jsx', 'tsx', 'py', 'rb', 'vue', 're', 'fn', 'fns', 'mod', 'opts', 'dev',
|
|
56
56
|
// Cloud/Infrastructure
|
|
57
57
|
's3', 'ec2', 'sqs', 'sns', 'vpc', 'ami', 'iam', 'acl', 'elb', 'alb', 'nlb', 'aws',
|
|
58
|
+
'ses', 'gst', 'cdk', 'btn', 'buf', 'agg', 'ocr', 'ai', 'cf', 'cfn', 'ga',
|
|
58
59
|
// Metrics/Performance
|
|
59
|
-
'fcp', 'lcp', 'cls', 'ttfb', 'tti', 'fid', 'fps', 'qps', 'rps', 'tps',
|
|
60
|
+
'fcp', 'lcp', 'cls', 'ttfb', 'tti', 'fid', 'fps', 'qps', 'rps', 'tps', 'wpm',
|
|
60
61
|
// Testing & i18n
|
|
61
|
-
'po', 'e2e', 'a11y', 'i18n', 'l10n',
|
|
62
|
+
'po', 'e2e', 'a11y', 'i18n', 'l10n', 'spy',
|
|
62
63
|
// Domain-specific abbreviations (context-aware)
|
|
63
|
-
'sk', 'fy', 'faq', 'og', 'seo', 'cta', 'roi', 'kpi',
|
|
64
|
+
'sk', 'fy', 'faq', 'og', 'seo', 'cta', 'roi', 'kpi', 'ttl', 'pct',
|
|
65
|
+
// Technical abbreviations
|
|
66
|
+
'mac', 'hex', 'esm', 'git', 'rec', 'loc', 'dup',
|
|
64
67
|
// Boolean helpers (these are intentional short names)
|
|
65
68
|
'is', 'has', 'can', 'did', 'was', 'are',
|
|
66
69
|
// Date/Time context (when in date contexts)
|
|
67
|
-
'd', 't', 'dt'
|
|
70
|
+
'd', 't', 'dt',
|
|
71
|
+
// Coverage metrics (industry standard: statements/branches/functions/lines)
|
|
72
|
+
's', 'b', 'f', 'l',
|
|
73
|
+
// Common media/content abbreviations
|
|
74
|
+
'vid', 'pic', 'img', 'doc', 'msg'
|
|
68
75
|
]);
|
|
69
76
|
|
|
70
77
|
/**
|
|
@@ -153,6 +160,13 @@ function analyzeFileNaming(
|
|
|
153
160
|
for (const match of singleLetterMatches) {
|
|
154
161
|
const letter = match[1].toLowerCase();
|
|
155
162
|
|
|
163
|
+
// Coverage metrics context (s/b/f/l are standard for statements/branches/functions/lines)
|
|
164
|
+
const isCoverageContext = /coverage|summary|metrics|pct|percent/i.test(line) ||
|
|
165
|
+
/\.(?:statements|branches|functions|lines)\.pct/i.test(line);
|
|
166
|
+
if (isCoverageContext && ['s', 'b', 'f', 'l'].includes(letter)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
156
170
|
// Enhanced loop/iterator context detection
|
|
157
171
|
const isInLoopContext =
|
|
158
172
|
line.includes('for') ||
|
|
@@ -309,22 +323,32 @@ function analyzeFileNaming(
|
|
|
309
323
|
// 4. Descriptive aggregate/collection patterns
|
|
310
324
|
// 5. Very long descriptive names (>15 chars)
|
|
311
325
|
// 6. Compound words with 3+ capitals
|
|
326
|
+
// 7. Helper/utility functions (common patterns)
|
|
327
|
+
// 8. React hooks (useX pattern)
|
|
312
328
|
|
|
313
|
-
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator)$/);
|
|
329
|
+
const isFactoryPattern = name.match(/(Factory|Builder|Creator|Generator|Provider|Adapter|Mock)$/);
|
|
314
330
|
const isEventHandler = name.match(/^on[A-Z]/);
|
|
315
331
|
const isDescriptiveLong = name.length > 15; // Reduced from 20 to 15
|
|
332
|
+
const isReactHook = name.match(/^use[A-Z]/); // React hooks
|
|
316
333
|
|
|
317
334
|
// Check for descriptive patterns
|
|
318
335
|
const isDescriptivePattern = name.match(/^(default|total|count|sum|avg|max|min|initial|current|previous|next)\w+/) ||
|
|
319
|
-
name.match(/\w+(Count|Total|Sum|Average|List|Map|Set|Config|Settings|Options|Props)$/);
|
|
336
|
+
name.match(/\w+(Count|Total|Sum|Average|List|Map|Set|Config|Settings|Options|Props|Data|Info|Details|State|Status|Response|Result)$/);
|
|
337
|
+
|
|
338
|
+
// Helper/utility function patterns
|
|
339
|
+
const isHelperPattern = name.match(/^(to|from|with|without|for|as|into)\w+/) || // toMetadata, withLogger, forPath
|
|
340
|
+
name.match(/^\w+(To|From|With|Without|For|As|Into)\w*$/); // metadataTo, pathFrom
|
|
341
|
+
|
|
342
|
+
// Common utility names that are descriptive
|
|
343
|
+
const isUtilityName = ['cn', 'proxy', 'sitemap', 'robots', 'gtag'].includes(name);
|
|
320
344
|
|
|
321
345
|
// Count capital letters for compound detection
|
|
322
346
|
const capitalCount = (name.match(/[A-Z]/g) || []).length;
|
|
323
347
|
const isCompoundWord = capitalCount >= 3; // daysSinceLastCommit has 4 capitals
|
|
324
348
|
|
|
325
|
-
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount)/);
|
|
349
|
+
const hasActionVerb = name.match(/^(get|set|is|has|can|should|create|update|delete|fetch|load|save|process|handle|validate|check|find|search|filter|map|reduce|make|do|run|start|stop|build|parse|format|render|calculate|compute|generate|transform|convert|normalize|sanitize|encode|decode|compress|extract|merge|split|join|sort|compare|test|verify|ensure|apply|execute|invoke|call|emit|dispatch|trigger|listen|subscribe|unsubscribe|add|remove|clear|reset|toggle|enable|disable|open|close|connect|disconnect|send|receive|read|write|import|export|register|unregister|mount|unmount|track|store|persist|upsert|derive|classify|combine|discover|activate|require|assert|expect|mask|escape|sign|put|list|complete|page|safe|mock|pick|pluralize|text)/);
|
|
326
350
|
|
|
327
|
-
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isDescriptivePattern && !isCompoundWord) {
|
|
351
|
+
if (!hasActionVerb && !isFactoryPattern && !isEventHandler && !isDescriptiveLong && !isDescriptivePattern && !isCompoundWord && !isHelperPattern && !isUtilityName && !isReactHook) {
|
|
328
352
|
issues.push({
|
|
329
353
|
file,
|
|
330
354
|
line: lineNumber,
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
7
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
-
[34mCLI[39m tsup v8.5.1
|
|
9
|
-
[34mCLI[39m Target: es2020
|
|
10
|
-
[34mCJS[39m Build start
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/cli.mjs [22m[32m8.54 KB[39m
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m220.00 B[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
|
-
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
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> @aiready/consistency@0.3.5 test /Users/pengcao/projects/aiready/packages/consistency
|
|
4
|
-
> vitest run
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[1m[7m[36m RUN [39m[27m[22m [36mv2.1.9 [39m[90m/Users/pengcao/projects/aiready/packages/consistency[39m
|
|
8
|
-
|
|
9
|
-
[?25l [90m·[39m should detect minimum severity filtering
|
|
10
|
-
[90m·[39m analyzeNaming[2m (8)[22m
|
|
11
|
-
[90m·[39m should detect single letter variables
|
|
12
|
-
[90m·[39m should NOT flag acceptable abbreviations
|
|
13
|
-
[90m·[39m should NOT flag common short English words
|
|
14
|
-
[90m·[39m should detect snake_case in TypeScript files
|
|
15
|
-
[90m·[39m should detect unclear boolean names
|
|
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)
|
|
19
|
-
[90m·[39m analyzePatterns[2m (3)[22m
|
|
20
|
-
[90m·[39m should detect mixed error handling
|
|
21
|
-
[90m·[39m should detect mixed async patterns
|
|
22
|
-
[90m·[39m should detect mixed import styles
|
|
23
|
-
[90m·[39m consistency scoring[2m (2)[22m
|
|
24
|
-
[90m·[39m should calculate consistency score correctly
|
|
25
|
-
[90m·[39m should weight critical issues more than info
|
|
26
|
-
[90m·[39m recommendations[2m (3)[22m
|
|
27
|
-
[90m·[39m should generate relevant recommendations
|
|
28
|
-
[90m·[39m should suggest standardizing error handling
|
|
29
|
-
[90m·[39m should suggest using async/await consistently
|
|
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
|
|
32
|
-
[32m✓[39m should detect single letter variables
|
|
33
|
-
[32m✓[39m should NOT flag acceptable abbreviations
|
|
34
|
-
[32m✓[39m should NOT flag common short English words
|
|
35
|
-
[32m✓[39m should detect snake_case in TypeScript files
|
|
36
|
-
[32m✓[39m should detect unclear boolean names
|
|
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)
|
|
40
|
-
[32m✓[39m analyzePatterns[2m (3)[22m
|
|
41
|
-
[32m✓[39m should detect mixed error handling
|
|
42
|
-
[32m✓[39m should detect mixed async patterns
|
|
43
|
-
[32m✓[39m should detect mixed import styles
|
|
44
|
-
[32m✓[39m consistency scoring[2m (2)[22m
|
|
45
|
-
[32m✓[39m should calculate consistency score correctly
|
|
46
|
-
[32m✓[39m should weight critical issues more than info
|
|
47
|
-
[32m✓[39m recommendations[2m (3)[22m
|
|
48
|
-
[32m✓[39m should generate relevant recommendations
|
|
49
|
-
[32m✓[39m should suggest standardizing error handling
|
|
50
|
-
[32m✓[39m should suggest using async/await consistently
|
|
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
|
|
52
|
-
[32m✓[39m analyzeConsistency[2m (2)[22m
|
|
53
|
-
[32m✓[39m should analyze naming issues
|
|
54
|
-
[32m✓[39m should detect minimum severity filtering
|
|
55
|
-
[32m✓[39m analyzeNaming[2m (8)[22m
|
|
56
|
-
[32m✓[39m should detect single letter variables
|
|
57
|
-
[32m✓[39m should NOT flag acceptable abbreviations
|
|
58
|
-
[32m✓[39m should NOT flag common short English words
|
|
59
|
-
[32m✓[39m should detect snake_case in TypeScript files
|
|
60
|
-
[32m✓[39m should detect unclear boolean names
|
|
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)
|
|
64
|
-
[32m✓[39m analyzePatterns[2m (3)[22m
|
|
65
|
-
[32m✓[39m should detect mixed error handling
|
|
66
|
-
[32m✓[39m should detect mixed async patterns
|
|
67
|
-
[32m✓[39m should detect mixed import styles
|
|
68
|
-
[32m✓[39m consistency scoring[2m (2)[22m
|
|
69
|
-
[32m✓[39m should calculate consistency score correctly
|
|
70
|
-
[32m✓[39m should weight critical issues more than info
|
|
71
|
-
[32m✓[39m recommendations[2m (3)[22m
|
|
72
|
-
[32m✓[39m should generate relevant recommendations
|
|
73
|
-
[32m✓[39m should suggest standardizing error handling
|
|
74
|
-
[32m✓[39m should suggest using async/await consistently
|
|
75
|
-
|
|
76
|
-
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
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
|
|
80
|
-
|
|
81
|
-
[?25h[?25h
|