@sarj/eslint-plugin 15.26.3 → 15.26.5

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 CHANGED
@@ -656,13 +656,17 @@ var import_typescript3 = __toESM(require("typescript"), 1);
656
656
  // src/rules/_for-each-ast-child.ts
657
657
  function forEachAstChild(node, visitorKeys, visit) {
658
658
  for (const key of visitorKeys[node.type] ?? []) {
659
- const value = node[key];
660
- if (Array.isArray(value)) {
661
- const children = value;
662
- for (const child of children) if (isNode(child) && visit(child) === true) return true;
663
- } else if (isNode(value)) {
664
- if (visit(value) === true) return true;
665
- }
659
+ if (forEachAstChildKey(node, key, visit)) return true;
660
+ }
661
+ return false;
662
+ }
663
+ function forEachAstChildKey(node, key, visit) {
664
+ const value = node[key];
665
+ if (Array.isArray(value)) {
666
+ const children = value;
667
+ for (const child of children) if (isNode(child) && visit(child) === true) return true;
668
+ } else if (isNode(value)) {
669
+ if (visit(value) === true) return true;
666
670
  }
667
671
  return false;
668
672
  }
@@ -3461,6 +3465,17 @@ var no_comment_cruft_default = createRule({
3461
3465
 
3462
3466
  // src/rules/no-cors-wildcard-with-credentials.ts
3463
3467
  var import_utils23 = require("@typescript-eslint/utils");
3468
+
3469
+ // src/rules/_for-each-own-ast-child.ts
3470
+ function forEachOwnAstChild(node, visit, includeKey = () => true) {
3471
+ for (const key of Object.keys(node)) {
3472
+ if (key === "parent" || !includeKey(key)) continue;
3473
+ if (forEachAstChildKey(node, key, visit)) return true;
3474
+ }
3475
+ return false;
3476
+ }
3477
+
3478
+ // src/rules/no-cors-wildcard-with-credentials.ts
3464
3479
  var NO_CORS_WILDCARD_WITH_CREDENTIALS_DOCUMENTATION = {
3465
3480
  summary: "Disallow wildcard CORS origins when credentials are enabled.",
3466
3481
  rationale: "Reflecting every origin while allowing credentials can let an untrusted site read authenticated cross-origin responses.",
@@ -3553,25 +3568,11 @@ function subtreeContainsStarLiteral(node) {
3553
3568
  if (isStarLiteral(node)) {
3554
3569
  return true;
3555
3570
  }
3556
- for (const key of Object.keys(node)) {
3557
- if (key === "parent" || key === "loc" || key === "range") {
3558
- continue;
3559
- }
3560
- const value = node[key];
3561
- if (Array.isArray(value)) {
3562
- for (const child of value) {
3563
- if (isNode2(child) && subtreeContainsStarLiteral(child)) {
3564
- return true;
3565
- }
3566
- }
3567
- } else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
3568
- return true;
3569
- }
3570
- }
3571
- return false;
3572
- }
3573
- function isNode2(value) {
3574
- return typeof value === "object" && value !== null && typeof value.type === "string";
3571
+ return forEachOwnAstChild(
3572
+ node,
3573
+ subtreeContainsStarLiteral,
3574
+ (key) => key !== "loc" && key !== "range"
3575
+ );
3575
3576
  }
3576
3577
  function calleeName(node) {
3577
3578
  const callee = node.callee;
@@ -4118,17 +4119,7 @@ function isJoinedFragmentArray(node) {
4118
4119
  }
4119
4120
  function markConsumed(node, consumed) {
4120
4121
  consumed.add(node);
4121
- for (const key of Object.keys(node)) {
4122
- if (key === "parent") {
4123
- continue;
4124
- }
4125
- const value = node[key];
4126
- for (const child of Array.isArray(value) ? value : [value]) {
4127
- if (child !== null && typeof child === "object" && "type" in child) {
4128
- markConsumed(child, consumed);
4129
- }
4130
- }
4131
- }
4122
+ forEachOwnAstChild(node, (child) => markConsumed(child, consumed));
4132
4123
  }
4133
4124
  function createSqlListener(handler) {
4134
4125
  const consumed = /* @__PURE__ */ new WeakSet();
@@ -4753,9 +4744,6 @@ var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
4753
4744
  "Response",
4754
4745
  "AbortController"
4755
4746
  ]);
4756
- function isNode3(value) {
4757
- return typeof value === "object" && value !== null && typeof value.type === "string";
4758
- }
4759
4747
  function isPureCall(node) {
4760
4748
  const callee = node.callee;
4761
4749
  if (callee.type !== import_utils30.AST_NODE_TYPES.MemberExpression) {
@@ -4793,27 +4781,7 @@ function subtreeMatches(stmt, predicate, descendIntoFunctions = false) {
4793
4781
  found = true;
4794
4782
  return;
4795
4783
  }
4796
- for (const key of Object.keys(current)) {
4797
- if (key === "parent") {
4798
- continue;
4799
- }
4800
- if (!descendIntoFunctions && NESTED_FUNCTION_TYPES.has(current.type) && key === "body") {
4801
- continue;
4802
- }
4803
- const value = current[key];
4804
- if (Array.isArray(value)) {
4805
- for (const child of value) {
4806
- if (isNode3(child)) {
4807
- visit(child);
4808
- }
4809
- }
4810
- } else if (isNode3(value)) {
4811
- visit(value);
4812
- }
4813
- if (found) {
4814
- return;
4815
- }
4816
- }
4784
+ forEachOwnAstChild(current, visit, (key) => descendIntoFunctions || !NESTED_FUNCTION_TYPES.has(current.type) || key !== "body");
4817
4785
  };
4818
4786
  visit(stmt);
4819
4787
  return found;
@@ -7169,17 +7137,7 @@ function nearestFunction(node) {
7169
7137
  }
7170
7138
  function walkOwnScope(node, predicate) {
7171
7139
  if (predicate(node)) return true;
7172
- for (const key of Object.keys(node)) {
7173
- if (key === "parent") continue;
7174
- const value = node[key];
7175
- for (const child of Array.isArray(value) ? value : [value]) {
7176
- if (typeof child === "object" && child !== null && typeof child.type === "string") {
7177
- const childNode = child;
7178
- if (!FUNCTION_TYPES3.has(childNode.type) && walkOwnScope(childNode, predicate)) return true;
7179
- }
7180
- }
7181
- }
7182
- return false;
7140
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES3.has(child.type) && walkOwnScope(child, predicate));
7183
7141
  }
7184
7142
  function isAssertion(node, context) {
7185
7143
  if (node.type !== import_utils44.AST_NODE_TYPES.CallExpression) return false;
@@ -9966,7 +9924,7 @@ function isSentinelArgument(arg) {
9966
9924
  function isFunctionNode(node) {
9967
9925
  return node.type === import_utils61.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils61.AST_NODE_TYPES.FunctionExpression || node.type === import_utils61.AST_NODE_TYPES.ArrowFunctionExpression;
9968
9926
  }
9969
- function isNode4(value) {
9927
+ function isNode2(value) {
9970
9928
  return typeof value === "object" && value !== null && typeof value.type === "string";
9971
9929
  }
9972
9930
  function walkWithinScope(node, visit) {
@@ -9982,21 +9940,10 @@ function walkWithinScope(node, visit) {
9982
9940
  if (isFunctionNode(current)) {
9983
9941
  return;
9984
9942
  }
9985
- for (const key of Object.keys(current)) {
9986
- if (key === "parent") {
9987
- continue;
9988
- }
9989
- const value = current[key];
9990
- if (Array.isArray(value)) {
9991
- for (const child of value) {
9992
- if (isNode4(child)) {
9993
- recurse(child);
9994
- }
9995
- }
9996
- } else if (isNode4(value)) {
9997
- recurse(value);
9998
- }
9999
- }
9943
+ forEachOwnAstChild(current, (child) => {
9944
+ recurse(child);
9945
+ return found;
9946
+ });
10000
9947
  };
10001
9948
  recurse(node);
10002
9949
  return found;
@@ -10043,22 +9990,10 @@ function subtreeReadsName(node, name) {
10043
9990
  if (shadowsName(current)) {
10044
9991
  return;
10045
9992
  }
10046
- for (const key of Object.keys(current)) {
10047
- if (key === "parent") {
10048
- continue;
10049
- }
10050
- if (isNonReadingProperty(current, key)) continue;
10051
- const value = current[key];
10052
- if (Array.isArray(value)) {
10053
- for (const child of value) {
10054
- if (isNode4(child)) {
10055
- recurse(child);
10056
- }
10057
- }
10058
- } else if (isNode4(value)) {
10059
- recurse(value);
10060
- }
10061
- }
9993
+ forEachOwnAstChild(current, (child) => {
9994
+ recurse(child);
9995
+ return found;
9996
+ }, (key) => !isNonReadingProperty(current, key));
10062
9997
  };
10063
9998
  recurse(node);
10064
9999
  return found;
@@ -10116,7 +10051,7 @@ function enclosingFunctionName(node) {
10116
10051
  let current = node.parent;
10117
10052
  while (current !== void 0 && current !== null) {
10118
10053
  if (isFunctionNode(current)) {
10119
- if ("id" in current && isNode4(current.id) && current.id.type === import_utils61.AST_NODE_TYPES.Identifier) {
10054
+ if ("id" in current && isNode2(current.id) && current.id.type === import_utils61.AST_NODE_TYPES.Identifier) {
10120
10055
  return current.id.name;
10121
10056
  }
10122
10057
  const parent = current.parent;
@@ -10177,14 +10112,10 @@ function tryReturnsSafeParse(catchNode) {
10177
10112
  visitChildren(current);
10178
10113
  };
10179
10114
  function visitChildren(current) {
10180
- for (const key of Object.keys(current)) {
10181
- if (key === "parent") continue;
10182
- const value = current[key];
10183
- const children = Array.isArray(value) ? value : [value];
10184
- for (const child of children) {
10185
- if (isNode4(child)) recurse(child);
10186
- }
10187
- }
10115
+ forEachOwnAstChild(current, (child) => {
10116
+ recurse(child);
10117
+ return sawUnsafeOperation;
10118
+ });
10188
10119
  }
10189
10120
  recurse(tryBlock);
10190
10121
  return sawSafeParse && !sawUnsafeOperation;
@@ -10221,7 +10152,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
10221
10152
  function enclosingFunctionBody(node) {
10222
10153
  let current = node.parent;
10223
10154
  while (current !== void 0 && current !== null) {
10224
- if (isFunctionNode(current) && "body" in current && isNode4(current.body) && current.body.type === import_utils61.AST_NODE_TYPES.BlockStatement) {
10155
+ if (isFunctionNode(current) && "body" in current && isNode2(current.body) && current.body.type === import_utils61.AST_NODE_TYPES.BlockStatement) {
10225
10156
  return current.body;
10226
10157
  }
10227
10158
  current = current.parent;
@@ -12331,16 +12262,7 @@ var subtreeReadsImportedBinding = (node, imported) => {
12331
12262
  if (node.type === import_utils72.AST_NODE_TYPES.Identifier) {
12332
12263
  return imported.has(node.name);
12333
12264
  }
12334
- for (const key of Object.keys(node)) {
12335
- if (key === "parent") continue;
12336
- const value = node[key];
12337
- for (const child of Array.isArray(value) ? value : [value]) {
12338
- if (child !== null && typeof child === "object" && typeof child.type === "string" && subtreeReadsImportedBinding(child, imported)) {
12339
- return true;
12340
- }
12341
- }
12342
- }
12343
- return false;
12265
+ return forEachOwnAstChild(node, (child) => subtreeReadsImportedBinding(child, imported));
12344
12266
  };
12345
12267
  var isUseClientDirective = (node) => {
12346
12268
  return node.type === import_utils72.AST_NODE_TYPES.ExpressionStatement && node.directive === "use client";
@@ -12984,23 +12906,7 @@ function walkOwnScope2(node, predicate) {
12984
12906
  if (predicate(node)) {
12985
12907
  return true;
12986
12908
  }
12987
- for (const key of Object.keys(node)) {
12988
- if (key === "parent") {
12989
- continue;
12990
- }
12991
- const value = node[key];
12992
- const children = Array.isArray(value) ? value : [value];
12993
- for (const child of children) {
12994
- if (typeof child !== "object" || child === null || typeof child.type !== "string") {
12995
- continue;
12996
- }
12997
- const childNode = child;
12998
- if (!FUNCTION_TYPES6.has(childNode.type) && walkOwnScope2(childNode, predicate)) {
12999
- return true;
13000
- }
13001
- }
13002
- }
13003
- return false;
12909
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES6.has(child.type) && walkOwnScope2(child, predicate));
13004
12910
  }
13005
12911
  function isAssertion2(node, isFrameworkAssertion) {
13006
12912
  if (node.type !== import_utils77.AST_NODE_TYPES.CallExpression || !ASSERTION_ROOTS.has(callerName(node.callee) ?? "")) return false;
@@ -16862,15 +16768,10 @@ var isLocalFileRead = (node) => {
16862
16768
  found = true;
16863
16769
  return;
16864
16770
  }
16865
- for (const key of Object.keys(current)) {
16866
- if (key === "parent") continue;
16867
- const value = current[key];
16868
- for (const child of Array.isArray(value) ? value : [value]) {
16869
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
16870
- visit(child);
16871
- }
16872
- }
16873
- }
16771
+ forEachOwnAstChild(current, (child) => {
16772
+ visit(child);
16773
+ return found;
16774
+ });
16874
16775
  };
16875
16776
  visit(node);
16876
16777
  return found;
@@ -20414,15 +20315,9 @@ var readConstructor = (ctor, declared, typeParameters) => {
20414
20315
  }
20415
20316
  }
20416
20317
  function enqueueChildren(current) {
20417
- for (const key of Object.keys(current)) {
20418
- if (key === "parent") continue;
20419
- const value = current[key];
20420
- for (const child of Array.isArray(value) ? value : [value]) {
20421
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20422
- pending.push(child);
20423
- }
20424
- }
20425
- }
20318
+ forEachOwnAstChild(current, (child) => {
20319
+ pending.push(child);
20320
+ });
20426
20321
  }
20427
20322
  while (pending.length > 0) {
20428
20323
  const current = pending.pop();
@@ -20531,15 +20426,10 @@ var subtreeHas = (root, found) => {
20531
20426
  hit = true;
20532
20427
  return;
20533
20428
  }
20534
- for (const key of Object.keys(current)) {
20535
- if (key === "parent") continue;
20536
- const value = current[key];
20537
- for (const child of Array.isArray(value) ? value : [value]) {
20538
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20539
- visit(child);
20540
- }
20541
- }
20542
- }
20429
+ forEachOwnAstChild(current, (child) => {
20430
+ visit(child);
20431
+ return hit;
20432
+ });
20543
20433
  };
20544
20434
  visit(root);
20545
20435
  return hit;
@@ -20564,13 +20454,7 @@ var behaviorallyInvokedFields = (body2) => {
20564
20454
  const field = invokedInstanceField(current);
20565
20455
  if (field !== null) invoked.add(field);
20566
20456
  }
20567
- for (const key of Object.keys(current)) {
20568
- if (key === "parent") continue;
20569
- const value = current[key];
20570
- for (const child of Array.isArray(value) ? value : [value]) {
20571
- if (child !== null && typeof child === "object" && typeof child.type === "string") visit(child);
20572
- }
20573
- }
20457
+ forEachOwnAstChild(current, visit);
20574
20458
  };
20575
20459
  for (const member of body2.body) {
20576
20460
  if (member.type === import_utils111.AST_NODE_TYPES.StaticBlock || member.static) continue;
@@ -23278,7 +23162,7 @@ var RULES = {
23278
23162
  };
23279
23163
  var meta = {
23280
23164
  name: "@sarj/eslint-plugin",
23281
- version: "15.26.3"
23165
+ version: "15.26.5"
23282
23166
  };
23283
23167
  var APPLICATION_ONLY_RULES = [];
23284
23168
  var LIBRARY_IMPORT_POLICY = ["error", {
package/dist/index.d.cts CHANGED
@@ -996,7 +996,7 @@ type FlatPreset = {
996
996
  declare const PLUGIN: {
997
997
  readonly meta: {
998
998
  readonly name: "@sarj/eslint-plugin";
999
- readonly version: "15.26.3";
999
+ readonly version: "15.26.5";
1000
1000
  };
1001
1001
  readonly rules: {
1002
1002
  readonly "no-conditional-empty-object-spread": DocumentedRule<[], "avoid">;
package/dist/index.d.ts CHANGED
@@ -996,7 +996,7 @@ type FlatPreset = {
996
996
  declare const PLUGIN: {
997
997
  readonly meta: {
998
998
  readonly name: "@sarj/eslint-plugin";
999
- readonly version: "15.26.3";
999
+ readonly version: "15.26.5";
1000
1000
  };
1001
1001
  readonly rules: {
1002
1002
  readonly "no-conditional-empty-object-spread": DocumentedRule<[], "avoid">;
package/dist/index.js CHANGED
@@ -612,13 +612,17 @@ import ts3 from "typescript";
612
612
  // src/rules/_for-each-ast-child.ts
613
613
  function forEachAstChild(node, visitorKeys, visit) {
614
614
  for (const key of visitorKeys[node.type] ?? []) {
615
- const value = node[key];
616
- if (Array.isArray(value)) {
617
- const children = value;
618
- for (const child of children) if (isNode(child) && visit(child) === true) return true;
619
- } else if (isNode(value)) {
620
- if (visit(value) === true) return true;
621
- }
615
+ if (forEachAstChildKey(node, key, visit)) return true;
616
+ }
617
+ return false;
618
+ }
619
+ function forEachAstChildKey(node, key, visit) {
620
+ const value = node[key];
621
+ if (Array.isArray(value)) {
622
+ const children = value;
623
+ for (const child of children) if (isNode(child) && visit(child) === true) return true;
624
+ } else if (isNode(value)) {
625
+ if (visit(value) === true) return true;
622
626
  }
623
627
  return false;
624
628
  }
@@ -3425,6 +3429,17 @@ import {
3425
3429
  AST_NODE_TYPES as AST_NODE_TYPES22,
3426
3430
  ASTUtils as ASTUtils5
3427
3431
  } from "@typescript-eslint/utils";
3432
+
3433
+ // src/rules/_for-each-own-ast-child.ts
3434
+ function forEachOwnAstChild(node, visit, includeKey = () => true) {
3435
+ for (const key of Object.keys(node)) {
3436
+ if (key === "parent" || !includeKey(key)) continue;
3437
+ if (forEachAstChildKey(node, key, visit)) return true;
3438
+ }
3439
+ return false;
3440
+ }
3441
+
3442
+ // src/rules/no-cors-wildcard-with-credentials.ts
3428
3443
  var NO_CORS_WILDCARD_WITH_CREDENTIALS_DOCUMENTATION = {
3429
3444
  summary: "Disallow wildcard CORS origins when credentials are enabled.",
3430
3445
  rationale: "Reflecting every origin while allowing credentials can let an untrusted site read authenticated cross-origin responses.",
@@ -3517,25 +3532,11 @@ function subtreeContainsStarLiteral(node) {
3517
3532
  if (isStarLiteral(node)) {
3518
3533
  return true;
3519
3534
  }
3520
- for (const key of Object.keys(node)) {
3521
- if (key === "parent" || key === "loc" || key === "range") {
3522
- continue;
3523
- }
3524
- const value = node[key];
3525
- if (Array.isArray(value)) {
3526
- for (const child of value) {
3527
- if (isNode2(child) && subtreeContainsStarLiteral(child)) {
3528
- return true;
3529
- }
3530
- }
3531
- } else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
3532
- return true;
3533
- }
3534
- }
3535
- return false;
3536
- }
3537
- function isNode2(value) {
3538
- return typeof value === "object" && value !== null && typeof value.type === "string";
3535
+ return forEachOwnAstChild(
3536
+ node,
3537
+ subtreeContainsStarLiteral,
3538
+ (key) => key !== "loc" && key !== "range"
3539
+ );
3539
3540
  }
3540
3541
  function calleeName(node) {
3541
3542
  const callee = node.callee;
@@ -4082,17 +4083,7 @@ function isJoinedFragmentArray(node) {
4082
4083
  }
4083
4084
  function markConsumed(node, consumed) {
4084
4085
  consumed.add(node);
4085
- for (const key of Object.keys(node)) {
4086
- if (key === "parent") {
4087
- continue;
4088
- }
4089
- const value = node[key];
4090
- for (const child of Array.isArray(value) ? value : [value]) {
4091
- if (child !== null && typeof child === "object" && "type" in child) {
4092
- markConsumed(child, consumed);
4093
- }
4094
- }
4095
- }
4086
+ forEachOwnAstChild(node, (child) => markConsumed(child, consumed));
4096
4087
  }
4097
4088
  function createSqlListener(handler) {
4098
4089
  const consumed = /* @__PURE__ */ new WeakSet();
@@ -4717,9 +4708,6 @@ var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
4717
4708
  "Response",
4718
4709
  "AbortController"
4719
4710
  ]);
4720
- function isNode3(value) {
4721
- return typeof value === "object" && value !== null && typeof value.type === "string";
4722
- }
4723
4711
  function isPureCall(node) {
4724
4712
  const callee = node.callee;
4725
4713
  if (callee.type !== AST_NODE_TYPES27.MemberExpression) {
@@ -4757,27 +4745,7 @@ function subtreeMatches(stmt, predicate, descendIntoFunctions = false) {
4757
4745
  found = true;
4758
4746
  return;
4759
4747
  }
4760
- for (const key of Object.keys(current)) {
4761
- if (key === "parent") {
4762
- continue;
4763
- }
4764
- if (!descendIntoFunctions && NESTED_FUNCTION_TYPES.has(current.type) && key === "body") {
4765
- continue;
4766
- }
4767
- const value = current[key];
4768
- if (Array.isArray(value)) {
4769
- for (const child of value) {
4770
- if (isNode3(child)) {
4771
- visit(child);
4772
- }
4773
- }
4774
- } else if (isNode3(value)) {
4775
- visit(value);
4776
- }
4777
- if (found) {
4778
- return;
4779
- }
4780
- }
4748
+ forEachOwnAstChild(current, visit, (key) => descendIntoFunctions || !NESTED_FUNCTION_TYPES.has(current.type) || key !== "body");
4781
4749
  };
4782
4750
  visit(stmt);
4783
4751
  return found;
@@ -7151,17 +7119,7 @@ function nearestFunction(node) {
7151
7119
  }
7152
7120
  function walkOwnScope(node, predicate) {
7153
7121
  if (predicate(node)) return true;
7154
- for (const key of Object.keys(node)) {
7155
- if (key === "parent") continue;
7156
- const value = node[key];
7157
- for (const child of Array.isArray(value) ? value : [value]) {
7158
- if (typeof child === "object" && child !== null && typeof child.type === "string") {
7159
- const childNode = child;
7160
- if (!FUNCTION_TYPES3.has(childNode.type) && walkOwnScope(childNode, predicate)) return true;
7161
- }
7162
- }
7163
- }
7164
- return false;
7122
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES3.has(child.type) && walkOwnScope(child, predicate));
7165
7123
  }
7166
7124
  function isAssertion(node, context) {
7167
7125
  if (node.type !== AST_NODE_TYPES37.CallExpression) return false;
@@ -9948,7 +9906,7 @@ function isSentinelArgument(arg) {
9948
9906
  function isFunctionNode(node) {
9949
9907
  return node.type === AST_NODE_TYPES48.FunctionDeclaration || node.type === AST_NODE_TYPES48.FunctionExpression || node.type === AST_NODE_TYPES48.ArrowFunctionExpression;
9950
9908
  }
9951
- function isNode4(value) {
9909
+ function isNode2(value) {
9952
9910
  return typeof value === "object" && value !== null && typeof value.type === "string";
9953
9911
  }
9954
9912
  function walkWithinScope(node, visit) {
@@ -9964,21 +9922,10 @@ function walkWithinScope(node, visit) {
9964
9922
  if (isFunctionNode(current)) {
9965
9923
  return;
9966
9924
  }
9967
- for (const key of Object.keys(current)) {
9968
- if (key === "parent") {
9969
- continue;
9970
- }
9971
- const value = current[key];
9972
- if (Array.isArray(value)) {
9973
- for (const child of value) {
9974
- if (isNode4(child)) {
9975
- recurse(child);
9976
- }
9977
- }
9978
- } else if (isNode4(value)) {
9979
- recurse(value);
9980
- }
9981
- }
9925
+ forEachOwnAstChild(current, (child) => {
9926
+ recurse(child);
9927
+ return found;
9928
+ });
9982
9929
  };
9983
9930
  recurse(node);
9984
9931
  return found;
@@ -10025,22 +9972,10 @@ function subtreeReadsName(node, name) {
10025
9972
  if (shadowsName(current)) {
10026
9973
  return;
10027
9974
  }
10028
- for (const key of Object.keys(current)) {
10029
- if (key === "parent") {
10030
- continue;
10031
- }
10032
- if (isNonReadingProperty(current, key)) continue;
10033
- const value = current[key];
10034
- if (Array.isArray(value)) {
10035
- for (const child of value) {
10036
- if (isNode4(child)) {
10037
- recurse(child);
10038
- }
10039
- }
10040
- } else if (isNode4(value)) {
10041
- recurse(value);
10042
- }
10043
- }
9975
+ forEachOwnAstChild(current, (child) => {
9976
+ recurse(child);
9977
+ return found;
9978
+ }, (key) => !isNonReadingProperty(current, key));
10044
9979
  };
10045
9980
  recurse(node);
10046
9981
  return found;
@@ -10098,7 +10033,7 @@ function enclosingFunctionName(node) {
10098
10033
  let current = node.parent;
10099
10034
  while (current !== void 0 && current !== null) {
10100
10035
  if (isFunctionNode(current)) {
10101
- if ("id" in current && isNode4(current.id) && current.id.type === AST_NODE_TYPES48.Identifier) {
10036
+ if ("id" in current && isNode2(current.id) && current.id.type === AST_NODE_TYPES48.Identifier) {
10102
10037
  return current.id.name;
10103
10038
  }
10104
10039
  const parent = current.parent;
@@ -10159,14 +10094,10 @@ function tryReturnsSafeParse(catchNode) {
10159
10094
  visitChildren(current);
10160
10095
  };
10161
10096
  function visitChildren(current) {
10162
- for (const key of Object.keys(current)) {
10163
- if (key === "parent") continue;
10164
- const value = current[key];
10165
- const children = Array.isArray(value) ? value : [value];
10166
- for (const child of children) {
10167
- if (isNode4(child)) recurse(child);
10168
- }
10169
- }
10097
+ forEachOwnAstChild(current, (child) => {
10098
+ recurse(child);
10099
+ return sawUnsafeOperation;
10100
+ });
10170
10101
  }
10171
10102
  recurse(tryBlock);
10172
10103
  return sawSafeParse && !sawUnsafeOperation;
@@ -10203,7 +10134,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
10203
10134
  function enclosingFunctionBody(node) {
10204
10135
  let current = node.parent;
10205
10136
  while (current !== void 0 && current !== null) {
10206
- if (isFunctionNode(current) && "body" in current && isNode4(current.body) && current.body.type === AST_NODE_TYPES48.BlockStatement) {
10137
+ if (isFunctionNode(current) && "body" in current && isNode2(current.body) && current.body.type === AST_NODE_TYPES48.BlockStatement) {
10207
10138
  return current.body;
10208
10139
  }
10209
10140
  current = current.parent;
@@ -12313,16 +12244,7 @@ var subtreeReadsImportedBinding = (node, imported) => {
12313
12244
  if (node.type === AST_NODE_TYPES57.Identifier) {
12314
12245
  return imported.has(node.name);
12315
12246
  }
12316
- for (const key of Object.keys(node)) {
12317
- if (key === "parent") continue;
12318
- const value = node[key];
12319
- for (const child of Array.isArray(value) ? value : [value]) {
12320
- if (child !== null && typeof child === "object" && typeof child.type === "string" && subtreeReadsImportedBinding(child, imported)) {
12321
- return true;
12322
- }
12323
- }
12324
- }
12325
- return false;
12247
+ return forEachOwnAstChild(node, (child) => subtreeReadsImportedBinding(child, imported));
12326
12248
  };
12327
12249
  var isUseClientDirective = (node) => {
12328
12250
  return node.type === AST_NODE_TYPES57.ExpressionStatement && node.directive === "use client";
@@ -12973,23 +12895,7 @@ function walkOwnScope2(node, predicate) {
12973
12895
  if (predicate(node)) {
12974
12896
  return true;
12975
12897
  }
12976
- for (const key of Object.keys(node)) {
12977
- if (key === "parent") {
12978
- continue;
12979
- }
12980
- const value = node[key];
12981
- const children = Array.isArray(value) ? value : [value];
12982
- for (const child of children) {
12983
- if (typeof child !== "object" || child === null || typeof child.type !== "string") {
12984
- continue;
12985
- }
12986
- const childNode = child;
12987
- if (!FUNCTION_TYPES6.has(childNode.type) && walkOwnScope2(childNode, predicate)) {
12988
- return true;
12989
- }
12990
- }
12991
- }
12992
- return false;
12898
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES6.has(child.type) && walkOwnScope2(child, predicate));
12993
12899
  }
12994
12900
  function isAssertion2(node, isFrameworkAssertion) {
12995
12901
  if (node.type !== AST_NODE_TYPES62.CallExpression || !ASSERTION_ROOTS.has(callerName(node.callee) ?? "")) return false;
@@ -16871,15 +16777,10 @@ var isLocalFileRead = (node) => {
16871
16777
  found = true;
16872
16778
  return;
16873
16779
  }
16874
- for (const key of Object.keys(current)) {
16875
- if (key === "parent") continue;
16876
- const value = current[key];
16877
- for (const child of Array.isArray(value) ? value : [value]) {
16878
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
16879
- visit(child);
16880
- }
16881
- }
16882
- }
16780
+ forEachOwnAstChild(current, (child) => {
16781
+ visit(child);
16782
+ return found;
16783
+ });
16883
16784
  };
16884
16785
  visit(node);
16885
16786
  return found;
@@ -20429,15 +20330,9 @@ var readConstructor = (ctor, declared, typeParameters) => {
20429
20330
  }
20430
20331
  }
20431
20332
  function enqueueChildren(current) {
20432
- for (const key of Object.keys(current)) {
20433
- if (key === "parent") continue;
20434
- const value = current[key];
20435
- for (const child of Array.isArray(value) ? value : [value]) {
20436
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20437
- pending.push(child);
20438
- }
20439
- }
20440
- }
20333
+ forEachOwnAstChild(current, (child) => {
20334
+ pending.push(child);
20335
+ });
20441
20336
  }
20442
20337
  while (pending.length > 0) {
20443
20338
  const current = pending.pop();
@@ -20546,15 +20441,10 @@ var subtreeHas = (root, found) => {
20546
20441
  hit = true;
20547
20442
  return;
20548
20443
  }
20549
- for (const key of Object.keys(current)) {
20550
- if (key === "parent") continue;
20551
- const value = current[key];
20552
- for (const child of Array.isArray(value) ? value : [value]) {
20553
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20554
- visit(child);
20555
- }
20556
- }
20557
- }
20444
+ forEachOwnAstChild(current, (child) => {
20445
+ visit(child);
20446
+ return hit;
20447
+ });
20558
20448
  };
20559
20449
  visit(root);
20560
20450
  return hit;
@@ -20579,13 +20469,7 @@ var behaviorallyInvokedFields = (body2) => {
20579
20469
  const field = invokedInstanceField(current);
20580
20470
  if (field !== null) invoked.add(field);
20581
20471
  }
20582
- for (const key of Object.keys(current)) {
20583
- if (key === "parent") continue;
20584
- const value = current[key];
20585
- for (const child of Array.isArray(value) ? value : [value]) {
20586
- if (child !== null && typeof child === "object" && typeof child.type === "string") visit(child);
20587
- }
20588
- }
20472
+ forEachOwnAstChild(current, visit);
20589
20473
  };
20590
20474
  for (const member of body2.body) {
20591
20475
  if (member.type === AST_NODE_TYPES94.StaticBlock || member.static) continue;
@@ -23299,7 +23183,7 @@ var RULES = {
23299
23183
  };
23300
23184
  var meta = {
23301
23185
  name: "@sarj/eslint-plugin",
23302
- version: "15.26.3"
23186
+ version: "15.26.5"
23303
23187
  };
23304
23188
  var APPLICATION_ONLY_RULES = [];
23305
23189
  var LIBRARY_IMPORT_POLICY = ["error", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/eslint-plugin",
3
- "version": "15.26.3",
3
+ "version": "15.26.5",
4
4
  "packageManager": "npm@12.0.2",
5
5
  "description": "Custom ESLint rules for hypermodern TypeScript / React / Next.js projects",
6
6
  "type": "module",