pasika 0.10.46 → 0.10.48
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/eslint/pasika/index.js +38 -55
- package/package.json +1 -1
|
@@ -3363,14 +3363,6 @@ var httpErrorUsageRule = {
|
|
|
3363
3363
|
// eslint/rules/husky/husky-hook.ts
|
|
3364
3364
|
import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
|
|
3365
3365
|
import path28 from "path";
|
|
3366
|
-
var VITEST_CONFIG_NAMES = [
|
|
3367
|
-
"vitest.config.ts",
|
|
3368
|
-
"vitest.config.mts",
|
|
3369
|
-
"vitest.config.cts",
|
|
3370
|
-
"vitest.config.js",
|
|
3371
|
-
"vitest.config.mjs",
|
|
3372
|
-
"vitest.config.cjs"
|
|
3373
|
-
];
|
|
3374
3366
|
function memberName(member) {
|
|
3375
3367
|
return member.name.type === "String" ? member.name.value : member.name.name;
|
|
3376
3368
|
}
|
|
@@ -3379,7 +3371,7 @@ var huskyHookRule = {
|
|
|
3379
3371
|
schema: [],
|
|
3380
3372
|
type: "problem",
|
|
3381
3373
|
docs: {
|
|
3382
|
-
description: "Require a pre-commit hook that runs lint-staged, typecheck, coverage
|
|
3374
|
+
description: "Require a pre-commit hook that runs lint-staged, typecheck, coverage, suppression pruning, and the libyear drift check."
|
|
3383
3375
|
}
|
|
3384
3376
|
},
|
|
3385
3377
|
create(context) {
|
|
@@ -3412,17 +3404,6 @@ var huskyHookRule = {
|
|
|
3412
3404
|
}
|
|
3413
3405
|
requireNamedScript("typecheck");
|
|
3414
3406
|
requireNamedScript("test:unit:coverage");
|
|
3415
|
-
const vitestConfigName = VITEST_CONFIG_NAMES.find((name) => existsSync4(path28.join(context.cwd, name)));
|
|
3416
|
-
if (vitestConfigName !== void 0) {
|
|
3417
|
-
const coverageIndex = content.indexOf("npm run test:unit:coverage");
|
|
3418
|
-
const localAddIndex = content.indexOf(`git add ${vitestConfigName}`);
|
|
3419
|
-
if (localAddIndex <= coverageIndex) {
|
|
3420
|
-
context.report({
|
|
3421
|
-
node,
|
|
3422
|
-
message: `.husky/pre-commit must stage an auto-updated ${vitestConfigName} after coverage.`
|
|
3423
|
-
});
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
3407
|
if (!content.includes("libyear --limit-major-individual=1")) {
|
|
3427
3408
|
context.report({ node, message: ".husky/pre-commit must run npx libyear --limit-major-individual=1." });
|
|
3428
3409
|
}
|
|
@@ -3485,14 +3466,11 @@ function relativeSpecifier(filename, resolvedPath) {
|
|
|
3485
3466
|
function aliasSpecifier(sourceRoot, resolvedPath) {
|
|
3486
3467
|
return `@/${(sourceSegments(sourceRoot, resolvedPath) ?? []).join("/")}`;
|
|
3487
3468
|
}
|
|
3488
|
-
function
|
|
3489
|
-
return specifier.
|
|
3469
|
+
function parentTraversalCount(specifier) {
|
|
3470
|
+
return specifier.split("/").filter((segment) => segment === "..").length;
|
|
3490
3471
|
}
|
|
3491
|
-
function
|
|
3492
|
-
return
|
|
3493
|
-
}
|
|
3494
|
-
function prefersRelative(sourceRoot, filename, resolvedPath) {
|
|
3495
|
-
return segmentCount(relativeSpecifier(filename, resolvedPath)) <= segmentCount(aliasSpecifier(sourceRoot, resolvedPath));
|
|
3472
|
+
function prefersRelative(filename, resolvedPath) {
|
|
3473
|
+
return parentTraversalCount(relativeSpecifier(filename, resolvedPath)) <= 1;
|
|
3496
3474
|
}
|
|
3497
3475
|
var importBoundariesRule = {
|
|
3498
3476
|
meta: {
|
|
@@ -3536,23 +3514,17 @@ var importBoundariesRule = {
|
|
|
3536
3514
|
}
|
|
3537
3515
|
const relativeForm = relativeSpecifier(filename, resolvedPath);
|
|
3538
3516
|
const aliasForm = aliasSpecifier(sourceRoot, resolvedPath);
|
|
3539
|
-
|
|
3540
|
-
const aliasSegments = segmentCount(aliasForm);
|
|
3541
|
-
function describeChoice(preferred, preferredSegments, other, otherSegments) {
|
|
3542
|
-
const tie = preferredSegments === otherSegments ? ", and a tie goes to the relative path" : "";
|
|
3543
|
-
return `Use "${preferred}" (${describeSegments(preferredSegments)}) instead of "${other}" (${describeSegments(otherSegments)})${tie}.`;
|
|
3544
|
-
}
|
|
3545
|
-
if (prefersRelative(sourceRoot, filename, resolvedPath) && importPath.startsWith("@/")) {
|
|
3517
|
+
if (prefersRelative(filename, resolvedPath) && importPath.startsWith("@/")) {
|
|
3546
3518
|
context.report({
|
|
3547
3519
|
node: source,
|
|
3548
|
-
message:
|
|
3520
|
+
message: `Use "${relativeForm}" instead of "${aliasForm}".`
|
|
3549
3521
|
});
|
|
3550
3522
|
return;
|
|
3551
3523
|
}
|
|
3552
|
-
if (!prefersRelative(
|
|
3524
|
+
if (!prefersRelative(filename, resolvedPath) && importPath.startsWith(".")) {
|
|
3553
3525
|
context.report({
|
|
3554
3526
|
node: source,
|
|
3555
|
-
message:
|
|
3527
|
+
message: `Use "${aliasForm}" instead of "${relativeForm}".`
|
|
3556
3528
|
});
|
|
3557
3529
|
}
|
|
3558
3530
|
}
|
|
@@ -4714,19 +4686,15 @@ var DOC3 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
|
4714
4686
|
var VALUE_SENTINELS = /* @__PURE__ */ new Set(["undefined", "NaN", "Infinity"]);
|
|
4715
4687
|
var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
4716
4688
|
function entityNameText(name) {
|
|
4717
|
-
if (!name) return void 0;
|
|
4718
4689
|
if (name.type === "Identifier") return name.name;
|
|
4719
4690
|
if (name.type === "TSQualifiedName") {
|
|
4720
4691
|
const left = entityNameText(name.left);
|
|
4721
|
-
const right = name.right
|
|
4692
|
+
const right = name.right.name;
|
|
4722
4693
|
return left && right ? `${left}.${right}` : void 0;
|
|
4723
4694
|
}
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
return object && property ? `${object}.${property}` : void 0;
|
|
4728
|
-
}
|
|
4729
|
-
return void 0;
|
|
4695
|
+
const object = entityNameText(name.object);
|
|
4696
|
+
const property = name.property.name;
|
|
4697
|
+
return object && property ? `${object}.${property}` : void 0;
|
|
4730
4698
|
}
|
|
4731
4699
|
function aliasMessage(alias, source) {
|
|
4732
4700
|
const aliasName = alias ?? "This declaration";
|
|
@@ -4766,16 +4734,31 @@ var noRedundantAliasRule = {
|
|
|
4766
4734
|
message: aliasMessage(node.id?.name, source)
|
|
4767
4735
|
});
|
|
4768
4736
|
},
|
|
4737
|
+
ExportNamedDeclaration(node) {
|
|
4738
|
+
for (const specifier of node.specifiers) {
|
|
4739
|
+
if (specifier.local.type !== "Identifier" || specifier.exported.type !== "Identifier") continue;
|
|
4740
|
+
const source = specifier.local.name;
|
|
4741
|
+
const alias = specifier.exported.name;
|
|
4742
|
+
if (source === alias) continue;
|
|
4743
|
+
const frameworkRouteAlias = path37.basename(context.filename) === "route.ts" && HTTP_METHODS.has(alias);
|
|
4744
|
+
if (frameworkRouteAlias) continue;
|
|
4745
|
+
context.report({
|
|
4746
|
+
node: specifier,
|
|
4747
|
+
message: aliasMessage(alias, source)
|
|
4748
|
+
});
|
|
4749
|
+
}
|
|
4750
|
+
},
|
|
4769
4751
|
TSInterfaceDeclaration(node) {
|
|
4770
4752
|
if (node.typeParameters || node.body?.body?.length !== 0 || node.extends?.length !== 1) return;
|
|
4771
|
-
const heritage
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4753
|
+
for (const heritage of node.extends) {
|
|
4754
|
+
if (heritage.typeArguments) return;
|
|
4755
|
+
const source = entityNameText(heritage.expression);
|
|
4756
|
+
if (!source) return;
|
|
4757
|
+
context.report({
|
|
4758
|
+
node,
|
|
4759
|
+
message: aliasMessage(node.id?.name, source)
|
|
4760
|
+
});
|
|
4761
|
+
}
|
|
4779
4762
|
}
|
|
4780
4763
|
};
|
|
4781
4764
|
}
|
|
@@ -5055,7 +5038,7 @@ function stringValues2(value) {
|
|
|
5055
5038
|
if (value.type !== "Array") return [];
|
|
5056
5039
|
return value.elements.flatMap((element) => element.value.type === "String" ? [element.value.value] : []);
|
|
5057
5040
|
}
|
|
5058
|
-
var
|
|
5041
|
+
var VITEST_CONFIG_NAMES = [
|
|
5059
5042
|
"vitest.config.ts",
|
|
5060
5043
|
"vitest.config.mts",
|
|
5061
5044
|
"vitest.config.cts",
|
|
@@ -5112,7 +5095,7 @@ var vitestCoverageRule = {
|
|
|
5112
5095
|
message: 'package.json must declare a "test:unit:coverage" script that runs Vitest with coverage.'
|
|
5113
5096
|
});
|
|
5114
5097
|
}
|
|
5115
|
-
const configName =
|
|
5098
|
+
const configName = VITEST_CONFIG_NAMES.find((name) => existsSync5(path39.join(context.cwd, name)));
|
|
5116
5099
|
if (!configName) {
|
|
5117
5100
|
context.report({
|
|
5118
5101
|
node,
|