@aiready/consistency 0.6.5 → 0.6.6
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 +10 -10
- package/.turbo/turbo-test.log +3 -3
- package/README.md +35 -5
- package/dist/chunk-WTBDNCEN.mjs +1352 -0
- package/dist/cli.js +29 -2
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +42 -397
- package/dist/index.mjs +6 -395
- package/package.json +1 -1
- package/src/analyzers/naming-ast.ts +4 -47
- package/src/analyzers/naming-constants.ts +107 -0
- package/src/analyzers/naming.ts +5 -95
- package/src/index.ts +2 -1
package/src/analyzers/naming.ts
CHANGED
|
@@ -1,78 +1,11 @@
|
|
|
1
1
|
import { readFileContent, loadConfig } from '@aiready/core';
|
|
2
2
|
import type { NamingIssue } from '../types';
|
|
3
3
|
import { dirname } from 'path';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'run', 'try', 'use', 'get', 'set', 'add', 'put', 'map', 'log', 'row', 'col',
|
|
10
|
-
'tab', 'box', 'div', 'nav', 'tag', 'any', 'all', 'one', 'two', 'out', 'off',
|
|
11
|
-
'on', 'yes', 'no', 'now', 'max', 'min', 'sum', 'avg', 'ref', 'src', 'dst',
|
|
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
|
-
'tax', 'cat', 'dog', 'car', 'bus', 'web', 'app', 'war', 'law', 'pay', 'buy',
|
|
15
|
-
'win', 'cut', 'hit', 'hot', 'pop', 'job', 'age', 'act', 'let', 'lot', 'bad',
|
|
16
|
-
'big', 'far', 'few', 'own', 'per', 'red', 'low', 'see', 'six', 'ten', 'way',
|
|
17
|
-
'who', 'why', 'yet', 'via', 'due', 'fee', 'fun', 'gas', 'gay', 'god', 'gun',
|
|
18
|
-
'guy', 'ice', 'ill', 'kid', 'mad', 'man', 'mix', 'mom', 'mrs', 'nor', 'odd',
|
|
19
|
-
'oil', 'pan', 'pet', 'pit', 'pot', 'pow', 'pro', 'raw', 'rep', 'rid', 'sad',
|
|
20
|
-
'sea', 'sit', 'sky', 'son', 'tea', 'tie', 'tip', 'van', 'war', 'win', 'won'
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
// Comprehensive list of acceptable abbreviations and acronyms
|
|
24
|
-
const ACCEPTABLE_ABBREVIATIONS = new Set([
|
|
25
|
-
// Standard identifiers
|
|
26
|
-
'id', 'uid', 'gid', 'pid',
|
|
27
|
-
// Loop counters and iterators
|
|
28
|
-
'i', 'j', 'k', 'n', 'm',
|
|
29
|
-
// Web/Network
|
|
30
|
-
'url', 'uri', 'api', 'cdn', 'dns', 'ip', 'tcp', 'udp', 'http', 'ssl', 'tls',
|
|
31
|
-
'utm', 'seo', 'rss', 'xhr', 'ajax', 'cors', 'ws', 'wss',
|
|
32
|
-
// Data formats
|
|
33
|
-
'json', 'xml', 'yaml', 'csv', 'html', 'css', 'svg', 'pdf',
|
|
34
|
-
// File types & extensions
|
|
35
|
-
'img', 'txt', 'doc', 'docx', 'xlsx', 'ppt', 'md', 'rst', 'jpg', 'png', 'gif',
|
|
36
|
-
// Databases
|
|
37
|
-
'db', 'sql', 'orm', 'dao', 'dto', 'ddb', 'rds', 'nosql',
|
|
38
|
-
// File system
|
|
39
|
-
'fs', 'dir', 'tmp', 'src', 'dst', 'bin', 'lib', 'pkg',
|
|
40
|
-
// Operating system
|
|
41
|
-
'os', 'env', 'arg', 'cli', 'cmd', 'exe', 'cwd', 'pwd',
|
|
42
|
-
// UI/UX
|
|
43
|
-
'ui', 'ux', 'gui', 'dom', 'ref',
|
|
44
|
-
// Request/Response
|
|
45
|
-
'req', 'res', 'ctx', 'err', 'msg', 'auth',
|
|
46
|
-
// Mathematics/Computing
|
|
47
|
-
'max', 'min', 'avg', 'sum', 'abs', 'cos', 'sin', 'tan', 'log', 'exp',
|
|
48
|
-
'pow', 'sqrt', 'std', 'var', 'int', 'num', 'idx',
|
|
49
|
-
// Time
|
|
50
|
-
'now', 'utc', 'tz', 'ms', 'sec', 'hr', 'min', 'yr', 'mo',
|
|
51
|
-
// Common patterns
|
|
52
|
-
'app', 'cfg', 'config', 'init', 'len', 'val', 'str', 'obj', 'arr',
|
|
53
|
-
'gen', 'def', 'raw', 'new', 'old', 'pre', 'post', 'sub', 'pub',
|
|
54
|
-
// Programming/Framework specific
|
|
55
|
-
'ts', 'js', 'jsx', 'tsx', 'py', 'rb', 'vue', 're', 'fn', 'fns', 'mod', 'opts', 'dev',
|
|
56
|
-
// Cloud/Infrastructure
|
|
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',
|
|
59
|
-
// Metrics/Performance
|
|
60
|
-
'fcp', 'lcp', 'cls', 'ttfb', 'tti', 'fid', 'fps', 'qps', 'rps', 'tps', 'wpm',
|
|
61
|
-
// Testing & i18n
|
|
62
|
-
'po', 'e2e', 'a11y', 'i18n', 'l10n', 'spy',
|
|
63
|
-
// Domain-specific abbreviations (context-aware)
|
|
64
|
-
'sk', 'fy', 'faq', 'og', 'seo', 'cta', 'roi', 'kpi', 'ttl', 'pct',
|
|
65
|
-
// Technical abbreviations
|
|
66
|
-
'mac', 'hex', 'esm', 'git', 'rec', 'loc', 'dup',
|
|
67
|
-
// Boolean helpers (these are intentional short names)
|
|
68
|
-
'is', 'has', 'can', 'did', 'was', 'are',
|
|
69
|
-
// Date/Time context (when in date contexts)
|
|
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'
|
|
75
|
-
]);
|
|
4
|
+
import {
|
|
5
|
+
COMMON_SHORT_WORDS,
|
|
6
|
+
ACCEPTABLE_ABBREVIATIONS,
|
|
7
|
+
snakeCaseToCamelCase,
|
|
8
|
+
} from './naming-constants';
|
|
76
9
|
|
|
77
10
|
/**
|
|
78
11
|
* Analyzes naming conventions and quality
|
|
@@ -364,26 +297,3 @@ function analyzeFileNaming(
|
|
|
364
297
|
|
|
365
298
|
return issues;
|
|
366
299
|
}
|
|
367
|
-
|
|
368
|
-
function snakeCaseToCamelCase(str: string): string {
|
|
369
|
-
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Detects naming convention patterns across the codebase
|
|
374
|
-
*/
|
|
375
|
-
export function detectNamingConventions(files: string[], allIssues: NamingIssue[]): {
|
|
376
|
-
dominantConvention: 'camelCase' | 'snake_case' | 'PascalCase' | 'mixed';
|
|
377
|
-
conventionScore: number;
|
|
378
|
-
} {
|
|
379
|
-
// Count conventions
|
|
380
|
-
const camelCaseCount = allIssues.filter(i => i.type === 'convention-mix').length;
|
|
381
|
-
const totalChecks = files.length * 10; // Rough estimate
|
|
382
|
-
|
|
383
|
-
if (camelCaseCount / totalChecks > 0.3) {
|
|
384
|
-
return { dominantConvention: 'mixed', conventionScore: 0.5 };
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// For TypeScript/JavaScript, default to camelCase
|
|
388
|
-
return { dominantConvention: 'camelCase', conventionScore: 0.9 };
|
|
389
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { analyzeConsistency } from './analyzer';
|
|
2
2
|
export { analyzeNamingAST } from './analyzers/naming-ast';
|
|
3
|
-
export { analyzeNaming
|
|
3
|
+
export { analyzeNaming } from './analyzers/naming'; // Legacy regex version
|
|
4
|
+
export { detectNamingConventions } from './analyzers/naming-constants';
|
|
4
5
|
export { analyzePatterns } from './analyzers/patterns';
|
|
5
6
|
export type {
|
|
6
7
|
ConsistencyOptions,
|