@hyphaene/hexa-ts-kit 1.12.0 → 1.12.1
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.
|
@@ -2412,7 +2412,12 @@ var ALLOWED_SPECIAL_FILES = ["index.ts", "openapi.ts"];
|
|
|
2412
2412
|
function parseFile(filePath) {
|
|
2413
2413
|
try {
|
|
2414
2414
|
const content = readFileSync4(filePath, "utf-8");
|
|
2415
|
-
return parse3(content, {
|
|
2415
|
+
return parse3(content, {
|
|
2416
|
+
loc: true,
|
|
2417
|
+
range: true,
|
|
2418
|
+
comment: true,
|
|
2419
|
+
jsx: false
|
|
2420
|
+
});
|
|
2416
2421
|
} catch {
|
|
2417
2422
|
return null;
|
|
2418
2423
|
}
|
|
@@ -2429,6 +2434,12 @@ function getExportedNames(ast) {
|
|
|
2429
2434
|
for (const decl of node.declaration.declarations) {
|
|
2430
2435
|
if (decl.id.type === "Identifier") {
|
|
2431
2436
|
names.push(decl.id.name);
|
|
2437
|
+
} else if (decl.id.type === "ObjectPattern") {
|
|
2438
|
+
for (const prop of decl.id.properties) {
|
|
2439
|
+
if (prop.type === "Property" && prop.value.type === "Identifier") {
|
|
2440
|
+
names.push(prop.value.name);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2432
2443
|
}
|
|
2433
2444
|
}
|
|
2434
2445
|
}
|
|
@@ -2467,7 +2478,9 @@ function hasZodInferTypeExport(content) {
|
|
|
2467
2478
|
return /export\s+type\s+\w+\s*=\s*z\.infer/.test(content);
|
|
2468
2479
|
}
|
|
2469
2480
|
function hasZodDataSchemas(content) {
|
|
2470
|
-
return /(?:const|let|var)\s+\w+\s*=\s*z\.(?:object|enum|array)\s*\(/.test(
|
|
2481
|
+
return /(?:const|let|var)\s+\w+\s*=\s*z\.(?:object|enum|array)\s*\(/.test(
|
|
2482
|
+
content
|
|
2483
|
+
);
|
|
2471
2484
|
}
|
|
2472
2485
|
function getExportsWithoutDeprecatedJsdoc(ast, content) {
|
|
2473
2486
|
const missingDeprecated = [];
|
|
@@ -2503,7 +2516,8 @@ function getNonReexportStatements(ast) {
|
|
|
2503
2516
|
if (node.type === "ImportDeclaration") continue;
|
|
2504
2517
|
if (node.type === "ExportAllDeclaration") continue;
|
|
2505
2518
|
if (node.type === "ExportNamedDeclaration" && node.source) continue;
|
|
2506
|
-
if (node.type === "ExportNamedDeclaration" && node.exportKind === "type" && node.source)
|
|
2519
|
+
if (node.type === "ExportNamedDeclaration" && node.exportKind === "type" && node.source)
|
|
2520
|
+
continue;
|
|
2507
2521
|
violations.push(node);
|
|
2508
2522
|
}
|
|
2509
2523
|
return violations;
|
|
@@ -2523,7 +2537,9 @@ async function checkEnumBundleRules(cwd) {
|
|
|
2523
2537
|
const fileName = basename5(file, ".enum-bundle.ts");
|
|
2524
2538
|
const upperName = fileName.replace(/[^a-zA-Z0-9]/g, "_").toUpperCase();
|
|
2525
2539
|
const hasSchema = exportedNames.some((n) => n.endsWith("Schema"));
|
|
2526
|
-
const hasEnumMapper = exportedNames.some(
|
|
2540
|
+
const hasEnumMapper = exportedNames.some(
|
|
2541
|
+
(n) => n === n.toUpperCase() && n.length > 1
|
|
2542
|
+
);
|
|
2527
2543
|
const hasValues = exportedNames.some((n) => n.endsWith("_VALUES"));
|
|
2528
2544
|
if (!hasSchema || !hasEnumMapper || !hasValues) {
|
|
2529
2545
|
const missing = [];
|
|
@@ -2733,12 +2749,19 @@ async function checkNamingRules(cwd) {
|
|
|
2733
2749
|
const results = [];
|
|
2734
2750
|
const files = await fg9("src/**/*.ts", {
|
|
2735
2751
|
cwd,
|
|
2736
|
-
ignore: [
|
|
2752
|
+
ignore: [
|
|
2753
|
+
"**/node_modules/**",
|
|
2754
|
+
"**/dist/**",
|
|
2755
|
+
"**/lib/**",
|
|
2756
|
+
"**/__tests__/**"
|
|
2757
|
+
]
|
|
2737
2758
|
});
|
|
2738
2759
|
for (const file of files) {
|
|
2739
2760
|
const fileName = basename5(file);
|
|
2740
2761
|
if (ALLOWED_SPECIAL_FILES.includes(fileName)) continue;
|
|
2741
|
-
const matchesSuffix = ALLOWED_SUFFIXES.some(
|
|
2762
|
+
const matchesSuffix = ALLOWED_SUFFIXES.some(
|
|
2763
|
+
(suffix) => fileName.endsWith(suffix)
|
|
2764
|
+
);
|
|
2742
2765
|
if (!matchesSuffix) {
|
|
2743
2766
|
results.push({
|
|
2744
2767
|
ruleId: "CTR-NAMING-001",
|
package/dist/cli.js
CHANGED
package/dist/mcp-server.js
CHANGED