pasika 0.10.46 → 0.10.47
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 +8 -17
- package/package.json +1 -1
|
@@ -3485,14 +3485,11 @@ function relativeSpecifier(filename, resolvedPath) {
|
|
|
3485
3485
|
function aliasSpecifier(sourceRoot, resolvedPath) {
|
|
3486
3486
|
return `@/${(sourceSegments(sourceRoot, resolvedPath) ?? []).join("/")}`;
|
|
3487
3487
|
}
|
|
3488
|
-
function
|
|
3489
|
-
return specifier.
|
|
3488
|
+
function parentTraversalCount(specifier) {
|
|
3489
|
+
return specifier.split("/").filter((segment) => segment === "..").length;
|
|
3490
3490
|
}
|
|
3491
|
-
function
|
|
3492
|
-
return
|
|
3493
|
-
}
|
|
3494
|
-
function prefersRelative(sourceRoot, filename, resolvedPath) {
|
|
3495
|
-
return segmentCount(relativeSpecifier(filename, resolvedPath)) <= segmentCount(aliasSpecifier(sourceRoot, resolvedPath));
|
|
3491
|
+
function prefersRelative(filename, resolvedPath) {
|
|
3492
|
+
return parentTraversalCount(relativeSpecifier(filename, resolvedPath)) <= 1;
|
|
3496
3493
|
}
|
|
3497
3494
|
var importBoundariesRule = {
|
|
3498
3495
|
meta: {
|
|
@@ -3536,23 +3533,17 @@ var importBoundariesRule = {
|
|
|
3536
3533
|
}
|
|
3537
3534
|
const relativeForm = relativeSpecifier(filename, resolvedPath);
|
|
3538
3535
|
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("@/")) {
|
|
3536
|
+
if (prefersRelative(filename, resolvedPath) && importPath.startsWith("@/")) {
|
|
3546
3537
|
context.report({
|
|
3547
3538
|
node: source,
|
|
3548
|
-
message:
|
|
3539
|
+
message: `Use "${relativeForm}" instead of "${aliasForm}".`
|
|
3549
3540
|
});
|
|
3550
3541
|
return;
|
|
3551
3542
|
}
|
|
3552
|
-
if (!prefersRelative(
|
|
3543
|
+
if (!prefersRelative(filename, resolvedPath) && importPath.startsWith(".")) {
|
|
3553
3544
|
context.report({
|
|
3554
3545
|
node: source,
|
|
3555
|
-
message:
|
|
3546
|
+
message: `Use "${aliasForm}" instead of "${relativeForm}".`
|
|
3556
3547
|
});
|
|
3557
3548
|
}
|
|
3558
3549
|
}
|