@sarj/eslint-plugin 15.26.4 → 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
@@ -3465,6 +3465,17 @@ var no_comment_cruft_default = createRule({
3465
3465
 
3466
3466
  // src/rules/no-cors-wildcard-with-credentials.ts
3467
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
3468
3479
  var NO_CORS_WILDCARD_WITH_CREDENTIALS_DOCUMENTATION = {
3469
3480
  summary: "Disallow wildcard CORS origins when credentials are enabled.",
3470
3481
  rationale: "Reflecting every origin while allowing credentials can let an untrusted site read authenticated cross-origin responses.",
@@ -3557,25 +3568,11 @@ function subtreeContainsStarLiteral(node) {
3557
3568
  if (isStarLiteral(node)) {
3558
3569
  return true;
3559
3570
  }
3560
- for (const key of Object.keys(node)) {
3561
- if (key === "parent" || key === "loc" || key === "range") {
3562
- continue;
3563
- }
3564
- const value = node[key];
3565
- if (Array.isArray(value)) {
3566
- for (const child of value) {
3567
- if (isNode2(child) && subtreeContainsStarLiteral(child)) {
3568
- return true;
3569
- }
3570
- }
3571
- } else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
3572
- return true;
3573
- }
3574
- }
3575
- return false;
3576
- }
3577
- function isNode2(value) {
3578
- return typeof value === "object" && value !== null && typeof value.type === "string";
3571
+ return forEachOwnAstChild(
3572
+ node,
3573
+ subtreeContainsStarLiteral,
3574
+ (key) => key !== "loc" && key !== "range"
3575
+ );
3579
3576
  }
3580
3577
  function calleeName(node) {
3581
3578
  const callee = node.callee;
@@ -3991,17 +3988,6 @@ var import_utils27 = require("@typescript-eslint/utils");
3991
3988
 
3992
3989
  // src/rules/_sql.ts
3993
3990
  var import_utils26 = require("@typescript-eslint/utils");
3994
-
3995
- // src/rules/_for-each-own-ast-child.ts
3996
- function forEachOwnAstChild(node, visit, includeKey = () => true) {
3997
- for (const key of Object.keys(node)) {
3998
- if (key === "parent" || !includeKey(key)) continue;
3999
- if (forEachAstChildKey(node, key, visit)) return true;
4000
- }
4001
- return false;
4002
- }
4003
-
4004
- // src/rules/_sql.ts
4005
3991
  function stripSqlNoise(text) {
4006
3992
  return scanSqlNoise(text);
4007
3993
  }
@@ -9938,7 +9924,7 @@ function isSentinelArgument(arg) {
9938
9924
  function isFunctionNode(node) {
9939
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;
9940
9926
  }
9941
- function isNode3(value) {
9927
+ function isNode2(value) {
9942
9928
  return typeof value === "object" && value !== null && typeof value.type === "string";
9943
9929
  }
9944
9930
  function walkWithinScope(node, visit) {
@@ -10065,7 +10051,7 @@ function enclosingFunctionName(node) {
10065
10051
  let current = node.parent;
10066
10052
  while (current !== void 0 && current !== null) {
10067
10053
  if (isFunctionNode(current)) {
10068
- if ("id" in current && isNode3(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) {
10069
10055
  return current.id.name;
10070
10056
  }
10071
10057
  const parent = current.parent;
@@ -10166,7 +10152,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
10166
10152
  function enclosingFunctionBody(node) {
10167
10153
  let current = node.parent;
10168
10154
  while (current !== void 0 && current !== null) {
10169
- if (isFunctionNode(current) && "body" in current && isNode3(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) {
10170
10156
  return current.body;
10171
10157
  }
10172
10158
  current = current.parent;
@@ -12276,16 +12262,7 @@ var subtreeReadsImportedBinding = (node, imported) => {
12276
12262
  if (node.type === import_utils72.AST_NODE_TYPES.Identifier) {
12277
12263
  return imported.has(node.name);
12278
12264
  }
12279
- for (const key of Object.keys(node)) {
12280
- if (key === "parent") continue;
12281
- const value = node[key];
12282
- for (const child of Array.isArray(value) ? value : [value]) {
12283
- if (child !== null && typeof child === "object" && typeof child.type === "string" && subtreeReadsImportedBinding(child, imported)) {
12284
- return true;
12285
- }
12286
- }
12287
- }
12288
- return false;
12265
+ return forEachOwnAstChild(node, (child) => subtreeReadsImportedBinding(child, imported));
12289
12266
  };
12290
12267
  var isUseClientDirective = (node) => {
12291
12268
  return node.type === import_utils72.AST_NODE_TYPES.ExpressionStatement && node.directive === "use client";
@@ -12929,23 +12906,7 @@ function walkOwnScope2(node, predicate) {
12929
12906
  if (predicate(node)) {
12930
12907
  return true;
12931
12908
  }
12932
- for (const key of Object.keys(node)) {
12933
- if (key === "parent") {
12934
- continue;
12935
- }
12936
- const value = node[key];
12937
- const children = Array.isArray(value) ? value : [value];
12938
- for (const child of children) {
12939
- if (typeof child !== "object" || child === null || typeof child.type !== "string") {
12940
- continue;
12941
- }
12942
- const childNode = child;
12943
- if (!FUNCTION_TYPES6.has(childNode.type) && walkOwnScope2(childNode, predicate)) {
12944
- return true;
12945
- }
12946
- }
12947
- }
12948
- return false;
12909
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES6.has(child.type) && walkOwnScope2(child, predicate));
12949
12910
  }
12950
12911
  function isAssertion2(node, isFrameworkAssertion) {
12951
12912
  if (node.type !== import_utils77.AST_NODE_TYPES.CallExpression || !ASSERTION_ROOTS.has(callerName(node.callee) ?? "")) return false;
@@ -16807,15 +16768,10 @@ var isLocalFileRead = (node) => {
16807
16768
  found = true;
16808
16769
  return;
16809
16770
  }
16810
- for (const key of Object.keys(current)) {
16811
- if (key === "parent") continue;
16812
- const value = current[key];
16813
- for (const child of Array.isArray(value) ? value : [value]) {
16814
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
16815
- visit(child);
16816
- }
16817
- }
16818
- }
16771
+ forEachOwnAstChild(current, (child) => {
16772
+ visit(child);
16773
+ return found;
16774
+ });
16819
16775
  };
16820
16776
  visit(node);
16821
16777
  return found;
@@ -20359,15 +20315,9 @@ var readConstructor = (ctor, declared, typeParameters) => {
20359
20315
  }
20360
20316
  }
20361
20317
  function enqueueChildren(current) {
20362
- for (const key of Object.keys(current)) {
20363
- if (key === "parent") continue;
20364
- const value = current[key];
20365
- for (const child of Array.isArray(value) ? value : [value]) {
20366
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20367
- pending.push(child);
20368
- }
20369
- }
20370
- }
20318
+ forEachOwnAstChild(current, (child) => {
20319
+ pending.push(child);
20320
+ });
20371
20321
  }
20372
20322
  while (pending.length > 0) {
20373
20323
  const current = pending.pop();
@@ -20476,15 +20426,10 @@ var subtreeHas = (root, found) => {
20476
20426
  hit = true;
20477
20427
  return;
20478
20428
  }
20479
- for (const key of Object.keys(current)) {
20480
- if (key === "parent") continue;
20481
- const value = current[key];
20482
- for (const child of Array.isArray(value) ? value : [value]) {
20483
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20484
- visit(child);
20485
- }
20486
- }
20487
- }
20429
+ forEachOwnAstChild(current, (child) => {
20430
+ visit(child);
20431
+ return hit;
20432
+ });
20488
20433
  };
20489
20434
  visit(root);
20490
20435
  return hit;
@@ -20509,13 +20454,7 @@ var behaviorallyInvokedFields = (body2) => {
20509
20454
  const field = invokedInstanceField(current);
20510
20455
  if (field !== null) invoked.add(field);
20511
20456
  }
20512
- for (const key of Object.keys(current)) {
20513
- if (key === "parent") continue;
20514
- const value = current[key];
20515
- for (const child of Array.isArray(value) ? value : [value]) {
20516
- if (child !== null && typeof child === "object" && typeof child.type === "string") visit(child);
20517
- }
20518
- }
20457
+ forEachOwnAstChild(current, visit);
20519
20458
  };
20520
20459
  for (const member of body2.body) {
20521
20460
  if (member.type === import_utils111.AST_NODE_TYPES.StaticBlock || member.static) continue;
@@ -23223,7 +23162,7 @@ var RULES = {
23223
23162
  };
23224
23163
  var meta = {
23225
23164
  name: "@sarj/eslint-plugin",
23226
- version: "15.26.4"
23165
+ version: "15.26.5"
23227
23166
  };
23228
23167
  var APPLICATION_ONLY_RULES = [];
23229
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.4";
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.4";
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
@@ -3429,6 +3429,17 @@ import {
3429
3429
  AST_NODE_TYPES as AST_NODE_TYPES22,
3430
3430
  ASTUtils as ASTUtils5
3431
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
3432
3443
  var NO_CORS_WILDCARD_WITH_CREDENTIALS_DOCUMENTATION = {
3433
3444
  summary: "Disallow wildcard CORS origins when credentials are enabled.",
3434
3445
  rationale: "Reflecting every origin while allowing credentials can let an untrusted site read authenticated cross-origin responses.",
@@ -3521,25 +3532,11 @@ function subtreeContainsStarLiteral(node) {
3521
3532
  if (isStarLiteral(node)) {
3522
3533
  return true;
3523
3534
  }
3524
- for (const key of Object.keys(node)) {
3525
- if (key === "parent" || key === "loc" || key === "range") {
3526
- continue;
3527
- }
3528
- const value = node[key];
3529
- if (Array.isArray(value)) {
3530
- for (const child of value) {
3531
- if (isNode2(child) && subtreeContainsStarLiteral(child)) {
3532
- return true;
3533
- }
3534
- }
3535
- } else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
3536
- return true;
3537
- }
3538
- }
3539
- return false;
3540
- }
3541
- function isNode2(value) {
3542
- return typeof value === "object" && value !== null && typeof value.type === "string";
3535
+ return forEachOwnAstChild(
3536
+ node,
3537
+ subtreeContainsStarLiteral,
3538
+ (key) => key !== "loc" && key !== "range"
3539
+ );
3543
3540
  }
3544
3541
  function calleeName(node) {
3545
3542
  const callee = node.callee;
@@ -3955,17 +3952,6 @@ import { AST_NODE_TYPES as AST_NODE_TYPES25 } from "@typescript-eslint/utils";
3955
3952
 
3956
3953
  // src/rules/_sql.ts
3957
3954
  import { AST_NODE_TYPES as AST_NODE_TYPES24 } from "@typescript-eslint/utils";
3958
-
3959
- // src/rules/_for-each-own-ast-child.ts
3960
- function forEachOwnAstChild(node, visit, includeKey = () => true) {
3961
- for (const key of Object.keys(node)) {
3962
- if (key === "parent" || !includeKey(key)) continue;
3963
- if (forEachAstChildKey(node, key, visit)) return true;
3964
- }
3965
- return false;
3966
- }
3967
-
3968
- // src/rules/_sql.ts
3969
3955
  function stripSqlNoise(text) {
3970
3956
  return scanSqlNoise(text);
3971
3957
  }
@@ -9920,7 +9906,7 @@ function isSentinelArgument(arg) {
9920
9906
  function isFunctionNode(node) {
9921
9907
  return node.type === AST_NODE_TYPES48.FunctionDeclaration || node.type === AST_NODE_TYPES48.FunctionExpression || node.type === AST_NODE_TYPES48.ArrowFunctionExpression;
9922
9908
  }
9923
- function isNode3(value) {
9909
+ function isNode2(value) {
9924
9910
  return typeof value === "object" && value !== null && typeof value.type === "string";
9925
9911
  }
9926
9912
  function walkWithinScope(node, visit) {
@@ -10047,7 +10033,7 @@ function enclosingFunctionName(node) {
10047
10033
  let current = node.parent;
10048
10034
  while (current !== void 0 && current !== null) {
10049
10035
  if (isFunctionNode(current)) {
10050
- if ("id" in current && isNode3(current.id) && current.id.type === AST_NODE_TYPES48.Identifier) {
10036
+ if ("id" in current && isNode2(current.id) && current.id.type === AST_NODE_TYPES48.Identifier) {
10051
10037
  return current.id.name;
10052
10038
  }
10053
10039
  const parent = current.parent;
@@ -10148,7 +10134,7 @@ function functionReturnsSameSentinelKindElsewhere(catchNode, kind) {
10148
10134
  function enclosingFunctionBody(node) {
10149
10135
  let current = node.parent;
10150
10136
  while (current !== void 0 && current !== null) {
10151
- if (isFunctionNode(current) && "body" in current && isNode3(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) {
10152
10138
  return current.body;
10153
10139
  }
10154
10140
  current = current.parent;
@@ -12258,16 +12244,7 @@ var subtreeReadsImportedBinding = (node, imported) => {
12258
12244
  if (node.type === AST_NODE_TYPES57.Identifier) {
12259
12245
  return imported.has(node.name);
12260
12246
  }
12261
- for (const key of Object.keys(node)) {
12262
- if (key === "parent") continue;
12263
- const value = node[key];
12264
- for (const child of Array.isArray(value) ? value : [value]) {
12265
- if (child !== null && typeof child === "object" && typeof child.type === "string" && subtreeReadsImportedBinding(child, imported)) {
12266
- return true;
12267
- }
12268
- }
12269
- }
12270
- return false;
12247
+ return forEachOwnAstChild(node, (child) => subtreeReadsImportedBinding(child, imported));
12271
12248
  };
12272
12249
  var isUseClientDirective = (node) => {
12273
12250
  return node.type === AST_NODE_TYPES57.ExpressionStatement && node.directive === "use client";
@@ -12918,23 +12895,7 @@ function walkOwnScope2(node, predicate) {
12918
12895
  if (predicate(node)) {
12919
12896
  return true;
12920
12897
  }
12921
- for (const key of Object.keys(node)) {
12922
- if (key === "parent") {
12923
- continue;
12924
- }
12925
- const value = node[key];
12926
- const children = Array.isArray(value) ? value : [value];
12927
- for (const child of children) {
12928
- if (typeof child !== "object" || child === null || typeof child.type !== "string") {
12929
- continue;
12930
- }
12931
- const childNode = child;
12932
- if (!FUNCTION_TYPES6.has(childNode.type) && walkOwnScope2(childNode, predicate)) {
12933
- return true;
12934
- }
12935
- }
12936
- }
12937
- return false;
12898
+ return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES6.has(child.type) && walkOwnScope2(child, predicate));
12938
12899
  }
12939
12900
  function isAssertion2(node, isFrameworkAssertion) {
12940
12901
  if (node.type !== AST_NODE_TYPES62.CallExpression || !ASSERTION_ROOTS.has(callerName(node.callee) ?? "")) return false;
@@ -16816,15 +16777,10 @@ var isLocalFileRead = (node) => {
16816
16777
  found = true;
16817
16778
  return;
16818
16779
  }
16819
- for (const key of Object.keys(current)) {
16820
- if (key === "parent") continue;
16821
- const value = current[key];
16822
- for (const child of Array.isArray(value) ? value : [value]) {
16823
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
16824
- visit(child);
16825
- }
16826
- }
16827
- }
16780
+ forEachOwnAstChild(current, (child) => {
16781
+ visit(child);
16782
+ return found;
16783
+ });
16828
16784
  };
16829
16785
  visit(node);
16830
16786
  return found;
@@ -20374,15 +20330,9 @@ var readConstructor = (ctor, declared, typeParameters) => {
20374
20330
  }
20375
20331
  }
20376
20332
  function enqueueChildren(current) {
20377
- for (const key of Object.keys(current)) {
20378
- if (key === "parent") continue;
20379
- const value = current[key];
20380
- for (const child of Array.isArray(value) ? value : [value]) {
20381
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20382
- pending.push(child);
20383
- }
20384
- }
20385
- }
20333
+ forEachOwnAstChild(current, (child) => {
20334
+ pending.push(child);
20335
+ });
20386
20336
  }
20387
20337
  while (pending.length > 0) {
20388
20338
  const current = pending.pop();
@@ -20491,15 +20441,10 @@ var subtreeHas = (root, found) => {
20491
20441
  hit = true;
20492
20442
  return;
20493
20443
  }
20494
- for (const key of Object.keys(current)) {
20495
- if (key === "parent") continue;
20496
- const value = current[key];
20497
- for (const child of Array.isArray(value) ? value : [value]) {
20498
- if (child !== null && typeof child === "object" && typeof child.type === "string") {
20499
- visit(child);
20500
- }
20501
- }
20502
- }
20444
+ forEachOwnAstChild(current, (child) => {
20445
+ visit(child);
20446
+ return hit;
20447
+ });
20503
20448
  };
20504
20449
  visit(root);
20505
20450
  return hit;
@@ -20524,13 +20469,7 @@ var behaviorallyInvokedFields = (body2) => {
20524
20469
  const field = invokedInstanceField(current);
20525
20470
  if (field !== null) invoked.add(field);
20526
20471
  }
20527
- for (const key of Object.keys(current)) {
20528
- if (key === "parent") continue;
20529
- const value = current[key];
20530
- for (const child of Array.isArray(value) ? value : [value]) {
20531
- if (child !== null && typeof child === "object" && typeof child.type === "string") visit(child);
20532
- }
20533
- }
20472
+ forEachOwnAstChild(current, visit);
20534
20473
  };
20535
20474
  for (const member of body2.body) {
20536
20475
  if (member.type === AST_NODE_TYPES94.StaticBlock || member.static) continue;
@@ -23244,7 +23183,7 @@ var RULES = {
23244
23183
  };
23245
23184
  var meta = {
23246
23185
  name: "@sarj/eslint-plugin",
23247
- version: "15.26.4"
23186
+ version: "15.26.5"
23248
23187
  };
23249
23188
  var APPLICATION_ONLY_RULES = [];
23250
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.4",
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",