@sarj/eslint-plugin 16.22.2 → 16.22.3
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.cjs +24 -21
- package/dist/index.js +24 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -866,7 +866,7 @@ function isSearchParamReceiver(call, services) {
|
|
|
866
866
|
// package.json
|
|
867
867
|
var package_default = {
|
|
868
868
|
name: "@sarj/eslint-plugin",
|
|
869
|
-
version: "16.22.
|
|
869
|
+
version: "16.22.3",
|
|
870
870
|
packageManager: "npm@12.2.0",
|
|
871
871
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
872
872
|
type: "module",
|
|
@@ -27229,6 +27229,17 @@ function stringValue(node) {
|
|
|
27229
27229
|
}
|
|
27230
27230
|
return null;
|
|
27231
27231
|
}
|
|
27232
|
+
function staticPathSuffix(pathArguments, builder) {
|
|
27233
|
+
const trailing = [];
|
|
27234
|
+
for (const argument of pathArguments.toReversed()) {
|
|
27235
|
+
if (argument.type === import_utils143.AST_NODE_TYPES.SpreadElement) return null;
|
|
27236
|
+
const segment = stringValue(argument);
|
|
27237
|
+
if (segment === null) break;
|
|
27238
|
+
trailing.unshift(segment);
|
|
27239
|
+
if (builder === "resolve" && import_node_path3.posix.isAbsolute(segment.replaceAll("\\", "/"))) break;
|
|
27240
|
+
}
|
|
27241
|
+
return trailing.length > 0 ? trailing.join("/") : null;
|
|
27242
|
+
}
|
|
27232
27243
|
function importSource(node) {
|
|
27233
27244
|
return typeof node.source.value === "string" ? node.source.value : null;
|
|
27234
27245
|
}
|
|
@@ -27291,26 +27302,18 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27291
27302
|
const value = stringValue(current);
|
|
27292
27303
|
if (value !== null) return sourcePathValue(value);
|
|
27293
27304
|
if (current.type === import_utils143.AST_NODE_TYPES.Identifier) return visible("paths", current);
|
|
27294
|
-
if (current.type
|
|
27295
|
-
|
|
27296
|
-
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
|
|
27300
|
-
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27304
|
-
|
|
27305
|
-
|
|
27306
|
-
trailing.unshift(segment);
|
|
27307
|
-
if (pathBuilder === "resolve" && import_node_path3.posix.isAbsolute(segment.replaceAll("\\", "/"))) break;
|
|
27308
|
-
}
|
|
27309
|
-
return trailing.length > 0 && sourcePathValue(trailing.join("/"));
|
|
27310
|
-
}
|
|
27311
|
-
if (current.type === import_utils143.AST_NODE_TYPES.NewExpression && callee.type === import_utils143.AST_NODE_TYPES.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
27312
|
-
if (callee.type === import_utils143.AST_NODE_TYPES.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === import_utils143.AST_NODE_TYPES.ImportSpecifier && definition.node.imported.type === import_utils143.AST_NODE_TYPES.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === import_utils143.AST_NODE_TYPES.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
27313
|
-
}
|
|
27305
|
+
if (current.type !== import_utils143.AST_NODE_TYPES.CallExpression && current.type !== import_utils143.AST_NODE_TYPES.NewExpression) return false;
|
|
27306
|
+
const callee = unwrapExpression(current.callee);
|
|
27307
|
+
const first = current.arguments[0];
|
|
27308
|
+
if (first === void 0 || first.type === import_utils143.AST_NODE_TYPES.SpreadElement) return false;
|
|
27309
|
+
const pathBuilder = callee.type === import_utils143.AST_NODE_TYPES.Identifier ? nativePathBuilder(callee) : null;
|
|
27310
|
+
if (current.type === import_utils143.AST_NODE_TYPES.CallExpression && pathBuilder !== null) {
|
|
27311
|
+
if (temporaryDescendant(current, pathBuilder)) return false;
|
|
27312
|
+
const suffix = staticPathSuffix(current.arguments, pathBuilder);
|
|
27313
|
+
return suffix !== null && sourcePathValue(suffix);
|
|
27314
|
+
}
|
|
27315
|
+
if (current.type === import_utils143.AST_NODE_TYPES.NewExpression && callee.type === import_utils143.AST_NODE_TYPES.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
27316
|
+
if (callee.type === import_utils143.AST_NODE_TYPES.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === import_utils143.AST_NODE_TYPES.ImportSpecifier && definition.node.imported.type === import_utils143.AST_NODE_TYPES.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === import_utils143.AST_NODE_TYPES.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
27314
27317
|
return false;
|
|
27315
27318
|
};
|
|
27316
27319
|
const nativePathBuilder = (node) => {
|
package/dist/index.js
CHANGED
|
@@ -819,7 +819,7 @@ function isSearchParamReceiver(call, services) {
|
|
|
819
819
|
// package.json
|
|
820
820
|
var package_default = {
|
|
821
821
|
name: "@sarj/eslint-plugin",
|
|
822
|
-
version: "16.22.
|
|
822
|
+
version: "16.22.3",
|
|
823
823
|
packageManager: "npm@12.2.0",
|
|
824
824
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
825
825
|
type: "module",
|
|
@@ -27253,6 +27253,17 @@ function stringValue(node) {
|
|
|
27253
27253
|
}
|
|
27254
27254
|
return null;
|
|
27255
27255
|
}
|
|
27256
|
+
function staticPathSuffix(pathArguments, builder) {
|
|
27257
|
+
const trailing = [];
|
|
27258
|
+
for (const argument of pathArguments.toReversed()) {
|
|
27259
|
+
if (argument.type === AST_NODE_TYPES122.SpreadElement) return null;
|
|
27260
|
+
const segment = stringValue(argument);
|
|
27261
|
+
if (segment === null) break;
|
|
27262
|
+
trailing.unshift(segment);
|
|
27263
|
+
if (builder === "resolve" && posix2.isAbsolute(segment.replaceAll("\\", "/"))) break;
|
|
27264
|
+
}
|
|
27265
|
+
return trailing.length > 0 ? trailing.join("/") : null;
|
|
27266
|
+
}
|
|
27256
27267
|
function importSource(node) {
|
|
27257
27268
|
return typeof node.source.value === "string" ? node.source.value : null;
|
|
27258
27269
|
}
|
|
@@ -27315,26 +27326,18 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27315
27326
|
const value = stringValue(current);
|
|
27316
27327
|
if (value !== null) return sourcePathValue(value);
|
|
27317
27328
|
if (current.type === AST_NODE_TYPES122.Identifier) return visible("paths", current);
|
|
27318
|
-
if (current.type
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
|
|
27322
|
-
|
|
27323
|
-
|
|
27324
|
-
|
|
27325
|
-
|
|
27326
|
-
|
|
27327
|
-
|
|
27328
|
-
|
|
27329
|
-
|
|
27330
|
-
trailing.unshift(segment);
|
|
27331
|
-
if (pathBuilder === "resolve" && posix2.isAbsolute(segment.replaceAll("\\", "/"))) break;
|
|
27332
|
-
}
|
|
27333
|
-
return trailing.length > 0 && sourcePathValue(trailing.join("/"));
|
|
27334
|
-
}
|
|
27335
|
-
if (current.type === AST_NODE_TYPES122.NewExpression && callee.type === AST_NODE_TYPES122.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
27336
|
-
if (callee.type === AST_NODE_TYPES122.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === AST_NODE_TYPES122.ImportSpecifier && definition.node.imported.type === AST_NODE_TYPES122.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === AST_NODE_TYPES122.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
27337
|
-
}
|
|
27329
|
+
if (current.type !== AST_NODE_TYPES122.CallExpression && current.type !== AST_NODE_TYPES122.NewExpression) return false;
|
|
27330
|
+
const callee = unwrapExpression(current.callee);
|
|
27331
|
+
const first = current.arguments[0];
|
|
27332
|
+
if (first === void 0 || first.type === AST_NODE_TYPES122.SpreadElement) return false;
|
|
27333
|
+
const pathBuilder = callee.type === AST_NODE_TYPES122.Identifier ? nativePathBuilder(callee) : null;
|
|
27334
|
+
if (current.type === AST_NODE_TYPES122.CallExpression && pathBuilder !== null) {
|
|
27335
|
+
if (temporaryDescendant(current, pathBuilder)) return false;
|
|
27336
|
+
const suffix = staticPathSuffix(current.arguments, pathBuilder);
|
|
27337
|
+
return suffix !== null && sourcePathValue(suffix);
|
|
27338
|
+
}
|
|
27339
|
+
if (current.type === AST_NODE_TYPES122.NewExpression && callee.type === AST_NODE_TYPES122.Identifier && callee.name === "URL" && (bindingOf(callee)?.defs.length ?? 0) === 0) return sourcePath(first);
|
|
27340
|
+
if (callee.type === AST_NODE_TYPES122.Identifier && bindingOf(callee)?.defs.some((definition) => definition.node.type === AST_NODE_TYPES122.ImportSpecifier && definition.node.imported.type === AST_NODE_TYPES122.Identifier && definition.node.imported.name === "fileURLToPath" && definition.node.parent.type === AST_NODE_TYPES122.ImportDeclaration && ["node:url", "url"].includes(String(definition.node.parent.source.value)))) return sourcePath(first);
|
|
27338
27341
|
return false;
|
|
27339
27342
|
};
|
|
27340
27343
|
const nativePathBuilder = (node) => {
|