@aiready/consistency 0.6.4 → 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/dist/index.js CHANGED
@@ -459,8 +459,9 @@ function isAcceptableInContext(name, context, options) {
459
459
  return false;
460
460
  }
461
461
 
462
- // src/analyzers/naming-ast.ts
462
+ // src/analyzers/naming-constants.ts
463
463
  var COMMON_SHORT_WORDS = /* @__PURE__ */ new Set([
464
+ // Full English words (1-3 letters)
464
465
  "day",
465
466
  "key",
466
467
  "net",
@@ -516,12 +517,14 @@ var COMMON_SHORT_WORDS = /* @__PURE__ */ new Set([
516
517
  "tmp",
517
518
  "ext",
518
519
  "sep",
520
+ // Prepositions and conjunctions
519
521
  "and",
520
522
  "from",
521
523
  "how",
522
524
  "pad",
523
525
  "bar",
524
526
  "non",
527
+ // Additional full words commonly flagged
525
528
  "tax",
526
529
  "cat",
527
530
  "dog",
@@ -601,15 +604,18 @@ var COMMON_SHORT_WORDS = /* @__PURE__ */ new Set([
601
604
  "won"
602
605
  ]);
603
606
  var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
607
+ // Standard identifiers
604
608
  "id",
605
609
  "uid",
606
610
  "gid",
607
611
  "pid",
612
+ // Loop counters and iterators
608
613
  "i",
609
614
  "j",
610
615
  "k",
611
616
  "n",
612
617
  "m",
618
+ // Web/Network
613
619
  "url",
614
620
  "uri",
615
621
  "api",
@@ -629,6 +635,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
629
635
  "cors",
630
636
  "ws",
631
637
  "wss",
638
+ // Data formats
632
639
  "json",
633
640
  "xml",
634
641
  "yaml",
@@ -637,6 +644,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
637
644
  "css",
638
645
  "svg",
639
646
  "pdf",
647
+ // File types & extensions
640
648
  "img",
641
649
  "txt",
642
650
  "doc",
@@ -648,6 +656,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
648
656
  "jpg",
649
657
  "png",
650
658
  "gif",
659
+ // Databases
651
660
  "db",
652
661
  "sql",
653
662
  "orm",
@@ -656,6 +665,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
656
665
  "ddb",
657
666
  "rds",
658
667
  "nosql",
668
+ // File system
659
669
  "fs",
660
670
  "dir",
661
671
  "tmp",
@@ -664,6 +674,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
664
674
  "bin",
665
675
  "lib",
666
676
  "pkg",
677
+ // Operating system
667
678
  "os",
668
679
  "env",
669
680
  "arg",
@@ -672,17 +683,20 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
672
683
  "exe",
673
684
  "cwd",
674
685
  "pwd",
686
+ // UI/UX
675
687
  "ui",
676
688
  "ux",
677
689
  "gui",
678
690
  "dom",
679
691
  "ref",
692
+ // Request/Response
680
693
  "req",
681
694
  "res",
682
695
  "ctx",
683
696
  "err",
684
697
  "msg",
685
698
  "auth",
699
+ // Mathematics/Computing
686
700
  "max",
687
701
  "min",
688
702
  "avg",
@@ -700,6 +714,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
700
714
  "int",
701
715
  "num",
702
716
  "idx",
717
+ // Time
703
718
  "now",
704
719
  "utc",
705
720
  "tz",
@@ -709,6 +724,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
709
724
  "min",
710
725
  "yr",
711
726
  "mo",
727
+ // Common patterns
712
728
  "app",
713
729
  "cfg",
714
730
  "config",
@@ -727,6 +743,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
727
743
  "post",
728
744
  "sub",
729
745
  "pub",
746
+ // Programming/Framework specific
730
747
  "ts",
731
748
  "js",
732
749
  "jsx",
@@ -740,6 +757,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
740
757
  "mod",
741
758
  "opts",
742
759
  "dev",
760
+ // Cloud/Infrastructure
743
761
  "s3",
744
762
  "ec2",
745
763
  "sqs",
@@ -763,6 +781,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
763
781
  "cf",
764
782
  "cfn",
765
783
  "ga",
784
+ // Metrics/Performance
766
785
  "fcp",
767
786
  "lcp",
768
787
  "cls",
@@ -774,12 +793,14 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
774
793
  "rps",
775
794
  "tps",
776
795
  "wpm",
796
+ // Testing & i18n
777
797
  "po",
778
798
  "e2e",
779
799
  "a11y",
780
800
  "i18n",
781
801
  "l10n",
782
802
  "spy",
803
+ // Domain-specific abbreviations (context-aware)
783
804
  "sk",
784
805
  "fy",
785
806
  "faq",
@@ -790,6 +811,7 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
790
811
  "kpi",
791
812
  "ttl",
792
813
  "pct",
814
+ // Technical abbreviations
793
815
  "mac",
794
816
  "hex",
795
817
  "esm",
@@ -797,26 +819,42 @@ var ACCEPTABLE_ABBREVIATIONS = /* @__PURE__ */ new Set([
797
819
  "rec",
798
820
  "loc",
799
821
  "dup",
822
+ // Boolean helpers (these are intentional short names)
800
823
  "is",
801
824
  "has",
802
825
  "can",
803
826
  "did",
804
827
  "was",
805
828
  "are",
829
+ // Date/Time context (when in date contexts)
806
830
  "d",
807
831
  "t",
808
832
  "dt",
833
+ // Coverage metrics (industry standard: statements/branches/functions/lines)
809
834
  "s",
810
835
  "b",
811
836
  "f",
812
837
  "l",
813
- // Coverage metrics
838
+ // Common media/content abbreviations
814
839
  "vid",
815
840
  "pic",
816
841
  "img",
817
842
  "doc",
818
843
  "msg"
819
844
  ]);
845
+ function snakeCaseToCamelCase(str) {
846
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
847
+ }
848
+ function detectNamingConventions(files, allIssues) {
849
+ const camelCaseCount = allIssues.filter((i) => i.type === "convention-mix").length;
850
+ const totalChecks = files.length * 10;
851
+ if (camelCaseCount / totalChecks > 0.3) {
852
+ return { dominantConvention: "mixed", conventionScore: 0.5 };
853
+ }
854
+ return { dominantConvention: "camelCase", conventionScore: 0.9 };
855
+ }
856
+
857
+ // src/analyzers/naming-ast.ts
820
858
  async function analyzeNamingAST(files) {
821
859
  const issues = [];
822
860
  const rootDir = files.length > 0 ? (0, import_path.dirname)(files[0]) : process.cwd();
@@ -1338,388 +1376,6 @@ function generateRecommendations(namingIssues, patternIssues) {
1338
1376
  // src/analyzers/naming.ts
1339
1377
  var import_core4 = require("@aiready/core");
1340
1378
  var import_path2 = require("path");
1341
- var COMMON_SHORT_WORDS2 = /* @__PURE__ */ new Set([
1342
- // Full English words (1-3 letters)
1343
- "day",
1344
- "key",
1345
- "net",
1346
- "to",
1347
- "go",
1348
- "for",
1349
- "not",
1350
- "new",
1351
- "old",
1352
- "top",
1353
- "end",
1354
- "run",
1355
- "try",
1356
- "use",
1357
- "get",
1358
- "set",
1359
- "add",
1360
- "put",
1361
- "map",
1362
- "log",
1363
- "row",
1364
- "col",
1365
- "tab",
1366
- "box",
1367
- "div",
1368
- "nav",
1369
- "tag",
1370
- "any",
1371
- "all",
1372
- "one",
1373
- "two",
1374
- "out",
1375
- "off",
1376
- "on",
1377
- "yes",
1378
- "no",
1379
- "now",
1380
- "max",
1381
- "min",
1382
- "sum",
1383
- "avg",
1384
- "ref",
1385
- "src",
1386
- "dst",
1387
- "raw",
1388
- "def",
1389
- "sub",
1390
- "pub",
1391
- "pre",
1392
- "mid",
1393
- "alt",
1394
- "opt",
1395
- "tmp",
1396
- "ext",
1397
- "sep",
1398
- // Prepositions and conjunctions
1399
- "and",
1400
- "from",
1401
- "how",
1402
- "pad",
1403
- "bar",
1404
- "non",
1405
- // Additional full words commonly flagged
1406
- "tax",
1407
- "cat",
1408
- "dog",
1409
- "car",
1410
- "bus",
1411
- "web",
1412
- "app",
1413
- "war",
1414
- "law",
1415
- "pay",
1416
- "buy",
1417
- "win",
1418
- "cut",
1419
- "hit",
1420
- "hot",
1421
- "pop",
1422
- "job",
1423
- "age",
1424
- "act",
1425
- "let",
1426
- "lot",
1427
- "bad",
1428
- "big",
1429
- "far",
1430
- "few",
1431
- "own",
1432
- "per",
1433
- "red",
1434
- "low",
1435
- "see",
1436
- "six",
1437
- "ten",
1438
- "way",
1439
- "who",
1440
- "why",
1441
- "yet",
1442
- "via",
1443
- "due",
1444
- "fee",
1445
- "fun",
1446
- "gas",
1447
- "gay",
1448
- "god",
1449
- "gun",
1450
- "guy",
1451
- "ice",
1452
- "ill",
1453
- "kid",
1454
- "mad",
1455
- "man",
1456
- "mix",
1457
- "mom",
1458
- "mrs",
1459
- "nor",
1460
- "odd",
1461
- "oil",
1462
- "pan",
1463
- "pet",
1464
- "pit",
1465
- "pot",
1466
- "pow",
1467
- "pro",
1468
- "raw",
1469
- "rep",
1470
- "rid",
1471
- "sad",
1472
- "sea",
1473
- "sit",
1474
- "sky",
1475
- "son",
1476
- "tea",
1477
- "tie",
1478
- "tip",
1479
- "van",
1480
- "war",
1481
- "win",
1482
- "won"
1483
- ]);
1484
- var ACCEPTABLE_ABBREVIATIONS2 = /* @__PURE__ */ new Set([
1485
- // Standard identifiers
1486
- "id",
1487
- "uid",
1488
- "gid",
1489
- "pid",
1490
- // Loop counters and iterators
1491
- "i",
1492
- "j",
1493
- "k",
1494
- "n",
1495
- "m",
1496
- // Web/Network
1497
- "url",
1498
- "uri",
1499
- "api",
1500
- "cdn",
1501
- "dns",
1502
- "ip",
1503
- "tcp",
1504
- "udp",
1505
- "http",
1506
- "ssl",
1507
- "tls",
1508
- "utm",
1509
- "seo",
1510
- "rss",
1511
- "xhr",
1512
- "ajax",
1513
- "cors",
1514
- "ws",
1515
- "wss",
1516
- // Data formats
1517
- "json",
1518
- "xml",
1519
- "yaml",
1520
- "csv",
1521
- "html",
1522
- "css",
1523
- "svg",
1524
- "pdf",
1525
- // File types & extensions
1526
- "img",
1527
- "txt",
1528
- "doc",
1529
- "docx",
1530
- "xlsx",
1531
- "ppt",
1532
- "md",
1533
- "rst",
1534
- "jpg",
1535
- "png",
1536
- "gif",
1537
- // Databases
1538
- "db",
1539
- "sql",
1540
- "orm",
1541
- "dao",
1542
- "dto",
1543
- "ddb",
1544
- "rds",
1545
- "nosql",
1546
- // File system
1547
- "fs",
1548
- "dir",
1549
- "tmp",
1550
- "src",
1551
- "dst",
1552
- "bin",
1553
- "lib",
1554
- "pkg",
1555
- // Operating system
1556
- "os",
1557
- "env",
1558
- "arg",
1559
- "cli",
1560
- "cmd",
1561
- "exe",
1562
- "cwd",
1563
- "pwd",
1564
- // UI/UX
1565
- "ui",
1566
- "ux",
1567
- "gui",
1568
- "dom",
1569
- "ref",
1570
- // Request/Response
1571
- "req",
1572
- "res",
1573
- "ctx",
1574
- "err",
1575
- "msg",
1576
- "auth",
1577
- // Mathematics/Computing
1578
- "max",
1579
- "min",
1580
- "avg",
1581
- "sum",
1582
- "abs",
1583
- "cos",
1584
- "sin",
1585
- "tan",
1586
- "log",
1587
- "exp",
1588
- "pow",
1589
- "sqrt",
1590
- "std",
1591
- "var",
1592
- "int",
1593
- "num",
1594
- "idx",
1595
- // Time
1596
- "now",
1597
- "utc",
1598
- "tz",
1599
- "ms",
1600
- "sec",
1601
- "hr",
1602
- "min",
1603
- "yr",
1604
- "mo",
1605
- // Common patterns
1606
- "app",
1607
- "cfg",
1608
- "config",
1609
- "init",
1610
- "len",
1611
- "val",
1612
- "str",
1613
- "obj",
1614
- "arr",
1615
- "gen",
1616
- "def",
1617
- "raw",
1618
- "new",
1619
- "old",
1620
- "pre",
1621
- "post",
1622
- "sub",
1623
- "pub",
1624
- // Programming/Framework specific
1625
- "ts",
1626
- "js",
1627
- "jsx",
1628
- "tsx",
1629
- "py",
1630
- "rb",
1631
- "vue",
1632
- "re",
1633
- "fn",
1634
- "fns",
1635
- "mod",
1636
- "opts",
1637
- "dev",
1638
- // Cloud/Infrastructure
1639
- "s3",
1640
- "ec2",
1641
- "sqs",
1642
- "sns",
1643
- "vpc",
1644
- "ami",
1645
- "iam",
1646
- "acl",
1647
- "elb",
1648
- "alb",
1649
- "nlb",
1650
- "aws",
1651
- "ses",
1652
- "gst",
1653
- "cdk",
1654
- "btn",
1655
- "buf",
1656
- "agg",
1657
- "ocr",
1658
- "ai",
1659
- "cf",
1660
- "cfn",
1661
- "ga",
1662
- // Metrics/Performance
1663
- "fcp",
1664
- "lcp",
1665
- "cls",
1666
- "ttfb",
1667
- "tti",
1668
- "fid",
1669
- "fps",
1670
- "qps",
1671
- "rps",
1672
- "tps",
1673
- "wpm",
1674
- // Testing & i18n
1675
- "po",
1676
- "e2e",
1677
- "a11y",
1678
- "i18n",
1679
- "l10n",
1680
- "spy",
1681
- // Domain-specific abbreviations (context-aware)
1682
- "sk",
1683
- "fy",
1684
- "faq",
1685
- "og",
1686
- "seo",
1687
- "cta",
1688
- "roi",
1689
- "kpi",
1690
- "ttl",
1691
- "pct",
1692
- // Technical abbreviations
1693
- "mac",
1694
- "hex",
1695
- "esm",
1696
- "git",
1697
- "rec",
1698
- "loc",
1699
- "dup",
1700
- // Boolean helpers (these are intentional short names)
1701
- "is",
1702
- "has",
1703
- "can",
1704
- "did",
1705
- "was",
1706
- "are",
1707
- // Date/Time context (when in date contexts)
1708
- "d",
1709
- "t",
1710
- "dt",
1711
- // Coverage metrics (industry standard: statements/branches/functions/lines)
1712
- "s",
1713
- "b",
1714
- "f",
1715
- "l",
1716
- // Common media/content abbreviations
1717
- "vid",
1718
- "pic",
1719
- "img",
1720
- "doc",
1721
- "msg"
1722
- ]);
1723
1379
  async function analyzeNaming(files) {
1724
1380
  const issues = [];
1725
1381
  const rootDir = files.length > 0 ? (0, import_path2.dirname)(files[0]) : process.cwd();
@@ -1739,8 +1395,8 @@ function analyzeFileNaming(file, content, customAbbreviations, customShortWords,
1739
1395
  const issues = [];
1740
1396
  const isTestFile = file.match(/\.(test|spec)\.(ts|tsx|js|jsx)$/);
1741
1397
  const lines = content.split("\n");
1742
- const allAbbreviations = /* @__PURE__ */ new Set([...ACCEPTABLE_ABBREVIATIONS2, ...customAbbreviations]);
1743
- const allShortWords = /* @__PURE__ */ new Set([...COMMON_SHORT_WORDS2, ...customShortWords]);
1398
+ const allAbbreviations = /* @__PURE__ */ new Set([...ACCEPTABLE_ABBREVIATIONS, ...customAbbreviations]);
1399
+ const allShortWords = /* @__PURE__ */ new Set([...COMMON_SHORT_WORDS, ...customShortWords]);
1744
1400
  const getContextWindow = (index, windowSize = 3) => {
1745
1401
  const start = Math.max(0, index - windowSize);
1746
1402
  const end = Math.min(lines.length, index + windowSize + 1);
@@ -1900,17 +1556,6 @@ function analyzeFileNaming(file, content, customAbbreviations, customShortWords,
1900
1556
  });
1901
1557
  return issues;
1902
1558
  }
1903
- function snakeCaseToCamelCase(str) {
1904
- return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
1905
- }
1906
- function detectNamingConventions(files, allIssues) {
1907
- const camelCaseCount = allIssues.filter((i) => i.type === "convention-mix").length;
1908
- const totalChecks = files.length * 10;
1909
- if (camelCaseCount / totalChecks > 0.3) {
1910
- return { dominantConvention: "mixed", conventionScore: 0.5 };
1911
- }
1912
- return { dominantConvention: "camelCase", conventionScore: 0.9 };
1913
- }
1914
1559
  // Annotate the CommonJS export names for ESM import in node:
1915
1560
  0 && (module.exports = {
1916
1561
  analyzeConsistency,