@sarj/eslint-plugin 15.26.2 → 15.26.4
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 +57 -119
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +57 -119
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -652,6 +652,29 @@ var no_broad_return_type_default = createRule({
|
|
|
652
652
|
// src/rules/no-reduce-accumulator-copy.ts
|
|
653
653
|
var import_utils5 = require("@typescript-eslint/utils");
|
|
654
654
|
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
655
|
+
|
|
656
|
+
// src/rules/_for-each-ast-child.ts
|
|
657
|
+
function forEachAstChild(node, visitorKeys, visit) {
|
|
658
|
+
for (const key of visitorKeys[node.type] ?? []) {
|
|
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;
|
|
670
|
+
}
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
function isNode(value) {
|
|
674
|
+
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// src/rules/no-reduce-accumulator-copy.ts
|
|
655
678
|
var NO_REDUCE_ACCUMULATOR_COPY_DOCUMENTATION = {
|
|
656
679
|
summary: "Review copies of the accumulated collection inside a built-in reduce callback.",
|
|
657
680
|
rationale: "Copying a growing accumulator at every step can make collection quadratic instead of linear in its output size.",
|
|
@@ -722,12 +745,7 @@ var no_reduce_accumulator_copy_default = createRule({
|
|
|
722
745
|
context.report({ node: current, messageId: "copy" });
|
|
723
746
|
}
|
|
724
747
|
if (current.type === import_utils5.AST_NODE_TYPES.CallExpression) inspectCall(current);
|
|
725
|
-
|
|
726
|
-
const child = current[key];
|
|
727
|
-
if (Array.isArray(child)) {
|
|
728
|
-
for (const item of child) if (item !== null && typeof item === "object" && "type" in item) inspect(item);
|
|
729
|
-
} else if (child !== null && typeof child === "object" && "type" in child) inspect(child);
|
|
730
|
-
}
|
|
748
|
+
forEachAstChild(current, context.sourceCode.visitorKeys, inspect);
|
|
731
749
|
};
|
|
732
750
|
inspect(callback.body);
|
|
733
751
|
}
|
|
@@ -3546,17 +3564,17 @@ function subtreeContainsStarLiteral(node) {
|
|
|
3546
3564
|
const value = node[key];
|
|
3547
3565
|
if (Array.isArray(value)) {
|
|
3548
3566
|
for (const child of value) {
|
|
3549
|
-
if (
|
|
3567
|
+
if (isNode2(child) && subtreeContainsStarLiteral(child)) {
|
|
3550
3568
|
return true;
|
|
3551
3569
|
}
|
|
3552
3570
|
}
|
|
3553
|
-
} else if (
|
|
3571
|
+
} else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
|
|
3554
3572
|
return true;
|
|
3555
3573
|
}
|
|
3556
3574
|
}
|
|
3557
3575
|
return false;
|
|
3558
3576
|
}
|
|
3559
|
-
function
|
|
3577
|
+
function isNode2(value) {
|
|
3560
3578
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
3561
3579
|
}
|
|
3562
3580
|
function calleeName(node) {
|
|
@@ -3973,6 +3991,17 @@ var import_utils27 = require("@typescript-eslint/utils");
|
|
|
3973
3991
|
|
|
3974
3992
|
// src/rules/_sql.ts
|
|
3975
3993
|
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
|
|
3976
4005
|
function stripSqlNoise(text) {
|
|
3977
4006
|
return scanSqlNoise(text);
|
|
3978
4007
|
}
|
|
@@ -4104,17 +4133,7 @@ function isJoinedFragmentArray(node) {
|
|
|
4104
4133
|
}
|
|
4105
4134
|
function markConsumed(node, consumed) {
|
|
4106
4135
|
consumed.add(node);
|
|
4107
|
-
|
|
4108
|
-
if (key === "parent") {
|
|
4109
|
-
continue;
|
|
4110
|
-
}
|
|
4111
|
-
const value = node[key];
|
|
4112
|
-
for (const child of Array.isArray(value) ? value : [value]) {
|
|
4113
|
-
if (child !== null && typeof child === "object" && "type" in child) {
|
|
4114
|
-
markConsumed(child, consumed);
|
|
4115
|
-
}
|
|
4116
|
-
}
|
|
4117
|
-
}
|
|
4136
|
+
forEachOwnAstChild(node, (child) => markConsumed(child, consumed));
|
|
4118
4137
|
}
|
|
4119
4138
|
function createSqlListener(handler) {
|
|
4120
4139
|
const consumed = /* @__PURE__ */ new WeakSet();
|
|
@@ -4570,15 +4589,7 @@ function functionComplexity(fn, visitorKeys) {
|
|
|
4570
4589
|
visitChildren(node, nesting);
|
|
4571
4590
|
}
|
|
4572
4591
|
function visitChildren(node, nesting) {
|
|
4573
|
-
|
|
4574
|
-
const value = node[key];
|
|
4575
|
-
const candidates = Array.isArray(value) ? value : [value];
|
|
4576
|
-
for (const candidate2 of candidates) {
|
|
4577
|
-
if (typeof candidate2 === "object" && candidate2 !== null && "type" in candidate2) {
|
|
4578
|
-
visit(candidate2, nesting);
|
|
4579
|
-
}
|
|
4580
|
-
}
|
|
4581
|
-
}
|
|
4592
|
+
forEachAstChild(node, visitorKeys, (child) => visit(child, nesting));
|
|
4582
4593
|
}
|
|
4583
4594
|
visit(fn.body, 0);
|
|
4584
4595
|
return points;
|
|
@@ -4747,9 +4758,6 @@ var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4747
4758
|
"Response",
|
|
4748
4759
|
"AbortController"
|
|
4749
4760
|
]);
|
|
4750
|
-
function isNode2(value) {
|
|
4751
|
-
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
4752
|
-
}
|
|
4753
4761
|
function isPureCall(node) {
|
|
4754
4762
|
const callee = node.callee;
|
|
4755
4763
|
if (callee.type !== import_utils30.AST_NODE_TYPES.MemberExpression) {
|
|
@@ -4787,27 +4795,7 @@ function subtreeMatches(stmt, predicate, descendIntoFunctions = false) {
|
|
|
4787
4795
|
found = true;
|
|
4788
4796
|
return;
|
|
4789
4797
|
}
|
|
4790
|
-
|
|
4791
|
-
if (key === "parent") {
|
|
4792
|
-
continue;
|
|
4793
|
-
}
|
|
4794
|
-
if (!descendIntoFunctions && NESTED_FUNCTION_TYPES.has(current.type) && key === "body") {
|
|
4795
|
-
continue;
|
|
4796
|
-
}
|
|
4797
|
-
const value = current[key];
|
|
4798
|
-
if (Array.isArray(value)) {
|
|
4799
|
-
for (const child of value) {
|
|
4800
|
-
if (isNode2(child)) {
|
|
4801
|
-
visit(child);
|
|
4802
|
-
}
|
|
4803
|
-
}
|
|
4804
|
-
} else if (isNode2(value)) {
|
|
4805
|
-
visit(value);
|
|
4806
|
-
}
|
|
4807
|
-
if (found) {
|
|
4808
|
-
return;
|
|
4809
|
-
}
|
|
4810
|
-
}
|
|
4798
|
+
forEachOwnAstChild(current, visit, (key) => descendIntoFunctions || !NESTED_FUNCTION_TYPES.has(current.type) || key !== "body");
|
|
4811
4799
|
};
|
|
4812
4800
|
visit(stmt);
|
|
4813
4801
|
return found;
|
|
@@ -7163,17 +7151,7 @@ function nearestFunction(node) {
|
|
|
7163
7151
|
}
|
|
7164
7152
|
function walkOwnScope(node, predicate) {
|
|
7165
7153
|
if (predicate(node)) return true;
|
|
7166
|
-
|
|
7167
|
-
if (key === "parent") continue;
|
|
7168
|
-
const value = node[key];
|
|
7169
|
-
for (const child of Array.isArray(value) ? value : [value]) {
|
|
7170
|
-
if (typeof child === "object" && child !== null && typeof child.type === "string") {
|
|
7171
|
-
const childNode = child;
|
|
7172
|
-
if (!FUNCTION_TYPES3.has(childNode.type) && walkOwnScope(childNode, predicate)) return true;
|
|
7173
|
-
}
|
|
7174
|
-
}
|
|
7175
|
-
}
|
|
7176
|
-
return false;
|
|
7154
|
+
return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES3.has(child.type) && walkOwnScope(child, predicate));
|
|
7177
7155
|
}
|
|
7178
7156
|
function isAssertion(node, context) {
|
|
7179
7157
|
if (node.type !== import_utils44.AST_NODE_TYPES.CallExpression) return false;
|
|
@@ -9976,21 +9954,10 @@ function walkWithinScope(node, visit) {
|
|
|
9976
9954
|
if (isFunctionNode(current)) {
|
|
9977
9955
|
return;
|
|
9978
9956
|
}
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
const value = current[key];
|
|
9984
|
-
if (Array.isArray(value)) {
|
|
9985
|
-
for (const child of value) {
|
|
9986
|
-
if (isNode3(child)) {
|
|
9987
|
-
recurse(child);
|
|
9988
|
-
}
|
|
9989
|
-
}
|
|
9990
|
-
} else if (isNode3(value)) {
|
|
9991
|
-
recurse(value);
|
|
9992
|
-
}
|
|
9993
|
-
}
|
|
9957
|
+
forEachOwnAstChild(current, (child) => {
|
|
9958
|
+
recurse(child);
|
|
9959
|
+
return found;
|
|
9960
|
+
});
|
|
9994
9961
|
};
|
|
9995
9962
|
recurse(node);
|
|
9996
9963
|
return found;
|
|
@@ -10037,22 +10004,10 @@ function subtreeReadsName(node, name) {
|
|
|
10037
10004
|
if (shadowsName(current)) {
|
|
10038
10005
|
return;
|
|
10039
10006
|
}
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
if (isNonReadingProperty(current, key)) continue;
|
|
10045
|
-
const value = current[key];
|
|
10046
|
-
if (Array.isArray(value)) {
|
|
10047
|
-
for (const child of value) {
|
|
10048
|
-
if (isNode3(child)) {
|
|
10049
|
-
recurse(child);
|
|
10050
|
-
}
|
|
10051
|
-
}
|
|
10052
|
-
} else if (isNode3(value)) {
|
|
10053
|
-
recurse(value);
|
|
10054
|
-
}
|
|
10055
|
-
}
|
|
10007
|
+
forEachOwnAstChild(current, (child) => {
|
|
10008
|
+
recurse(child);
|
|
10009
|
+
return found;
|
|
10010
|
+
}, (key) => !isNonReadingProperty(current, key));
|
|
10056
10011
|
};
|
|
10057
10012
|
recurse(node);
|
|
10058
10013
|
return found;
|
|
@@ -10171,14 +10126,10 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
10171
10126
|
visitChildren(current);
|
|
10172
10127
|
};
|
|
10173
10128
|
function visitChildren(current) {
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
for (const child of children) {
|
|
10179
|
-
if (isNode3(child)) recurse(child);
|
|
10180
|
-
}
|
|
10181
|
-
}
|
|
10129
|
+
forEachOwnAstChild(current, (child) => {
|
|
10130
|
+
recurse(child);
|
|
10131
|
+
return sawUnsafeOperation;
|
|
10132
|
+
});
|
|
10182
10133
|
}
|
|
10183
10134
|
recurse(tryBlock);
|
|
10184
10135
|
return sawSafeParse && !sawUnsafeOperation;
|
|
@@ -16315,13 +16266,7 @@ function isEmptyGuard(node, access) {
|
|
|
16315
16266
|
}
|
|
16316
16267
|
function contains(node, visitorKeys, predicate) {
|
|
16317
16268
|
if (predicate(node)) return true;
|
|
16318
|
-
|
|
16319
|
-
const child = node[key];
|
|
16320
|
-
for (const value of Array.isArray(child) ? child : [child]) {
|
|
16321
|
-
if (value !== null && typeof value === "object" && "type" in value && contains(value, visitorKeys, predicate)) return true;
|
|
16322
|
-
}
|
|
16323
|
-
}
|
|
16324
|
-
return false;
|
|
16269
|
+
return forEachAstChild(node, visitorKeys, (child) => contains(child, visitorKeys, predicate));
|
|
16325
16270
|
}
|
|
16326
16271
|
function belongsToFunction(node, fn) {
|
|
16327
16272
|
let current = node;
|
|
@@ -22085,14 +22030,7 @@ function referencedPropertyName(node) {
|
|
|
22085
22030
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
22086
22031
|
visit(node, nestedFunction);
|
|
22087
22032
|
const nested = nestedFunction || isFunction(node);
|
|
22088
|
-
|
|
22089
|
-
const child = node[key];
|
|
22090
|
-
if (Array.isArray(child)) {
|
|
22091
|
-
for (const item of child) if (typeof item === "object" && item !== null && "type" in item) walk(item, visitorKeys, visit, nested);
|
|
22092
|
-
} else if (typeof child === "object" && child !== null && "type" in child) {
|
|
22093
|
-
walk(child, visitorKeys, visit, nested);
|
|
22094
|
-
}
|
|
22095
|
-
}
|
|
22033
|
+
forEachAstChild(node, visitorKeys, (child) => walk(child, visitorKeys, visit, nested));
|
|
22096
22034
|
}
|
|
22097
22035
|
function classScope(context, node, computedReferenceNames) {
|
|
22098
22036
|
const methods = node.body.body.filter(
|
|
@@ -23285,7 +23223,7 @@ var RULES = {
|
|
|
23285
23223
|
};
|
|
23286
23224
|
var meta = {
|
|
23287
23225
|
name: "@sarj/eslint-plugin",
|
|
23288
|
-
version: "15.26.
|
|
23226
|
+
version: "15.26.4"
|
|
23289
23227
|
};
|
|
23290
23228
|
var APPLICATION_ONLY_RULES = [];
|
|
23291
23229
|
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.
|
|
999
|
+
readonly version: "15.26.4";
|
|
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.
|
|
999
|
+
readonly version: "15.26.4";
|
|
1000
1000
|
};
|
|
1001
1001
|
readonly rules: {
|
|
1002
1002
|
readonly "no-conditional-empty-object-spread": DocumentedRule<[], "avoid">;
|
package/dist/index.js
CHANGED
|
@@ -608,6 +608,29 @@ var no_broad_return_type_default = createRule({
|
|
|
608
608
|
// src/rules/no-reduce-accumulator-copy.ts
|
|
609
609
|
import { AST_NODE_TYPES as AST_NODE_TYPES4, ASTUtils as ASTUtils2, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
610
610
|
import ts3 from "typescript";
|
|
611
|
+
|
|
612
|
+
// src/rules/_for-each-ast-child.ts
|
|
613
|
+
function forEachAstChild(node, visitorKeys, visit) {
|
|
614
|
+
for (const key of visitorKeys[node.type] ?? []) {
|
|
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;
|
|
626
|
+
}
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
function isNode(value) {
|
|
630
|
+
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// src/rules/no-reduce-accumulator-copy.ts
|
|
611
634
|
var NO_REDUCE_ACCUMULATOR_COPY_DOCUMENTATION = {
|
|
612
635
|
summary: "Review copies of the accumulated collection inside a built-in reduce callback.",
|
|
613
636
|
rationale: "Copying a growing accumulator at every step can make collection quadratic instead of linear in its output size.",
|
|
@@ -678,12 +701,7 @@ var no_reduce_accumulator_copy_default = createRule({
|
|
|
678
701
|
context.report({ node: current, messageId: "copy" });
|
|
679
702
|
}
|
|
680
703
|
if (current.type === AST_NODE_TYPES4.CallExpression) inspectCall(current);
|
|
681
|
-
|
|
682
|
-
const child = current[key];
|
|
683
|
-
if (Array.isArray(child)) {
|
|
684
|
-
for (const item of child) if (item !== null && typeof item === "object" && "type" in item) inspect(item);
|
|
685
|
-
} else if (child !== null && typeof child === "object" && "type" in child) inspect(child);
|
|
686
|
-
}
|
|
704
|
+
forEachAstChild(current, context.sourceCode.visitorKeys, inspect);
|
|
687
705
|
};
|
|
688
706
|
inspect(callback.body);
|
|
689
707
|
}
|
|
@@ -3510,17 +3528,17 @@ function subtreeContainsStarLiteral(node) {
|
|
|
3510
3528
|
const value = node[key];
|
|
3511
3529
|
if (Array.isArray(value)) {
|
|
3512
3530
|
for (const child of value) {
|
|
3513
|
-
if (
|
|
3531
|
+
if (isNode2(child) && subtreeContainsStarLiteral(child)) {
|
|
3514
3532
|
return true;
|
|
3515
3533
|
}
|
|
3516
3534
|
}
|
|
3517
|
-
} else if (
|
|
3535
|
+
} else if (isNode2(value) && subtreeContainsStarLiteral(value)) {
|
|
3518
3536
|
return true;
|
|
3519
3537
|
}
|
|
3520
3538
|
}
|
|
3521
3539
|
return false;
|
|
3522
3540
|
}
|
|
3523
|
-
function
|
|
3541
|
+
function isNode2(value) {
|
|
3524
3542
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
3525
3543
|
}
|
|
3526
3544
|
function calleeName(node) {
|
|
@@ -3937,6 +3955,17 @@ import { AST_NODE_TYPES as AST_NODE_TYPES25 } from "@typescript-eslint/utils";
|
|
|
3937
3955
|
|
|
3938
3956
|
// src/rules/_sql.ts
|
|
3939
3957
|
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
|
|
3940
3969
|
function stripSqlNoise(text) {
|
|
3941
3970
|
return scanSqlNoise(text);
|
|
3942
3971
|
}
|
|
@@ -4068,17 +4097,7 @@ function isJoinedFragmentArray(node) {
|
|
|
4068
4097
|
}
|
|
4069
4098
|
function markConsumed(node, consumed) {
|
|
4070
4099
|
consumed.add(node);
|
|
4071
|
-
|
|
4072
|
-
if (key === "parent") {
|
|
4073
|
-
continue;
|
|
4074
|
-
}
|
|
4075
|
-
const value = node[key];
|
|
4076
|
-
for (const child of Array.isArray(value) ? value : [value]) {
|
|
4077
|
-
if (child !== null && typeof child === "object" && "type" in child) {
|
|
4078
|
-
markConsumed(child, consumed);
|
|
4079
|
-
}
|
|
4080
|
-
}
|
|
4081
|
-
}
|
|
4100
|
+
forEachOwnAstChild(node, (child) => markConsumed(child, consumed));
|
|
4082
4101
|
}
|
|
4083
4102
|
function createSqlListener(handler) {
|
|
4084
4103
|
const consumed = /* @__PURE__ */ new WeakSet();
|
|
@@ -4534,15 +4553,7 @@ function functionComplexity(fn, visitorKeys) {
|
|
|
4534
4553
|
visitChildren(node, nesting);
|
|
4535
4554
|
}
|
|
4536
4555
|
function visitChildren(node, nesting) {
|
|
4537
|
-
|
|
4538
|
-
const value = node[key];
|
|
4539
|
-
const candidates = Array.isArray(value) ? value : [value];
|
|
4540
|
-
for (const candidate2 of candidates) {
|
|
4541
|
-
if (typeof candidate2 === "object" && candidate2 !== null && "type" in candidate2) {
|
|
4542
|
-
visit(candidate2, nesting);
|
|
4543
|
-
}
|
|
4544
|
-
}
|
|
4545
|
-
}
|
|
4556
|
+
forEachAstChild(node, visitorKeys, (child) => visit(child, nesting));
|
|
4546
4557
|
}
|
|
4547
4558
|
visit(fn.body, 0);
|
|
4548
4559
|
return points;
|
|
@@ -4711,9 +4722,6 @@ var PURE_CONSTRUCTORS = /* @__PURE__ */ new Set([
|
|
|
4711
4722
|
"Response",
|
|
4712
4723
|
"AbortController"
|
|
4713
4724
|
]);
|
|
4714
|
-
function isNode2(value) {
|
|
4715
|
-
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
4716
|
-
}
|
|
4717
4725
|
function isPureCall(node) {
|
|
4718
4726
|
const callee = node.callee;
|
|
4719
4727
|
if (callee.type !== AST_NODE_TYPES27.MemberExpression) {
|
|
@@ -4751,27 +4759,7 @@ function subtreeMatches(stmt, predicate, descendIntoFunctions = false) {
|
|
|
4751
4759
|
found = true;
|
|
4752
4760
|
return;
|
|
4753
4761
|
}
|
|
4754
|
-
|
|
4755
|
-
if (key === "parent") {
|
|
4756
|
-
continue;
|
|
4757
|
-
}
|
|
4758
|
-
if (!descendIntoFunctions && NESTED_FUNCTION_TYPES.has(current.type) && key === "body") {
|
|
4759
|
-
continue;
|
|
4760
|
-
}
|
|
4761
|
-
const value = current[key];
|
|
4762
|
-
if (Array.isArray(value)) {
|
|
4763
|
-
for (const child of value) {
|
|
4764
|
-
if (isNode2(child)) {
|
|
4765
|
-
visit(child);
|
|
4766
|
-
}
|
|
4767
|
-
}
|
|
4768
|
-
} else if (isNode2(value)) {
|
|
4769
|
-
visit(value);
|
|
4770
|
-
}
|
|
4771
|
-
if (found) {
|
|
4772
|
-
return;
|
|
4773
|
-
}
|
|
4774
|
-
}
|
|
4762
|
+
forEachOwnAstChild(current, visit, (key) => descendIntoFunctions || !NESTED_FUNCTION_TYPES.has(current.type) || key !== "body");
|
|
4775
4763
|
};
|
|
4776
4764
|
visit(stmt);
|
|
4777
4765
|
return found;
|
|
@@ -7145,17 +7133,7 @@ function nearestFunction(node) {
|
|
|
7145
7133
|
}
|
|
7146
7134
|
function walkOwnScope(node, predicate) {
|
|
7147
7135
|
if (predicate(node)) return true;
|
|
7148
|
-
|
|
7149
|
-
if (key === "parent") continue;
|
|
7150
|
-
const value = node[key];
|
|
7151
|
-
for (const child of Array.isArray(value) ? value : [value]) {
|
|
7152
|
-
if (typeof child === "object" && child !== null && typeof child.type === "string") {
|
|
7153
|
-
const childNode = child;
|
|
7154
|
-
if (!FUNCTION_TYPES3.has(childNode.type) && walkOwnScope(childNode, predicate)) return true;
|
|
7155
|
-
}
|
|
7156
|
-
}
|
|
7157
|
-
}
|
|
7158
|
-
return false;
|
|
7136
|
+
return forEachOwnAstChild(node, (child) => !FUNCTION_TYPES3.has(child.type) && walkOwnScope(child, predicate));
|
|
7159
7137
|
}
|
|
7160
7138
|
function isAssertion(node, context) {
|
|
7161
7139
|
if (node.type !== AST_NODE_TYPES37.CallExpression) return false;
|
|
@@ -9958,21 +9936,10 @@ function walkWithinScope(node, visit) {
|
|
|
9958
9936
|
if (isFunctionNode(current)) {
|
|
9959
9937
|
return;
|
|
9960
9938
|
}
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
const value = current[key];
|
|
9966
|
-
if (Array.isArray(value)) {
|
|
9967
|
-
for (const child of value) {
|
|
9968
|
-
if (isNode3(child)) {
|
|
9969
|
-
recurse(child);
|
|
9970
|
-
}
|
|
9971
|
-
}
|
|
9972
|
-
} else if (isNode3(value)) {
|
|
9973
|
-
recurse(value);
|
|
9974
|
-
}
|
|
9975
|
-
}
|
|
9939
|
+
forEachOwnAstChild(current, (child) => {
|
|
9940
|
+
recurse(child);
|
|
9941
|
+
return found;
|
|
9942
|
+
});
|
|
9976
9943
|
};
|
|
9977
9944
|
recurse(node);
|
|
9978
9945
|
return found;
|
|
@@ -10019,22 +9986,10 @@ function subtreeReadsName(node, name) {
|
|
|
10019
9986
|
if (shadowsName(current)) {
|
|
10020
9987
|
return;
|
|
10021
9988
|
}
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
if (isNonReadingProperty(current, key)) continue;
|
|
10027
|
-
const value = current[key];
|
|
10028
|
-
if (Array.isArray(value)) {
|
|
10029
|
-
for (const child of value) {
|
|
10030
|
-
if (isNode3(child)) {
|
|
10031
|
-
recurse(child);
|
|
10032
|
-
}
|
|
10033
|
-
}
|
|
10034
|
-
} else if (isNode3(value)) {
|
|
10035
|
-
recurse(value);
|
|
10036
|
-
}
|
|
10037
|
-
}
|
|
9989
|
+
forEachOwnAstChild(current, (child) => {
|
|
9990
|
+
recurse(child);
|
|
9991
|
+
return found;
|
|
9992
|
+
}, (key) => !isNonReadingProperty(current, key));
|
|
10038
9993
|
};
|
|
10039
9994
|
recurse(node);
|
|
10040
9995
|
return found;
|
|
@@ -10153,14 +10108,10 @@ function tryReturnsSafeParse(catchNode) {
|
|
|
10153
10108
|
visitChildren(current);
|
|
10154
10109
|
};
|
|
10155
10110
|
function visitChildren(current) {
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
for (const child of children) {
|
|
10161
|
-
if (isNode3(child)) recurse(child);
|
|
10162
|
-
}
|
|
10163
|
-
}
|
|
10111
|
+
forEachOwnAstChild(current, (child) => {
|
|
10112
|
+
recurse(child);
|
|
10113
|
+
return sawUnsafeOperation;
|
|
10114
|
+
});
|
|
10164
10115
|
}
|
|
10165
10116
|
recurse(tryBlock);
|
|
10166
10117
|
return sawSafeParse && !sawUnsafeOperation;
|
|
@@ -16316,13 +16267,7 @@ function isEmptyGuard(node, access) {
|
|
|
16316
16267
|
}
|
|
16317
16268
|
function contains(node, visitorKeys, predicate) {
|
|
16318
16269
|
if (predicate(node)) return true;
|
|
16319
|
-
|
|
16320
|
-
const child = node[key];
|
|
16321
|
-
for (const value of Array.isArray(child) ? child : [child]) {
|
|
16322
|
-
if (value !== null && typeof value === "object" && "type" in value && contains(value, visitorKeys, predicate)) return true;
|
|
16323
|
-
}
|
|
16324
|
-
}
|
|
16325
|
-
return false;
|
|
16270
|
+
return forEachAstChild(node, visitorKeys, (child) => contains(child, visitorKeys, predicate));
|
|
16326
16271
|
}
|
|
16327
16272
|
function belongsToFunction(node, fn) {
|
|
16328
16273
|
let current = node;
|
|
@@ -22103,14 +22048,7 @@ function referencedPropertyName(node) {
|
|
|
22103
22048
|
function walk(node, visitorKeys, visit, nestedFunction = false) {
|
|
22104
22049
|
visit(node, nestedFunction);
|
|
22105
22050
|
const nested = nestedFunction || isFunction(node);
|
|
22106
|
-
|
|
22107
|
-
const child = node[key];
|
|
22108
|
-
if (Array.isArray(child)) {
|
|
22109
|
-
for (const item of child) if (typeof item === "object" && item !== null && "type" in item) walk(item, visitorKeys, visit, nested);
|
|
22110
|
-
} else if (typeof child === "object" && child !== null && "type" in child) {
|
|
22111
|
-
walk(child, visitorKeys, visit, nested);
|
|
22112
|
-
}
|
|
22113
|
-
}
|
|
22051
|
+
forEachAstChild(node, visitorKeys, (child) => walk(child, visitorKeys, visit, nested));
|
|
22114
22052
|
}
|
|
22115
22053
|
function classScope(context, node, computedReferenceNames) {
|
|
22116
22054
|
const methods = node.body.body.filter(
|
|
@@ -23306,7 +23244,7 @@ var RULES = {
|
|
|
23306
23244
|
};
|
|
23307
23245
|
var meta = {
|
|
23308
23246
|
name: "@sarj/eslint-plugin",
|
|
23309
|
-
version: "15.26.
|
|
23247
|
+
version: "15.26.4"
|
|
23310
23248
|
};
|
|
23311
23249
|
var APPLICATION_ONLY_RULES = [];
|
|
23312
23250
|
var LIBRARY_IMPORT_POLICY = ["error", {
|