@sarj/eslint-plugin 16.26.1 → 16.26.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/{_docs-B9LZ5Out.d.cts → _docs-DU-K223M.d.cts} +2 -1
- package/dist/{_docs-B9LZ5Out.d.ts → _docs-DU-K223M.d.ts} +2 -1
- package/dist/index.cjs +43 -25
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +43 -25
- package/dist/rule-examples.d.cts +1 -1
- package/dist/rule-examples.d.ts +1 -1
- package/package.json +19 -19
|
@@ -90,4 +90,5 @@ declare function publicDocumentation(rules: Readonly<Record<string, {
|
|
|
90
90
|
readonly documentation?: NativeRuleSpec;
|
|
91
91
|
}>>): readonly PublicRuleSpec[];
|
|
92
92
|
|
|
93
|
-
export {
|
|
93
|
+
export { publicDocumentation as p };
|
|
94
|
+
export type { DocumentedRule as D };
|
|
@@ -90,4 +90,5 @@ declare function publicDocumentation(rules: Readonly<Record<string, {
|
|
|
90
90
|
readonly documentation?: NativeRuleSpec;
|
|
91
91
|
}>>): readonly PublicRuleSpec[];
|
|
92
92
|
|
|
93
|
-
export {
|
|
93
|
+
export { publicDocumentation as p };
|
|
94
|
+
export type { DocumentedRule as D };
|
package/dist/index.cjs
CHANGED
|
@@ -883,8 +883,8 @@ function isSearchParamReceiver(call, services) {
|
|
|
883
883
|
// package.json
|
|
884
884
|
var package_default = {
|
|
885
885
|
name: "@sarj/eslint-plugin",
|
|
886
|
-
version: "16.26.
|
|
887
|
-
packageManager: "npm@12.2.
|
|
886
|
+
version: "16.26.3",
|
|
887
|
+
packageManager: "npm@12.2.1",
|
|
888
888
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
889
889
|
type: "module",
|
|
890
890
|
main: "./dist/index.cjs",
|
|
@@ -937,8 +937,8 @@ var package_default = {
|
|
|
937
937
|
author: "sarj-ai",
|
|
938
938
|
license: "MIT",
|
|
939
939
|
dependencies: {
|
|
940
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
941
|
-
"@typescript-eslint/utils": "^8.
|
|
940
|
+
"@typescript-eslint/typescript-estree": "^8.72.0",
|
|
941
|
+
"@typescript-eslint/utils": "^8.72.0",
|
|
942
942
|
"jsonc-parser": "^3.3.1",
|
|
943
943
|
"ts-api-utils": "2.5.0",
|
|
944
944
|
"eslint-plugin-sonarjs": "4.2.2"
|
|
@@ -947,20 +947,20 @@ var package_default = {
|
|
|
947
947
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
948
948
|
"@eslint/compat": "^2.1.1",
|
|
949
949
|
"@eslint/js": "10.0.1",
|
|
950
|
-
"@shadcn/lint": "0.2.
|
|
950
|
+
"@shadcn/lint": "0.2.3",
|
|
951
951
|
"@types/node": "26.6.5",
|
|
952
|
-
"@typescript-eslint/parser": "8.
|
|
953
|
-
"@typescript-eslint/rule-tester": "8.
|
|
954
|
-
"@typescript-eslint/utils": "8.
|
|
952
|
+
"@typescript-eslint/parser": "8.72.0",
|
|
953
|
+
"@typescript-eslint/rule-tester": "8.72.0",
|
|
954
|
+
"@typescript-eslint/utils": "8.72.0",
|
|
955
955
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
956
|
-
"@vitest/eslint-plugin": "1.6.
|
|
957
|
-
eslint: "10.
|
|
956
|
+
"@vitest/eslint-plugin": "1.6.28",
|
|
957
|
+
eslint: "10.13.0",
|
|
958
958
|
"eslint-node-test": "1.0.1",
|
|
959
|
-
"eslint-plugin-better-tailwindcss": "^4.
|
|
959
|
+
"eslint-plugin-better-tailwindcss": "^4.10.0",
|
|
960
960
|
"eslint-plugin-jest": "29.17.0",
|
|
961
|
-
"eslint-plugin-jsdoc": "65.
|
|
962
|
-
"eslint-plugin-n": "^18.
|
|
963
|
-
"eslint-plugin-perfectionist": "5.
|
|
961
|
+
"eslint-plugin-jsdoc": "65.4.2",
|
|
962
|
+
"eslint-plugin-n": "^18.5.0",
|
|
963
|
+
"eslint-plugin-perfectionist": "5.13.0",
|
|
964
964
|
"eslint-plugin-playwright": "2.12.1",
|
|
965
965
|
"eslint-plugin-promise": "^7.3.0",
|
|
966
966
|
"eslint-plugin-react": "^7.37.5",
|
|
@@ -968,14 +968,14 @@ var package_default = {
|
|
|
968
968
|
"eslint-plugin-regexp": "3.3.1",
|
|
969
969
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
970
970
|
"eslint-plugin-testing-library": "7.16.2",
|
|
971
|
-
"eslint-plugin-unicorn": "^
|
|
972
|
-
"eslint-plugin-zod": "^5.
|
|
971
|
+
"eslint-plugin-unicorn": "^79.0.0",
|
|
972
|
+
"eslint-plugin-zod": "^5.2.2",
|
|
973
973
|
globals: "17.13.0",
|
|
974
974
|
jiti: "2.7.0",
|
|
975
|
-
tsup: "
|
|
975
|
+
tsup: "9.0.0",
|
|
976
976
|
typescript: "npm:@typescript/typescript6@6.0.2",
|
|
977
|
-
"typescript-eslint": "^8.
|
|
978
|
-
vitest: "5.0.
|
|
977
|
+
"typescript-eslint": "^8.72.0",
|
|
978
|
+
vitest: "5.0.5",
|
|
979
979
|
zod: "4.6.7"
|
|
980
980
|
},
|
|
981
981
|
peerDependencies: {
|
|
@@ -11084,6 +11084,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
11084
11084
|
const returnBlock = node.parent;
|
|
11085
11085
|
if (parameter?.type === import_utils64.AST_NODE_TYPES.Identifier && returnBlock?.type === import_utils64.AST_NODE_TYPES.BlockStatement) {
|
|
11086
11086
|
const errorBinding = import_utils64.ASTUtils.findVariable(context.sourceCode.getScope(parameter), parameter.name);
|
|
11087
|
+
const errorReferences = errorBinding !== null && errorBinding.references.length > 32 ? new Set(errorBinding.references.map((reference) => reference.identifier)) : void 0;
|
|
11087
11088
|
const assertedError = returnBlock.body.some((statement) => {
|
|
11088
11089
|
if (statement.range[1] > node.range[0] || statement.type !== import_utils64.AST_NODE_TYPES.ExpressionStatement) return false;
|
|
11089
11090
|
const expression = statement.expression;
|
|
@@ -11094,7 +11095,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
11094
11095
|
let operand = expression.callee.type === import_utils64.AST_NODE_TYPES.MemberExpression ? expression.callee.object : null;
|
|
11095
11096
|
if (operand?.type === import_utils64.AST_NODE_TYPES.MemberExpression && staticMemberName3(operand) === "not") operand = operand.object;
|
|
11096
11097
|
if (assertionName !== "assert" && (assertionName !== "expect" || operand?.type !== import_utils64.AST_NODE_TYPES.CallExpression || operand.callee !== root)) return false;
|
|
11097
|
-
return walkOwnScope(expression, (current) => current.type === import_utils64.AST_NODE_TYPES.Identifier && errorBinding?.references.some((reference) => reference.identifier === current) === true);
|
|
11098
|
+
return walkOwnScope(expression, (current) => current.type === import_utils64.AST_NODE_TYPES.Identifier && (errorReferences?.has(current) ?? errorBinding?.references.some((reference) => reference.identifier === current)) === true);
|
|
11098
11099
|
});
|
|
11099
11100
|
if (assertedError) return;
|
|
11100
11101
|
}
|
|
@@ -17325,6 +17326,15 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
17325
17326
|
if (!isTestFile(context)) {
|
|
17326
17327
|
return {};
|
|
17327
17328
|
}
|
|
17329
|
+
const referenceIdentifiers = /* @__PURE__ */ new WeakMap();
|
|
17330
|
+
const isReference = (variable, identifier) => {
|
|
17331
|
+
let identifiers = referenceIdentifiers.get(variable);
|
|
17332
|
+
if (identifiers === void 0) {
|
|
17333
|
+
identifiers = new Set(variable.references.map((reference) => reference.identifier));
|
|
17334
|
+
referenceIdentifiers.set(variable, identifiers);
|
|
17335
|
+
}
|
|
17336
|
+
return identifiers.has(identifier);
|
|
17337
|
+
};
|
|
17328
17338
|
const isFrameworkTest = (identifier) => TEST_CALLERS3.has(runtimeTestFrameworkName(context.sourceCode, identifier, "test") ?? "");
|
|
17329
17339
|
const isFrameworkAssertion = (identifier) => ASSERTION_ROOTS.has(runtimeTestFrameworkName(context.sourceCode, identifier, "assertion") ?? "");
|
|
17330
17340
|
return {
|
|
@@ -17348,7 +17358,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
17348
17358
|
const capturesSetup = walkOwnScope2(node.body, (current) => {
|
|
17349
17359
|
if (current.type !== import_utils99.AST_NODE_TYPES.Identifier) return false;
|
|
17350
17360
|
const variable = import_utils99.ASTUtils.findVariable(context.sourceCode.getScope(current), current.name);
|
|
17351
|
-
if (variable === null || !variable
|
|
17361
|
+
if (variable === null || !isReference(variable, current)) return false;
|
|
17352
17362
|
return variable.defs.some((definition) => {
|
|
17353
17363
|
const declaration = definition.name;
|
|
17354
17364
|
return declaration.range[0] >= enclosing.range[0] && declaration.range[1] <= enclosing.range[1] && (declaration.range[0] < node.range[0] || declaration.range[1] > node.range[1]);
|
|
@@ -27532,6 +27542,14 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27532
27542
|
defaultOptions: [],
|
|
27533
27543
|
create(context) {
|
|
27534
27544
|
if (!isTestFile(context) || isGeneratedFile(context, context.sourceCode.text)) return {};
|
|
27545
|
+
const referenceStability = /* @__PURE__ */ new WeakMap();
|
|
27546
|
+
const referenceStable = (variable) => {
|
|
27547
|
+
const cached = referenceStability.get(variable);
|
|
27548
|
+
if (cached !== void 0) return cached;
|
|
27549
|
+
const stable = !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
27550
|
+
referenceStability.set(variable, stable);
|
|
27551
|
+
return stable;
|
|
27552
|
+
};
|
|
27535
27553
|
const scopes = [newScope()];
|
|
27536
27554
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
27537
27555
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
@@ -27549,7 +27567,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27549
27567
|
};
|
|
27550
27568
|
const visible = (kind, node) => {
|
|
27551
27569
|
const name2 = bindingOf(node);
|
|
27552
|
-
if (name2 === null || name2
|
|
27570
|
+
if (name2 === null || !referenceStable(name2)) return false;
|
|
27553
27571
|
for (let index = scopes.length - 1; index >= 0; index--) {
|
|
27554
27572
|
const scope = scopes[index];
|
|
27555
27573
|
if (scope.declared.has(name2)) return scope[kind].has(name2);
|
|
@@ -27558,7 +27576,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27558
27576
|
};
|
|
27559
27577
|
const visibleRawOrigins = (node) => {
|
|
27560
27578
|
const name2 = bindingOf(node);
|
|
27561
|
-
if (name2 === null || name2
|
|
27579
|
+
if (name2 === null || !referenceStable(name2)) return /* @__PURE__ */ new Set();
|
|
27562
27580
|
for (let index = scopes.length - 1; index >= 0; index--) {
|
|
27563
27581
|
const scope = scopes[index];
|
|
27564
27582
|
if (scope.declared.has(name2)) return scope.rawOrigins.get(name2) ?? /* @__PURE__ */ new Set();
|
|
@@ -27590,7 +27608,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27590
27608
|
};
|
|
27591
27609
|
const nativeImportedName = (node, modules) => {
|
|
27592
27610
|
const binding = bindingOf(node);
|
|
27593
|
-
if (binding === null || binding
|
|
27611
|
+
if (binding === null || !referenceStable(binding)) return null;
|
|
27594
27612
|
for (const definition of binding.defs) {
|
|
27595
27613
|
const imported = definition.node;
|
|
27596
27614
|
if (imported.type === import_utils144.AST_NODE_TYPES.ImportSpecifier && imported.imported.type === import_utils144.AST_NODE_TYPES.Identifier && imported.parent.type === import_utils144.AST_NODE_TYPES.ImportDeclaration && modules.has(String(imported.parent.source.value))) {
|
|
@@ -27601,7 +27619,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27601
27619
|
};
|
|
27602
27620
|
const stableInitializer = (node) => {
|
|
27603
27621
|
const binding = bindingOf(node);
|
|
27604
|
-
if (binding === null || binding
|
|
27622
|
+
if (binding === null || !referenceStable(binding) || binding.defs.length !== 1) return null;
|
|
27605
27623
|
const definition = binding.defs[0]?.node;
|
|
27606
27624
|
return definition?.type === import_utils144.AST_NODE_TYPES.VariableDeclarator ? definition.init : null;
|
|
27607
27625
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DocumentedRule } from './_docs-
|
|
2
|
-
export { p as publicDocumentation } from './_docs-
|
|
1
|
+
import { D as DocumentedRule } from './_docs-DU-K223M.cjs';
|
|
2
|
+
export { p as publicDocumentation } from './_docs-DU-K223M.cjs';
|
|
3
3
|
import '@typescript-eslint/utils';
|
|
4
4
|
|
|
5
5
|
/** @fileoverview _retired-rules — burned rule names and their migration action. */
|
|
@@ -1150,4 +1150,5 @@ declare const PLUGIN: {
|
|
|
1150
1150
|
};
|
|
1151
1151
|
};
|
|
1152
1152
|
|
|
1153
|
-
export { ADVISORY_RULES, APPLICATION_ONLY_RULES, RECOMMENDED_RULES, RENAMED_RULES, RETIRED_RULES, RULES,
|
|
1153
|
+
export { ADVISORY_RULES, APPLICATION_ONLY_RULES, RECOMMENDED_RULES, RENAMED_RULES, RETIRED_RULES, RULES, STRICT_RULES, ADVISORY_RULES as advisoryRules, APPLICATION_ONLY_RULES as applicationOnlyRules, PLUGIN as default, RECOMMENDED_RULES as recommendedRules, RENAMED_RULES as renamedRules, RETIRED_RULES as retiredRules, RULES as rules, STRICT_RULES as strictRules };
|
|
1154
|
+
export type { RetiredRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DocumentedRule } from './_docs-
|
|
2
|
-
export { p as publicDocumentation } from './_docs-
|
|
1
|
+
import { D as DocumentedRule } from './_docs-DU-K223M.js';
|
|
2
|
+
export { p as publicDocumentation } from './_docs-DU-K223M.js';
|
|
3
3
|
import '@typescript-eslint/utils';
|
|
4
4
|
|
|
5
5
|
/** @fileoverview _retired-rules — burned rule names and their migration action. */
|
|
@@ -1150,4 +1150,5 @@ declare const PLUGIN: {
|
|
|
1150
1150
|
};
|
|
1151
1151
|
};
|
|
1152
1152
|
|
|
1153
|
-
export { ADVISORY_RULES, APPLICATION_ONLY_RULES, RECOMMENDED_RULES, RENAMED_RULES, RETIRED_RULES, RULES,
|
|
1153
|
+
export { ADVISORY_RULES, APPLICATION_ONLY_RULES, RECOMMENDED_RULES, RENAMED_RULES, RETIRED_RULES, RULES, STRICT_RULES, ADVISORY_RULES as advisoryRules, APPLICATION_ONLY_RULES as applicationOnlyRules, PLUGIN as default, RECOMMENDED_RULES as recommendedRules, RENAMED_RULES as renamedRules, RETIRED_RULES as retiredRules, RULES as rules, STRICT_RULES as strictRules };
|
|
1154
|
+
export type { RetiredRule };
|
package/dist/index.js
CHANGED
|
@@ -836,8 +836,8 @@ function isSearchParamReceiver(call, services) {
|
|
|
836
836
|
// package.json
|
|
837
837
|
var package_default = {
|
|
838
838
|
name: "@sarj/eslint-plugin",
|
|
839
|
-
version: "16.26.
|
|
840
|
-
packageManager: "npm@12.2.
|
|
839
|
+
version: "16.26.3",
|
|
840
|
+
packageManager: "npm@12.2.1",
|
|
841
841
|
description: "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
842
842
|
type: "module",
|
|
843
843
|
main: "./dist/index.cjs",
|
|
@@ -890,8 +890,8 @@ var package_default = {
|
|
|
890
890
|
author: "sarj-ai",
|
|
891
891
|
license: "MIT",
|
|
892
892
|
dependencies: {
|
|
893
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
894
|
-
"@typescript-eslint/utils": "^8.
|
|
893
|
+
"@typescript-eslint/typescript-estree": "^8.72.0",
|
|
894
|
+
"@typescript-eslint/utils": "^8.72.0",
|
|
895
895
|
"jsonc-parser": "^3.3.1",
|
|
896
896
|
"ts-api-utils": "2.5.0",
|
|
897
897
|
"eslint-plugin-sonarjs": "4.2.2"
|
|
@@ -900,20 +900,20 @@ var package_default = {
|
|
|
900
900
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
901
901
|
"@eslint/compat": "^2.1.1",
|
|
902
902
|
"@eslint/js": "10.0.1",
|
|
903
|
-
"@shadcn/lint": "0.2.
|
|
903
|
+
"@shadcn/lint": "0.2.3",
|
|
904
904
|
"@types/node": "26.6.5",
|
|
905
|
-
"@typescript-eslint/parser": "8.
|
|
906
|
-
"@typescript-eslint/rule-tester": "8.
|
|
907
|
-
"@typescript-eslint/utils": "8.
|
|
905
|
+
"@typescript-eslint/parser": "8.72.0",
|
|
906
|
+
"@typescript-eslint/rule-tester": "8.72.0",
|
|
907
|
+
"@typescript-eslint/utils": "8.72.0",
|
|
908
908
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
909
|
-
"@vitest/eslint-plugin": "1.6.
|
|
910
|
-
eslint: "10.
|
|
909
|
+
"@vitest/eslint-plugin": "1.6.28",
|
|
910
|
+
eslint: "10.13.0",
|
|
911
911
|
"eslint-node-test": "1.0.1",
|
|
912
|
-
"eslint-plugin-better-tailwindcss": "^4.
|
|
912
|
+
"eslint-plugin-better-tailwindcss": "^4.10.0",
|
|
913
913
|
"eslint-plugin-jest": "29.17.0",
|
|
914
|
-
"eslint-plugin-jsdoc": "65.
|
|
915
|
-
"eslint-plugin-n": "^18.
|
|
916
|
-
"eslint-plugin-perfectionist": "5.
|
|
914
|
+
"eslint-plugin-jsdoc": "65.4.2",
|
|
915
|
+
"eslint-plugin-n": "^18.5.0",
|
|
916
|
+
"eslint-plugin-perfectionist": "5.13.0",
|
|
917
917
|
"eslint-plugin-playwright": "2.12.1",
|
|
918
918
|
"eslint-plugin-promise": "^7.3.0",
|
|
919
919
|
"eslint-plugin-react": "^7.37.5",
|
|
@@ -921,14 +921,14 @@ var package_default = {
|
|
|
921
921
|
"eslint-plugin-regexp": "3.3.1",
|
|
922
922
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
923
923
|
"eslint-plugin-testing-library": "7.16.2",
|
|
924
|
-
"eslint-plugin-unicorn": "^
|
|
925
|
-
"eslint-plugin-zod": "^5.
|
|
924
|
+
"eslint-plugin-unicorn": "^79.0.0",
|
|
925
|
+
"eslint-plugin-zod": "^5.2.2",
|
|
926
926
|
globals: "17.13.0",
|
|
927
927
|
jiti: "2.7.0",
|
|
928
|
-
tsup: "
|
|
928
|
+
tsup: "9.0.0",
|
|
929
929
|
typescript: "npm:@typescript/typescript6@6.0.2",
|
|
930
|
-
"typescript-eslint": "^8.
|
|
931
|
-
vitest: "5.0.
|
|
930
|
+
"typescript-eslint": "^8.72.0",
|
|
931
|
+
vitest: "5.0.5",
|
|
932
932
|
zod: "4.6.7"
|
|
933
933
|
},
|
|
934
934
|
peerDependencies: {
|
|
@@ -11069,6 +11069,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
11069
11069
|
const returnBlock = node.parent;
|
|
11070
11070
|
if (parameter?.type === AST_NODE_TYPES55.Identifier && returnBlock?.type === AST_NODE_TYPES55.BlockStatement) {
|
|
11071
11071
|
const errorBinding = ASTUtils32.findVariable(context.sourceCode.getScope(parameter), parameter.name);
|
|
11072
|
+
const errorReferences = errorBinding !== null && errorBinding.references.length > 32 ? new Set(errorBinding.references.map((reference) => reference.identifier)) : void 0;
|
|
11072
11073
|
const assertedError = returnBlock.body.some((statement) => {
|
|
11073
11074
|
if (statement.range[1] > node.range[0] || statement.type !== AST_NODE_TYPES55.ExpressionStatement) return false;
|
|
11074
11075
|
const expression = statement.expression;
|
|
@@ -11079,7 +11080,7 @@ var no_bare_return_from_test_catch_default = createRule({
|
|
|
11079
11080
|
let operand = expression.callee.type === AST_NODE_TYPES55.MemberExpression ? expression.callee.object : null;
|
|
11080
11081
|
if (operand?.type === AST_NODE_TYPES55.MemberExpression && staticMemberName3(operand) === "not") operand = operand.object;
|
|
11081
11082
|
if (assertionName !== "assert" && (assertionName !== "expect" || operand?.type !== AST_NODE_TYPES55.CallExpression || operand.callee !== root)) return false;
|
|
11082
|
-
return walkOwnScope(expression, (current) => current.type === AST_NODE_TYPES55.Identifier && errorBinding?.references.some((reference) => reference.identifier === current) === true);
|
|
11083
|
+
return walkOwnScope(expression, (current) => current.type === AST_NODE_TYPES55.Identifier && (errorReferences?.has(current) ?? errorBinding?.references.some((reference) => reference.identifier === current)) === true);
|
|
11083
11084
|
});
|
|
11084
11085
|
if (assertedError) return;
|
|
11085
11086
|
}
|
|
@@ -17316,6 +17317,15 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
17316
17317
|
if (!isTestFile(context)) {
|
|
17317
17318
|
return {};
|
|
17318
17319
|
}
|
|
17320
|
+
const referenceIdentifiers = /* @__PURE__ */ new WeakMap();
|
|
17321
|
+
const isReference = (variable, identifier) => {
|
|
17322
|
+
let identifiers = referenceIdentifiers.get(variable);
|
|
17323
|
+
if (identifiers === void 0) {
|
|
17324
|
+
identifiers = new Set(variable.references.map((reference) => reference.identifier));
|
|
17325
|
+
referenceIdentifiers.set(variable, identifiers);
|
|
17326
|
+
}
|
|
17327
|
+
return identifiers.has(identifier);
|
|
17328
|
+
};
|
|
17319
17329
|
const isFrameworkTest = (identifier) => TEST_CALLERS3.has(runtimeTestFrameworkName(context.sourceCode, identifier, "test") ?? "");
|
|
17320
17330
|
const isFrameworkAssertion = (identifier) => ASSERTION_ROOTS.has(runtimeTestFrameworkName(context.sourceCode, identifier, "assertion") ?? "");
|
|
17321
17331
|
return {
|
|
@@ -17339,7 +17349,7 @@ var test_loops_over_literal_cases_default = createRule({
|
|
|
17339
17349
|
const capturesSetup = walkOwnScope2(node.body, (current) => {
|
|
17340
17350
|
if (current.type !== AST_NODE_TYPES82.Identifier) return false;
|
|
17341
17351
|
const variable = ASTUtils50.findVariable(context.sourceCode.getScope(current), current.name);
|
|
17342
|
-
if (variable === null || !variable
|
|
17352
|
+
if (variable === null || !isReference(variable, current)) return false;
|
|
17343
17353
|
return variable.defs.some((definition) => {
|
|
17344
17354
|
const declaration = definition.name;
|
|
17345
17355
|
return declaration.range[0] >= enclosing.range[0] && declaration.range[1] <= enclosing.range[1] && (declaration.range[0] < node.range[0] || declaration.range[1] > node.range[1]);
|
|
@@ -27556,6 +27566,14 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27556
27566
|
defaultOptions: [],
|
|
27557
27567
|
create(context) {
|
|
27558
27568
|
if (!isTestFile(context) || isGeneratedFile(context, context.sourceCode.text)) return {};
|
|
27569
|
+
const referenceStability = /* @__PURE__ */ new WeakMap();
|
|
27570
|
+
const referenceStable = (variable) => {
|
|
27571
|
+
const cached = referenceStability.get(variable);
|
|
27572
|
+
if (cached !== void 0) return cached;
|
|
27573
|
+
const stable = !variable.references.some((reference) => reference.isWrite() && reference.init !== true);
|
|
27574
|
+
referenceStability.set(variable, stable);
|
|
27575
|
+
return stable;
|
|
27576
|
+
};
|
|
27559
27577
|
const scopes = [newScope()];
|
|
27560
27578
|
const reportedOrigins = /* @__PURE__ */ new Set();
|
|
27561
27579
|
const currentScope = () => scopes.at(-1) ?? scopes[0];
|
|
@@ -27573,7 +27591,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27573
27591
|
};
|
|
27574
27592
|
const visible = (kind, node) => {
|
|
27575
27593
|
const name2 = bindingOf(node);
|
|
27576
|
-
if (name2 === null || name2
|
|
27594
|
+
if (name2 === null || !referenceStable(name2)) return false;
|
|
27577
27595
|
for (let index = scopes.length - 1; index >= 0; index--) {
|
|
27578
27596
|
const scope = scopes[index];
|
|
27579
27597
|
if (scope.declared.has(name2)) return scope[kind].has(name2);
|
|
@@ -27582,7 +27600,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27582
27600
|
};
|
|
27583
27601
|
const visibleRawOrigins = (node) => {
|
|
27584
27602
|
const name2 = bindingOf(node);
|
|
27585
|
-
if (name2 === null || name2
|
|
27603
|
+
if (name2 === null || !referenceStable(name2)) return /* @__PURE__ */ new Set();
|
|
27586
27604
|
for (let index = scopes.length - 1; index >= 0; index--) {
|
|
27587
27605
|
const scope = scopes[index];
|
|
27588
27606
|
if (scope.declared.has(name2)) return scope.rawOrigins.get(name2) ?? /* @__PURE__ */ new Set();
|
|
@@ -27614,7 +27632,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27614
27632
|
};
|
|
27615
27633
|
const nativeImportedName = (node, modules) => {
|
|
27616
27634
|
const binding = bindingOf(node);
|
|
27617
|
-
if (binding === null || binding
|
|
27635
|
+
if (binding === null || !referenceStable(binding)) return null;
|
|
27618
27636
|
for (const definition of binding.defs) {
|
|
27619
27637
|
const imported = definition.node;
|
|
27620
27638
|
if (imported.type === AST_NODE_TYPES123.ImportSpecifier && imported.imported.type === AST_NODE_TYPES123.Identifier && imported.parent.type === AST_NODE_TYPES123.ImportDeclaration && modules.has(String(imported.parent.source.value))) {
|
|
@@ -27625,7 +27643,7 @@ function createSourceCoupledRule(name, documentation, sourceSuffixRe) {
|
|
|
27625
27643
|
};
|
|
27626
27644
|
const stableInitializer = (node) => {
|
|
27627
27645
|
const binding = bindingOf(node);
|
|
27628
|
-
if (binding === null || binding
|
|
27646
|
+
if (binding === null || !referenceStable(binding) || binding.defs.length !== 1) return null;
|
|
27629
27647
|
const definition = binding.defs[0]?.node;
|
|
27630
27648
|
return definition?.type === AST_NODE_TYPES123.VariableDeclarator ? definition.init : null;
|
|
27631
27649
|
};
|
package/dist/rule-examples.d.cts
CHANGED
package/dist/rule-examples.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarj/eslint-plugin",
|
|
3
|
-
"version": "16.26.
|
|
4
|
-
"packageManager": "npm@12.2.
|
|
3
|
+
"version": "16.26.3",
|
|
4
|
+
"packageManager": "npm@12.2.1",
|
|
5
5
|
"description": "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"author": "sarj-ai",
|
|
55
55
|
"license": "MIT",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
58
|
-
"@typescript-eslint/utils": "^8.
|
|
57
|
+
"@typescript-eslint/typescript-estree": "^8.72.0",
|
|
58
|
+
"@typescript-eslint/utils": "^8.72.0",
|
|
59
59
|
"jsonc-parser": "^3.3.1",
|
|
60
60
|
"ts-api-utils": "2.5.0",
|
|
61
61
|
"eslint-plugin-sonarjs": "4.2.2"
|
|
@@ -64,20 +64,20 @@
|
|
|
64
64
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
65
65
|
"@eslint/compat": "^2.1.1",
|
|
66
66
|
"@eslint/js": "10.0.1",
|
|
67
|
-
"@shadcn/lint": "0.2.
|
|
67
|
+
"@shadcn/lint": "0.2.3",
|
|
68
68
|
"@types/node": "26.6.5",
|
|
69
|
-
"@typescript-eslint/parser": "8.
|
|
70
|
-
"@typescript-eslint/rule-tester": "8.
|
|
71
|
-
"@typescript-eslint/utils": "8.
|
|
69
|
+
"@typescript-eslint/parser": "8.72.0",
|
|
70
|
+
"@typescript-eslint/rule-tester": "8.72.0",
|
|
71
|
+
"@typescript-eslint/utils": "8.72.0",
|
|
72
72
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
73
|
-
"@vitest/eslint-plugin": "1.6.
|
|
74
|
-
"eslint": "10.
|
|
73
|
+
"@vitest/eslint-plugin": "1.6.28",
|
|
74
|
+
"eslint": "10.13.0",
|
|
75
75
|
"eslint-node-test": "1.0.1",
|
|
76
|
-
"eslint-plugin-better-tailwindcss": "^4.
|
|
76
|
+
"eslint-plugin-better-tailwindcss": "^4.10.0",
|
|
77
77
|
"eslint-plugin-jest": "29.17.0",
|
|
78
|
-
"eslint-plugin-jsdoc": "65.
|
|
79
|
-
"eslint-plugin-n": "^18.
|
|
80
|
-
"eslint-plugin-perfectionist": "5.
|
|
78
|
+
"eslint-plugin-jsdoc": "65.4.2",
|
|
79
|
+
"eslint-plugin-n": "^18.5.0",
|
|
80
|
+
"eslint-plugin-perfectionist": "5.13.0",
|
|
81
81
|
"eslint-plugin-playwright": "2.12.1",
|
|
82
82
|
"eslint-plugin-promise": "^7.3.0",
|
|
83
83
|
"eslint-plugin-react": "^7.37.5",
|
|
@@ -85,14 +85,14 @@
|
|
|
85
85
|
"eslint-plugin-regexp": "3.3.1",
|
|
86
86
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
87
87
|
"eslint-plugin-testing-library": "7.16.2",
|
|
88
|
-
"eslint-plugin-unicorn": "^
|
|
89
|
-
"eslint-plugin-zod": "^5.
|
|
88
|
+
"eslint-plugin-unicorn": "^79.0.0",
|
|
89
|
+
"eslint-plugin-zod": "^5.2.2",
|
|
90
90
|
"globals": "17.13.0",
|
|
91
91
|
"jiti": "2.7.0",
|
|
92
|
-
"tsup": "
|
|
92
|
+
"tsup": "9.0.0",
|
|
93
93
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
94
|
-
"typescript-eslint": "^8.
|
|
95
|
-
"vitest": "5.0.
|
|
94
|
+
"typescript-eslint": "^8.72.0",
|
|
95
|
+
"vitest": "5.0.5",
|
|
96
96
|
"zod": "4.6.7"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|