@sarj/eslint-plugin 9.12.1 → 9.13.0
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 +493 -356
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +488 -351
- package/package.json +2 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -641,7 +641,7 @@ var CODE_KEYWORD_RE = /^(import |export |const |let |var |function\b|class |inte
|
|
|
641
641
|
var CODE_TAIL_RE = /[;{}()]\s*$|=>\s*$|,\s*$/;
|
|
642
642
|
var ASSIGN_RE = /^[A-Za-z_$][\w.$[\]]*\s*(?:=(?![=>])|\+=|-=|\*=)\s*\S.*[;)}\]]\s*$/;
|
|
643
643
|
var CALL_RE = /^[A-Za-z_$][\w.$]*\([^)]*\)\s*;?\s*$/;
|
|
644
|
-
var ASSERTION_CODE_RE = /^(?:await\s+)?(?:expect(?:TypeOf)
|
|
644
|
+
var ASSERTION_CODE_RE = /^(?:await\s+)?(?:expect(?:TypeOf)?|assert(?:\.\w+)?)\s*\(/;
|
|
645
645
|
var PSEUDOCODE_RE = /%\w+%|\[opt\]|(?:^|\s)<[A-Za-z]\w*>|…|\.\.\./;
|
|
646
646
|
function stripCommentMarker(line) {
|
|
647
647
|
return line.replace(/^\s*\/{1,2}/, "").replace(/^\s*\*+/, "").trim();
|
|
@@ -6708,8 +6708,143 @@ var prefer_input_group_search_default = createRule({
|
|
|
6708
6708
|
}
|
|
6709
6709
|
});
|
|
6710
6710
|
|
|
6711
|
-
// src/rules/prefer-
|
|
6711
|
+
// src/rules/prefer-immutable-module-constant.ts
|
|
6712
6712
|
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
6713
|
+
var CONSTANT_NAME = /^_?[A-Z][A-Z0-9_]*$/;
|
|
6714
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
6715
|
+
"add",
|
|
6716
|
+
"clear",
|
|
6717
|
+
"copyWithin",
|
|
6718
|
+
"delete",
|
|
6719
|
+
"fill",
|
|
6720
|
+
"pop",
|
|
6721
|
+
"push",
|
|
6722
|
+
"reverse",
|
|
6723
|
+
"set",
|
|
6724
|
+
"shift",
|
|
6725
|
+
"sort",
|
|
6726
|
+
"splice",
|
|
6727
|
+
"unshift"
|
|
6728
|
+
]);
|
|
6729
|
+
function isAsConst(node, sourceText) {
|
|
6730
|
+
if (node.type === AST_NODE_TYPES35.TSSatisfiesExpression) {
|
|
6731
|
+
return isAsConst(node.expression, sourceText);
|
|
6732
|
+
}
|
|
6733
|
+
return node.type === AST_NODE_TYPES35.TSAsExpression && sourceText(node.typeAnnotation).trim() === "const";
|
|
6734
|
+
}
|
|
6735
|
+
function unwrapExpression(node) {
|
|
6736
|
+
if (node.type === AST_NODE_TYPES35.TSAsExpression || node.type === AST_NODE_TYPES35.TSSatisfiesExpression || node.type === AST_NODE_TYPES35.TSNonNullExpression) {
|
|
6737
|
+
return unwrapExpression(node.expression);
|
|
6738
|
+
}
|
|
6739
|
+
return node;
|
|
6740
|
+
}
|
|
6741
|
+
function isObjectFreeze(node) {
|
|
6742
|
+
const inner = unwrapExpression(node);
|
|
6743
|
+
return inner.type === AST_NODE_TYPES35.CallExpression && inner.callee.type === AST_NODE_TYPES35.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES35.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze";
|
|
6744
|
+
}
|
|
6745
|
+
function collectionKind(node) {
|
|
6746
|
+
const inner = unwrapExpression(node);
|
|
6747
|
+
if (inner.type === AST_NODE_TYPES35.ArrayExpression || inner.type === AST_NODE_TYPES35.ObjectExpression) {
|
|
6748
|
+
return "literal";
|
|
6749
|
+
}
|
|
6750
|
+
if (inner.type === AST_NODE_TYPES35.NewExpression && inner.callee.type === AST_NODE_TYPES35.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map")) {
|
|
6751
|
+
return inner.callee.name;
|
|
6752
|
+
}
|
|
6753
|
+
return null;
|
|
6754
|
+
}
|
|
6755
|
+
function isReadonlyType(node, kind) {
|
|
6756
|
+
if (node.type === AST_NODE_TYPES35.TSTypeOperator && node.operator === "readonly") {
|
|
6757
|
+
return true;
|
|
6758
|
+
}
|
|
6759
|
+
if (node.type !== AST_NODE_TYPES35.TSTypeReference || node.typeName.type !== AST_NODE_TYPES35.Identifier) {
|
|
6760
|
+
return false;
|
|
6761
|
+
}
|
|
6762
|
+
if (node.typeName.name === "Readonly") {
|
|
6763
|
+
return true;
|
|
6764
|
+
}
|
|
6765
|
+
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6766
|
+
}
|
|
6767
|
+
function declaredReadonlyType(node, kind) {
|
|
6768
|
+
const annotation = node.id.type === AST_NODE_TYPES35.Identifier ? node.id.typeAnnotation : void 0;
|
|
6769
|
+
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6770
|
+
return true;
|
|
6771
|
+
}
|
|
6772
|
+
return node.init?.type === AST_NODE_TYPES35.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6773
|
+
}
|
|
6774
|
+
function referenceMutates(identifier) {
|
|
6775
|
+
let member = identifier.parent;
|
|
6776
|
+
if (member?.type !== AST_NODE_TYPES35.MemberExpression || member.object !== identifier) {
|
|
6777
|
+
return member?.type === AST_NODE_TYPES35.CallExpression && member.arguments[0] === identifier && member.callee.type === AST_NODE_TYPES35.MemberExpression && !member.callee.computed && member.callee.object.type === AST_NODE_TYPES35.Identifier && member.callee.object.name === "Object" && member.callee.property.type === AST_NODE_TYPES35.Identifier && member.callee.property.name === "assign";
|
|
6778
|
+
}
|
|
6779
|
+
while (member.parent.type === AST_NODE_TYPES35.MemberExpression && member.parent.object === member) {
|
|
6780
|
+
member = member.parent;
|
|
6781
|
+
}
|
|
6782
|
+
const parent = member.parent;
|
|
6783
|
+
if (parent?.type === AST_NODE_TYPES35.AssignmentExpression && parent.left === member) {
|
|
6784
|
+
return true;
|
|
6785
|
+
}
|
|
6786
|
+
if (parent?.type === AST_NODE_TYPES35.UpdateExpression && parent.argument === member) {
|
|
6787
|
+
return true;
|
|
6788
|
+
}
|
|
6789
|
+
if (parent?.type === AST_NODE_TYPES35.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6790
|
+
return true;
|
|
6791
|
+
}
|
|
6792
|
+
return parent?.type === AST_NODE_TYPES35.CallExpression && parent.callee === member && member.property.type === AST_NODE_TYPES35.Identifier && MUTATING_METHODS.has(member.property.name);
|
|
6793
|
+
}
|
|
6794
|
+
var prefer_immutable_module_constant_default = createRule({
|
|
6795
|
+
name: "prefer-immutable-module-constant",
|
|
6796
|
+
meta: {
|
|
6797
|
+
type: "suggestion",
|
|
6798
|
+
docs: {
|
|
6799
|
+
description: "Require module-level constant collections to expose readonly state."
|
|
6800
|
+
},
|
|
6801
|
+
schema: [],
|
|
6802
|
+
messages: {
|
|
6803
|
+
preferAsConst: "Module constant `{{name}}` is a mutable literal. Add `as const` or use `Object.freeze` so consumers cannot mutate shared state.",
|
|
6804
|
+
preferReadonlyCollection: "Module constant `{{name}}` is a mutable {{kind}}. Expose it as `Readonly{{kind}}` or an immutable collection."
|
|
6805
|
+
}
|
|
6806
|
+
},
|
|
6807
|
+
defaultOptions: [],
|
|
6808
|
+
create(context) {
|
|
6809
|
+
const sourceCode = context.sourceCode;
|
|
6810
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
6811
|
+
return {};
|
|
6812
|
+
}
|
|
6813
|
+
return {
|
|
6814
|
+
VariableDeclarator(node) {
|
|
6815
|
+
const declaration = node.parent;
|
|
6816
|
+
if (declaration.type !== AST_NODE_TYPES35.VariableDeclaration || declaration.kind !== "const" || node.id.type !== AST_NODE_TYPES35.Identifier || node.init === null || !CONSTANT_NAME.test(node.id.name)) {
|
|
6817
|
+
return;
|
|
6818
|
+
}
|
|
6819
|
+
const container = declaration.parent;
|
|
6820
|
+
if (container.type !== AST_NODE_TYPES35.Program && !(container.type === AST_NODE_TYPES35.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES35.Program)) {
|
|
6821
|
+
return;
|
|
6822
|
+
}
|
|
6823
|
+
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init)) {
|
|
6824
|
+
return;
|
|
6825
|
+
}
|
|
6826
|
+
const kind = collectionKind(node.init);
|
|
6827
|
+
if (kind === null || declaredReadonlyType(node, kind)) {
|
|
6828
|
+
return;
|
|
6829
|
+
}
|
|
6830
|
+
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6831
|
+
if (variable?.references.some(
|
|
6832
|
+
(reference) => reference.identifier.type === AST_NODE_TYPES35.Identifier && referenceMutates(reference.identifier)
|
|
6833
|
+
) === true) {
|
|
6834
|
+
return;
|
|
6835
|
+
}
|
|
6836
|
+
context.report({
|
|
6837
|
+
node: node.id,
|
|
6838
|
+
messageId: kind === "literal" ? "preferAsConst" : "preferReadonlyCollection",
|
|
6839
|
+
data: { name: node.id.name, kind }
|
|
6840
|
+
});
|
|
6841
|
+
}
|
|
6842
|
+
};
|
|
6843
|
+
}
|
|
6844
|
+
});
|
|
6845
|
+
|
|
6846
|
+
// src/rules/prefer-shadcn-primitives.ts
|
|
6847
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36 } from "@typescript-eslint/utils";
|
|
6713
6848
|
var SHADCN_PRIMITIVES = {
|
|
6714
6849
|
button: "Button",
|
|
6715
6850
|
dialog: "Dialog or AlertDialog family",
|
|
@@ -6730,15 +6865,15 @@ var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
6730
6865
|
"textarea"
|
|
6731
6866
|
]);
|
|
6732
6867
|
function rawElementName(node) {
|
|
6733
|
-
if (node.name.type !==
|
|
6868
|
+
if (node.name.type !== AST_NODE_TYPES36.JSXIdentifier) return null;
|
|
6734
6869
|
const name = node.name.name;
|
|
6735
6870
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6736
6871
|
}
|
|
6737
6872
|
function staticExpressionString(expression) {
|
|
6738
|
-
if (expression.type ===
|
|
6873
|
+
if (expression.type === AST_NODE_TYPES36.Literal) {
|
|
6739
6874
|
return typeof expression.value === "string" ? expression.value : null;
|
|
6740
6875
|
}
|
|
6741
|
-
if (expression.type ===
|
|
6876
|
+
if (expression.type === AST_NODE_TYPES36.TemplateLiteral) {
|
|
6742
6877
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6743
6878
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6744
6879
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -6748,24 +6883,24 @@ function staticExpressionString(expression) {
|
|
|
6748
6883
|
}
|
|
6749
6884
|
return value;
|
|
6750
6885
|
}
|
|
6751
|
-
if (expression.type ===
|
|
6886
|
+
if (expression.type === AST_NODE_TYPES36.TSAsExpression || expression.type === AST_NODE_TYPES36.TSNonNullExpression || expression.type === AST_NODE_TYPES36.TSSatisfiesExpression || expression.type === AST_NODE_TYPES36.TSTypeAssertion) {
|
|
6752
6887
|
return staticExpressionString(expression.expression);
|
|
6753
6888
|
}
|
|
6754
6889
|
return null;
|
|
6755
6890
|
}
|
|
6756
6891
|
function staticString(value) {
|
|
6757
|
-
if (value?.type ===
|
|
6892
|
+
if (value?.type === AST_NODE_TYPES36.Literal) {
|
|
6758
6893
|
return typeof value.value === "string" ? value.value : null;
|
|
6759
6894
|
}
|
|
6760
|
-
if (value?.type !==
|
|
6895
|
+
if (value?.type !== AST_NODE_TYPES36.JSXExpressionContainer) return null;
|
|
6761
6896
|
return staticExpressionString(value.expression);
|
|
6762
6897
|
}
|
|
6763
6898
|
function effectiveAttribute(node, attributeName) {
|
|
6764
6899
|
for (const attribute of node.attributes.toReversed()) {
|
|
6765
|
-
if (attribute.type ===
|
|
6900
|
+
if (attribute.type === AST_NODE_TYPES36.JSXSpreadAttribute) {
|
|
6766
6901
|
return { kind: "unknown" };
|
|
6767
6902
|
}
|
|
6768
|
-
if (attribute.name.type !==
|
|
6903
|
+
if (attribute.name.type !== AST_NODE_TYPES36.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6769
6904
|
continue;
|
|
6770
6905
|
}
|
|
6771
6906
|
const value = staticString(attribute.value);
|
|
@@ -6774,7 +6909,7 @@ function effectiveAttribute(node, attributeName) {
|
|
|
6774
6909
|
return { kind: "missing" };
|
|
6775
6910
|
}
|
|
6776
6911
|
function isLabelableElement(node) {
|
|
6777
|
-
if (node.openingElement.name.type !==
|
|
6912
|
+
if (node.openingElement.name.type !== AST_NODE_TYPES36.JSXIdentifier) {
|
|
6778
6913
|
return false;
|
|
6779
6914
|
}
|
|
6780
6915
|
const name = node.openingElement.name.name;
|
|
@@ -6786,10 +6921,10 @@ function isLabelableElement(node) {
|
|
|
6786
6921
|
}
|
|
6787
6922
|
function containsLabelableElement(node) {
|
|
6788
6923
|
return node.children.some((child) => {
|
|
6789
|
-
if (child.type ===
|
|
6924
|
+
if (child.type === AST_NODE_TYPES36.JSXElement) {
|
|
6790
6925
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6791
6926
|
}
|
|
6792
|
-
if (child.type ===
|
|
6927
|
+
if (child.type === AST_NODE_TYPES36.JSXFragment) {
|
|
6793
6928
|
return containsLabelableElement(child);
|
|
6794
6929
|
}
|
|
6795
6930
|
return false;
|
|
@@ -6798,7 +6933,7 @@ function containsLabelableElement(node) {
|
|
|
6798
6933
|
function isStaticallyAssociatedLabel(node) {
|
|
6799
6934
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6800
6935
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6801
|
-
return node.parent.type ===
|
|
6936
|
+
return node.parent.type === AST_NODE_TYPES36.JSXElement && containsLabelableElement(node.parent);
|
|
6802
6937
|
}
|
|
6803
6938
|
function replacementFor(node, element) {
|
|
6804
6939
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -6842,7 +6977,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
6842
6977
|
});
|
|
6843
6978
|
|
|
6844
6979
|
// src/rules/prefer-module-level-constant.ts
|
|
6845
|
-
import { AST_NODE_TYPES as
|
|
6980
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37 } from "@typescript-eslint/utils";
|
|
6846
6981
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6847
6982
|
var MAX_LITERAL_DEPTH = 4;
|
|
6848
6983
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6851,7 +6986,7 @@ var IGNORE_PATTERNS2 = [
|
|
|
6851
6986
|
/\.generated\.tsx?$/,
|
|
6852
6987
|
/\.d\.ts$/
|
|
6853
6988
|
];
|
|
6854
|
-
var
|
|
6989
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
6855
6990
|
// Array
|
|
6856
6991
|
"push",
|
|
6857
6992
|
"pop",
|
|
@@ -6871,9 +7006,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6871
7006
|
"assign"
|
|
6872
7007
|
]);
|
|
6873
7008
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
7009
|
+
AST_NODE_TYPES37.FunctionDeclaration,
|
|
7010
|
+
AST_NODE_TYPES37.FunctionExpression,
|
|
7011
|
+
AST_NODE_TYPES37.ArrowFunctionExpression
|
|
6877
7012
|
]);
|
|
6878
7013
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6879
7014
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6886,14 +7021,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6886
7021
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6887
7022
|
}
|
|
6888
7023
|
function unwrap3(node) {
|
|
6889
|
-
if (node.type ===
|
|
7024
|
+
if (node.type === AST_NODE_TYPES37.TSAsExpression || node.type === AST_NODE_TYPES37.TSSatisfiesExpression || node.type === AST_NODE_TYPES37.TSNonNullExpression) {
|
|
6890
7025
|
return unwrap3(node.expression);
|
|
6891
7026
|
}
|
|
6892
7027
|
return node;
|
|
6893
7028
|
}
|
|
6894
7029
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6895
7030
|
function isRegexLiteral(node) {
|
|
6896
|
-
return node.type ===
|
|
7031
|
+
return node.type === AST_NODE_TYPES37.Literal && "regex" in node && node.regex !== void 0;
|
|
6897
7032
|
}
|
|
6898
7033
|
function isLiteralOnly(node, depth) {
|
|
6899
7034
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6901,29 +7036,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6901
7036
|
}
|
|
6902
7037
|
const inner = unwrap3(node);
|
|
6903
7038
|
switch (inner.type) {
|
|
6904
|
-
case
|
|
7039
|
+
case AST_NODE_TYPES37.Literal: {
|
|
6905
7040
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6906
7041
|
}
|
|
6907
|
-
case
|
|
7042
|
+
case AST_NODE_TYPES37.TemplateLiteral: {
|
|
6908
7043
|
return inner.expressions.length === 0;
|
|
6909
7044
|
}
|
|
6910
|
-
case
|
|
6911
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
7045
|
+
case AST_NODE_TYPES37.UnaryExpression: {
|
|
7046
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES37.Literal && typeof inner.argument.value === "number";
|
|
6912
7047
|
}
|
|
6913
|
-
case
|
|
7048
|
+
case AST_NODE_TYPES37.ArrayExpression: {
|
|
6914
7049
|
return inner.elements.every(
|
|
6915
|
-
(el) => el !== null && el.type !==
|
|
7050
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES37.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6916
7051
|
);
|
|
6917
7052
|
}
|
|
6918
|
-
case
|
|
7053
|
+
case AST_NODE_TYPES37.ObjectExpression: {
|
|
6919
7054
|
return inner.properties.every((prop) => {
|
|
6920
|
-
if (prop.type !==
|
|
7055
|
+
if (prop.type !== AST_NODE_TYPES37.Property) {
|
|
6921
7056
|
return false;
|
|
6922
7057
|
}
|
|
6923
7058
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6924
7059
|
return false;
|
|
6925
7060
|
}
|
|
6926
|
-
if (prop.computed && prop.key.type !==
|
|
7061
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES37.Literal) {
|
|
6927
7062
|
return false;
|
|
6928
7063
|
}
|
|
6929
7064
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6936,7 +7071,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6936
7071
|
}
|
|
6937
7072
|
function unwrapObjectFreeze(node) {
|
|
6938
7073
|
const inner = unwrap3(node);
|
|
6939
|
-
if (inner.type ===
|
|
7074
|
+
if (inner.type === AST_NODE_TYPES37.CallExpression && inner.callee.type === AST_NODE_TYPES37.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES37.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES37.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES37.SpreadElement) {
|
|
6940
7075
|
return unwrap3(inner.arguments[0]);
|
|
6941
7076
|
}
|
|
6942
7077
|
return inner;
|
|
@@ -6952,19 +7087,19 @@ function classify(init, checkRegex) {
|
|
|
6952
7087
|
}
|
|
6953
7088
|
return { kind: "regex", size: 1 };
|
|
6954
7089
|
}
|
|
6955
|
-
if (node.type ===
|
|
7090
|
+
if (node.type === AST_NODE_TYPES37.ArrayExpression) {
|
|
6956
7091
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6957
7092
|
}
|
|
6958
|
-
if (node.type ===
|
|
7093
|
+
if (node.type === AST_NODE_TYPES37.ObjectExpression) {
|
|
6959
7094
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6960
7095
|
}
|
|
6961
|
-
if (node.type ===
|
|
7096
|
+
if (node.type === AST_NODE_TYPES37.NewExpression && node.callee.type === AST_NODE_TYPES37.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6962
7097
|
const arg = node.arguments[0];
|
|
6963
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
7098
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES37.SpreadElement) {
|
|
6964
7099
|
return null;
|
|
6965
7100
|
}
|
|
6966
7101
|
const entries = unwrap3(arg);
|
|
6967
|
-
if (entries.type !==
|
|
7102
|
+
if (entries.type !== AST_NODE_TYPES37.ArrayExpression) {
|
|
6968
7103
|
return null;
|
|
6969
7104
|
}
|
|
6970
7105
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6993,10 +7128,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6993
7128
|
);
|
|
6994
7129
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6995
7130
|
const callee = node.callee;
|
|
6996
|
-
if (callee.type ===
|
|
7131
|
+
if (callee.type === AST_NODE_TYPES37.Identifier && callee.name === "structuredClone") {
|
|
6997
7132
|
return true;
|
|
6998
7133
|
}
|
|
6999
|
-
if (callee.type !==
|
|
7134
|
+
if (callee.type !== AST_NODE_TYPES37.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES37.Identifier || callee.property.type !== AST_NODE_TYPES37.Identifier) {
|
|
7000
7135
|
return false;
|
|
7001
7136
|
}
|
|
7002
7137
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -7010,38 +7145,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
7010
7145
|
}
|
|
7011
7146
|
function isSafeRead(identifier) {
|
|
7012
7147
|
const parent = identifier.parent;
|
|
7013
|
-
if (parent.type ===
|
|
7148
|
+
if (parent.type === AST_NODE_TYPES37.MemberExpression) {
|
|
7014
7149
|
if (parent.object !== identifier) {
|
|
7015
7150
|
return true;
|
|
7016
7151
|
}
|
|
7017
7152
|
const grandparent = parent.parent;
|
|
7018
|
-
if (grandparent.type ===
|
|
7153
|
+
if (grandparent.type === AST_NODE_TYPES37.AssignmentExpression && grandparent.left === parent) {
|
|
7019
7154
|
return false;
|
|
7020
7155
|
}
|
|
7021
|
-
if (grandparent.type ===
|
|
7156
|
+
if (grandparent.type === AST_NODE_TYPES37.UpdateExpression) {
|
|
7022
7157
|
return false;
|
|
7023
7158
|
}
|
|
7024
|
-
if (grandparent.type ===
|
|
7159
|
+
if (grandparent.type === AST_NODE_TYPES37.UnaryExpression && grandparent.operator === "delete") {
|
|
7025
7160
|
return false;
|
|
7026
7161
|
}
|
|
7027
|
-
if (!parent.computed && parent.property.type ===
|
|
7162
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES37.Identifier && MUTATING_METHODS2.has(parent.property.name) && grandparent.type === AST_NODE_TYPES37.CallExpression && grandparent.callee === parent) {
|
|
7028
7163
|
return false;
|
|
7029
7164
|
}
|
|
7030
7165
|
return true;
|
|
7031
7166
|
}
|
|
7032
|
-
if (parent.type ===
|
|
7167
|
+
if (parent.type === AST_NODE_TYPES37.ForOfStatement && parent.right === identifier) {
|
|
7033
7168
|
return true;
|
|
7034
7169
|
}
|
|
7035
|
-
if (parent.type ===
|
|
7170
|
+
if (parent.type === AST_NODE_TYPES37.SpreadElement) {
|
|
7036
7171
|
return true;
|
|
7037
7172
|
}
|
|
7038
|
-
if (parent.type ===
|
|
7173
|
+
if (parent.type === AST_NODE_TYPES37.BinaryExpression) {
|
|
7039
7174
|
return true;
|
|
7040
7175
|
}
|
|
7041
|
-
if (parent.type ===
|
|
7176
|
+
if (parent.type === AST_NODE_TYPES37.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
7042
7177
|
return true;
|
|
7043
7178
|
}
|
|
7044
|
-
if (parent.type ===
|
|
7179
|
+
if (parent.type === AST_NODE_TYPES37.UnaryExpression && parent.operator !== "delete") {
|
|
7045
7180
|
return true;
|
|
7046
7181
|
}
|
|
7047
7182
|
return false;
|
|
@@ -7096,7 +7231,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7096
7231
|
if (reference.isWrite()) {
|
|
7097
7232
|
return false;
|
|
7098
7233
|
}
|
|
7099
|
-
if (reference.identifier.type !==
|
|
7234
|
+
if (reference.identifier.type !== AST_NODE_TYPES37.Identifier) {
|
|
7100
7235
|
return false;
|
|
7101
7236
|
}
|
|
7102
7237
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7108,10 +7243,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7108
7243
|
return {
|
|
7109
7244
|
VariableDeclarator(node) {
|
|
7110
7245
|
const declaration = node.parent;
|
|
7111
|
-
if (declaration.type !==
|
|
7246
|
+
if (declaration.type !== AST_NODE_TYPES37.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7112
7247
|
return;
|
|
7113
7248
|
}
|
|
7114
|
-
if (node.id.type !==
|
|
7249
|
+
if (node.id.type !== AST_NODE_TYPES37.Identifier || node.init === null) {
|
|
7115
7250
|
return;
|
|
7116
7251
|
}
|
|
7117
7252
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7138,7 +7273,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7138
7273
|
});
|
|
7139
7274
|
|
|
7140
7275
|
// src/rules/prefer-module-level-schema.ts
|
|
7141
|
-
import { AST_NODE_TYPES as
|
|
7276
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
7142
7277
|
|
|
7143
7278
|
// src/rules/_zod.ts
|
|
7144
7279
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7204,9 +7339,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7204
7339
|
"intl"
|
|
7205
7340
|
]);
|
|
7206
7341
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7342
|
+
AST_NODE_TYPES38.ArrowFunctionExpression,
|
|
7343
|
+
AST_NODE_TYPES38.FunctionDeclaration,
|
|
7344
|
+
AST_NODE_TYPES38.FunctionExpression
|
|
7210
7345
|
]);
|
|
7211
7346
|
function schemaExpression(node) {
|
|
7212
7347
|
let current = node;
|
|
@@ -7215,10 +7350,10 @@ function schemaExpression(node) {
|
|
|
7215
7350
|
if (parent === void 0) {
|
|
7216
7351
|
return current;
|
|
7217
7352
|
}
|
|
7218
|
-
if (parent.type ===
|
|
7353
|
+
if (parent.type === AST_NODE_TYPES38.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES38.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
7219
7354
|
return current;
|
|
7220
7355
|
}
|
|
7221
|
-
if (parent.type ===
|
|
7356
|
+
if (parent.type === AST_NODE_TYPES38.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES38.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES38.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES38.TSNonNullExpression && parent.expression === current) {
|
|
7222
7357
|
current = parent;
|
|
7223
7358
|
continue;
|
|
7224
7359
|
}
|
|
@@ -7269,22 +7404,22 @@ function subtreeSome(root, predicate) {
|
|
|
7269
7404
|
function readsReceiver(node) {
|
|
7270
7405
|
return subtreeSome(
|
|
7271
7406
|
node,
|
|
7272
|
-
(inner) => inner.type ===
|
|
7407
|
+
(inner) => inner.type === AST_NODE_TYPES38.ThisExpression || inner.type === AST_NODE_TYPES38.Super || inner.type === AST_NODE_TYPES38.Identifier && inner.name === "arguments"
|
|
7273
7408
|
);
|
|
7274
7409
|
}
|
|
7275
7410
|
function buildsLocalizedText(node) {
|
|
7276
7411
|
return subtreeSome(node, (inner) => {
|
|
7277
|
-
if (inner.type ===
|
|
7412
|
+
if (inner.type === AST_NODE_TYPES38.TaggedTemplateExpression) {
|
|
7278
7413
|
return true;
|
|
7279
7414
|
}
|
|
7280
|
-
if (inner.type !==
|
|
7415
|
+
if (inner.type !== AST_NODE_TYPES38.CallExpression) {
|
|
7281
7416
|
return false;
|
|
7282
7417
|
}
|
|
7283
7418
|
const { callee } = inner;
|
|
7284
|
-
if (callee.type ===
|
|
7419
|
+
if (callee.type === AST_NODE_TYPES38.Identifier) {
|
|
7285
7420
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7286
7421
|
}
|
|
7287
|
-
return callee.type ===
|
|
7422
|
+
return callee.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES38.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7288
7423
|
});
|
|
7289
7424
|
}
|
|
7290
7425
|
function collectReferences(scope, out) {
|
|
@@ -7341,15 +7476,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7341
7476
|
}
|
|
7342
7477
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7343
7478
|
function isZodCall(node) {
|
|
7344
|
-
return node.type ===
|
|
7479
|
+
return node.type === AST_NODE_TYPES38.CallExpression && node.callee.type === AST_NODE_TYPES38.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES38.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7345
7480
|
}
|
|
7346
7481
|
function isCovered(node) {
|
|
7347
7482
|
let current = node.parent ?? void 0;
|
|
7348
7483
|
while (current !== void 0) {
|
|
7349
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7484
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES38.MemberExpression && current.callee.property.type === AST_NODE_TYPES38.Identifier && factories.has(current.callee.property.name)) {
|
|
7350
7485
|
return true;
|
|
7351
7486
|
}
|
|
7352
|
-
if (current.type ===
|
|
7487
|
+
if (current.type === AST_NODE_TYPES38.CallExpression && (current.callee.type === AST_NODE_TYPES38.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES38.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES38.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7353
7488
|
return true;
|
|
7354
7489
|
}
|
|
7355
7490
|
current = current.parent ?? void 0;
|
|
@@ -7364,11 +7499,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7364
7499
|
if (parent === void 0) {
|
|
7365
7500
|
return confirmed;
|
|
7366
7501
|
}
|
|
7367
|
-
if (parent.type ===
|
|
7502
|
+
if (parent.type === AST_NODE_TYPES38.Property && parent.value === current || parent.type === AST_NODE_TYPES38.ObjectExpression || parent.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
7368
7503
|
current = parent;
|
|
7369
7504
|
continue;
|
|
7370
7505
|
}
|
|
7371
|
-
if (parent.type ===
|
|
7506
|
+
if (parent.type === AST_NODE_TYPES38.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7372
7507
|
current = schemaExpression(parent);
|
|
7373
7508
|
confirmed = current;
|
|
7374
7509
|
continue;
|
|
@@ -7378,7 +7513,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7378
7513
|
}
|
|
7379
7514
|
function isSchemaComposition(node) {
|
|
7380
7515
|
const { callee } = node;
|
|
7381
|
-
const isCombinator = callee.type ===
|
|
7516
|
+
const isCombinator = callee.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES38.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7382
7517
|
return isCombinator || isZodCall(node);
|
|
7383
7518
|
}
|
|
7384
7519
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7412,13 +7547,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7412
7547
|
}
|
|
7413
7548
|
function ownerName(enclosing) {
|
|
7414
7549
|
const parent = enclosing.parent ?? void 0;
|
|
7415
|
-
if (enclosing.type ===
|
|
7550
|
+
if (enclosing.type === AST_NODE_TYPES38.FunctionDeclaration && enclosing.id !== null) {
|
|
7416
7551
|
return enclosing.id.name;
|
|
7417
7552
|
}
|
|
7418
|
-
if (parent !== void 0 && parent.type ===
|
|
7553
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES38.VariableDeclarator && parent.id.type === AST_NODE_TYPES38.Identifier) {
|
|
7419
7554
|
return parent.id.name;
|
|
7420
7555
|
}
|
|
7421
|
-
if (parent !== void 0 && (parent.type ===
|
|
7556
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES38.MethodDefinition || parent.type === AST_NODE_TYPES38.Property) && parent.key.type === AST_NODE_TYPES38.Identifier) {
|
|
7422
7557
|
return parent.key.name;
|
|
7423
7558
|
}
|
|
7424
7559
|
return "this function";
|
|
@@ -7429,7 +7564,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7429
7564
|
return;
|
|
7430
7565
|
}
|
|
7431
7566
|
for (const specifier of node.specifiers) {
|
|
7432
|
-
if (specifier.type ===
|
|
7567
|
+
if (specifier.type === AST_NODE_TYPES38.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES38.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES38.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES38.Identifier && specifier.imported.name === "z") {
|
|
7433
7568
|
zodNamespaces.add(specifier.local.name);
|
|
7434
7569
|
}
|
|
7435
7570
|
}
|
|
@@ -7439,7 +7574,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7439
7574
|
return;
|
|
7440
7575
|
}
|
|
7441
7576
|
const callee = node.callee;
|
|
7442
|
-
if (callee.property.type !==
|
|
7577
|
+
if (callee.property.type !== AST_NODE_TYPES38.Identifier) {
|
|
7443
7578
|
return;
|
|
7444
7579
|
}
|
|
7445
7580
|
const factory = callee.property.name;
|
|
@@ -7454,7 +7589,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7454
7589
|
return;
|
|
7455
7590
|
}
|
|
7456
7591
|
const shape = node.arguments[0];
|
|
7457
|
-
if (shape !== void 0 && shape.type ===
|
|
7592
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES38.ObjectExpression && shape.properties.length < minProperties) {
|
|
7458
7593
|
return;
|
|
7459
7594
|
}
|
|
7460
7595
|
const expression = schemaExpression(node);
|
|
@@ -7482,9 +7617,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7482
7617
|
});
|
|
7483
7618
|
|
|
7484
7619
|
// src/rules/prefer-native-random-uuid.ts
|
|
7485
|
-
import { AST_NODE_TYPES as
|
|
7620
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
|
|
7486
7621
|
function requireUuid(node) {
|
|
7487
|
-
return node?.type ===
|
|
7622
|
+
return node?.type === AST_NODE_TYPES39.CallExpression && node.callee.type === AST_NODE_TYPES39.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === AST_NODE_TYPES39.Literal && node.arguments[0].value === "uuid";
|
|
7488
7623
|
}
|
|
7489
7624
|
var prefer_native_random_uuid_default = createRule({
|
|
7490
7625
|
name: "prefer-native-random-uuid",
|
|
@@ -7527,37 +7662,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7527
7662
|
ImportDeclaration(node) {
|
|
7528
7663
|
if (node.source.value !== "uuid") return;
|
|
7529
7664
|
for (const specifier of node.specifiers) {
|
|
7530
|
-
if (specifier.type ===
|
|
7665
|
+
if (specifier.type === AST_NODE_TYPES39.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES39.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7531
7666
|
record(specifier.local, directBindings);
|
|
7532
|
-
} else if (specifier.type ===
|
|
7667
|
+
} else if (specifier.type === AST_NODE_TYPES39.ImportNamespaceSpecifier) {
|
|
7533
7668
|
record(specifier.local, namespaceBindings);
|
|
7534
7669
|
}
|
|
7535
7670
|
}
|
|
7536
7671
|
},
|
|
7537
7672
|
VariableDeclarator(node) {
|
|
7538
7673
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7539
|
-
if (node.init?.type !==
|
|
7674
|
+
if (node.init?.type !== AST_NODE_TYPES39.CallExpression || node.init.callee.type !== AST_NODE_TYPES39.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7540
7675
|
return;
|
|
7541
7676
|
}
|
|
7542
|
-
if (node.id.type ===
|
|
7677
|
+
if (node.id.type === AST_NODE_TYPES39.Identifier) {
|
|
7543
7678
|
record(node.id, namespaceBindings);
|
|
7544
7679
|
return;
|
|
7545
7680
|
}
|
|
7546
|
-
if (node.id.type !==
|
|
7681
|
+
if (node.id.type !== AST_NODE_TYPES39.ObjectPattern) return;
|
|
7547
7682
|
for (const property of node.id.properties) {
|
|
7548
|
-
if (property.type ===
|
|
7683
|
+
if (property.type === AST_NODE_TYPES39.Property && !property.computed && (property.key.type === AST_NODE_TYPES39.Identifier && property.key.name === "v4" || property.key.type === AST_NODE_TYPES39.Literal && property.key.value === "v4") && property.value.type === AST_NODE_TYPES39.Identifier) {
|
|
7549
7684
|
record(property.value, directBindings);
|
|
7550
7685
|
}
|
|
7551
7686
|
}
|
|
7552
7687
|
},
|
|
7553
7688
|
"CallExpression:exit"(node) {
|
|
7554
7689
|
if (node.arguments.length !== 0) return;
|
|
7555
|
-
if (node.callee.type ===
|
|
7690
|
+
if (node.callee.type === AST_NODE_TYPES39.Identifier) {
|
|
7556
7691
|
const variable2 = resolve(node.callee);
|
|
7557
7692
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7558
7693
|
return;
|
|
7559
7694
|
}
|
|
7560
|
-
if (node.callee.type !==
|
|
7695
|
+
if (node.callee.type !== AST_NODE_TYPES39.MemberExpression || node.callee.computed || node.callee.object.type !== AST_NODE_TYPES39.Identifier || node.callee.property.type !== AST_NODE_TYPES39.Identifier || node.callee.property.name !== "v4") {
|
|
7561
7696
|
return;
|
|
7562
7697
|
}
|
|
7563
7698
|
const variable = resolve(node.callee.object);
|
|
@@ -7568,20 +7703,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7568
7703
|
});
|
|
7569
7704
|
|
|
7570
7705
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7571
|
-
import { AST_NODE_TYPES as
|
|
7706
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
7572
7707
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7573
7708
|
function propertyName(node) {
|
|
7574
7709
|
const key = node.key;
|
|
7575
|
-
if (key.type ===
|
|
7576
|
-
if (key.type ===
|
|
7710
|
+
if (key.type === AST_NODE_TYPES40.Identifier) return key.name;
|
|
7711
|
+
if (key.type === AST_NODE_TYPES40.Literal) return String(key.value);
|
|
7577
7712
|
return "collection";
|
|
7578
7713
|
}
|
|
7579
7714
|
function isArrayType(node) {
|
|
7580
|
-
if (node.type ===
|
|
7581
|
-
return node.type ===
|
|
7715
|
+
if (node.type === AST_NODE_TYPES40.TSArrayType) return true;
|
|
7716
|
+
return node.type === AST_NODE_TYPES40.TSTypeReference && node.typeName.type === AST_NODE_TYPES40.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7582
7717
|
}
|
|
7583
7718
|
function isNullishType(node) {
|
|
7584
|
-
return node.type ===
|
|
7719
|
+
return node.type === AST_NODE_TYPES40.TSNullKeyword || node.type === AST_NODE_TYPES40.TSUndefinedKeyword;
|
|
7585
7720
|
}
|
|
7586
7721
|
function isNullableArrayOnly(node) {
|
|
7587
7722
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7609,7 +7744,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7609
7744
|
if (node.optional) return;
|
|
7610
7745
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7611
7746
|
if (annotation === void 0) return;
|
|
7612
|
-
if (annotation.type !==
|
|
7747
|
+
if (annotation.type !== AST_NODE_TYPES40.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7613
7748
|
return;
|
|
7614
7749
|
}
|
|
7615
7750
|
context.report({
|
|
@@ -7622,7 +7757,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7622
7757
|
TSPropertySignature: checkOptionalProperty,
|
|
7623
7758
|
PropertyDefinition: checkOptionalProperty,
|
|
7624
7759
|
TSTypeAliasDeclaration(node) {
|
|
7625
|
-
if (node.typeAnnotation.type !==
|
|
7760
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES40.TSUnionType) return;
|
|
7626
7761
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7627
7762
|
context.report({
|
|
7628
7763
|
node,
|
|
@@ -7635,13 +7770,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7635
7770
|
});
|
|
7636
7771
|
|
|
7637
7772
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7638
|
-
import { AST_NODE_TYPES as
|
|
7773
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
7639
7774
|
var unwrap4 = (node) => {
|
|
7640
7775
|
let current = node;
|
|
7641
7776
|
while (current !== null && current !== void 0) {
|
|
7642
|
-
if (current.type ===
|
|
7777
|
+
if (current.type === AST_NODE_TYPES41.TSAsExpression || current.type === AST_NODE_TYPES41.TSTypeAssertion || current.type === AST_NODE_TYPES41.TSNonNullExpression || current.type === AST_NODE_TYPES41.TSSatisfiesExpression) {
|
|
7643
7778
|
current = current.expression;
|
|
7644
|
-
} else if (current.type ===
|
|
7779
|
+
} else if (current.type === AST_NODE_TYPES41.ChainExpression) {
|
|
7645
7780
|
current = current.expression;
|
|
7646
7781
|
} else {
|
|
7647
7782
|
break;
|
|
@@ -7656,23 +7791,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7656
7791
|
]);
|
|
7657
7792
|
var isSchemaParseReference = (node) => {
|
|
7658
7793
|
const inner = unwrap4(node);
|
|
7659
|
-
return inner !== null && inner.type ===
|
|
7794
|
+
return inner !== null && inner.type === AST_NODE_TYPES41.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES41.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7660
7795
|
};
|
|
7661
7796
|
var isRawPayloadSource = (node) => {
|
|
7662
7797
|
let current = unwrap4(node);
|
|
7663
7798
|
if (current === null) return false;
|
|
7664
|
-
if (current.type ===
|
|
7799
|
+
if (current.type === AST_NODE_TYPES41.AwaitExpression) {
|
|
7665
7800
|
current = unwrap4(current.argument);
|
|
7666
7801
|
}
|
|
7667
|
-
if (current === null || current.type !==
|
|
7802
|
+
if (current === null || current.type !== AST_NODE_TYPES41.CallExpression) {
|
|
7668
7803
|
return false;
|
|
7669
7804
|
}
|
|
7670
7805
|
const callee = unwrap4(current.callee);
|
|
7671
|
-
if (callee === null || callee.type !==
|
|
7806
|
+
if (callee === null || callee.type !== AST_NODE_TYPES41.MemberExpression) {
|
|
7672
7807
|
return false;
|
|
7673
7808
|
}
|
|
7674
7809
|
const property = unwrap4(callee.property);
|
|
7675
|
-
if (property === null || property.type !==
|
|
7810
|
+
if (property === null || property.type !== AST_NODE_TYPES41.Identifier) {
|
|
7676
7811
|
return false;
|
|
7677
7812
|
}
|
|
7678
7813
|
if (property.name === "json") {
|
|
@@ -7682,16 +7817,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7682
7817
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7683
7818
|
}
|
|
7684
7819
|
const object = unwrap4(callee.object);
|
|
7685
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7820
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES41.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7686
7821
|
};
|
|
7687
7822
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7688
7823
|
var isLocalFileRead = (node) => {
|
|
7689
7824
|
let found = false;
|
|
7690
7825
|
const visit = (current) => {
|
|
7691
7826
|
if (found || current === null || current === void 0) return;
|
|
7692
|
-
if (current.type ===
|
|
7827
|
+
if (current.type === AST_NODE_TYPES41.CallExpression) {
|
|
7693
7828
|
const callee = unwrap4(current.callee);
|
|
7694
|
-
const name = callee?.type ===
|
|
7829
|
+
const name = callee?.type === AST_NODE_TYPES41.Identifier ? callee.name : callee?.type === AST_NODE_TYPES41.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES41.Identifier ? callee.property.name : null;
|
|
7695
7830
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7696
7831
|
found = true;
|
|
7697
7832
|
return;
|
|
@@ -7713,15 +7848,15 @@ var isLocalFileRead = (node) => {
|
|
|
7713
7848
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7714
7849
|
var isInsideAssertion = (node) => {
|
|
7715
7850
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7716
|
-
if (current.type !==
|
|
7851
|
+
if (current.type !== AST_NODE_TYPES41.CallExpression) continue;
|
|
7717
7852
|
let callee = current.callee;
|
|
7718
|
-
while (callee.type ===
|
|
7853
|
+
while (callee.type === AST_NODE_TYPES41.MemberExpression) {
|
|
7719
7854
|
callee = callee.object;
|
|
7720
7855
|
}
|
|
7721
|
-
if (callee.type ===
|
|
7856
|
+
if (callee.type === AST_NODE_TYPES41.CallExpression) {
|
|
7722
7857
|
callee = callee.callee;
|
|
7723
7858
|
}
|
|
7724
|
-
if (callee.type ===
|
|
7859
|
+
if (callee.type === AST_NODE_TYPES41.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7725
7860
|
return true;
|
|
7726
7861
|
}
|
|
7727
7862
|
}
|
|
@@ -7740,39 +7875,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7740
7875
|
var isValidationRead = (node) => {
|
|
7741
7876
|
let current = node;
|
|
7742
7877
|
let parent = current.parent;
|
|
7743
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7878
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES41.TSAsExpression || parent.type === AST_NODE_TYPES41.TSTypeAssertion || parent.type === AST_NODE_TYPES41.TSNonNullExpression || parent.type === AST_NODE_TYPES41.TSSatisfiesExpression || parent.type === AST_NODE_TYPES41.ChainExpression)) {
|
|
7744
7879
|
current = parent;
|
|
7745
7880
|
parent = parent.parent;
|
|
7746
7881
|
}
|
|
7747
7882
|
if (parent === null || parent === void 0) return false;
|
|
7748
|
-
if (parent.type ===
|
|
7883
|
+
if (parent.type === AST_NODE_TYPES41.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7749
7884
|
return true;
|
|
7750
7885
|
}
|
|
7751
|
-
if (parent.type !==
|
|
7886
|
+
if (parent.type !== AST_NODE_TYPES41.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7752
7887
|
return false;
|
|
7753
7888
|
}
|
|
7754
7889
|
const callee = parent.callee;
|
|
7755
|
-
if (callee.type ===
|
|
7890
|
+
if (callee.type === AST_NODE_TYPES41.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES41.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES41.Identifier && callee.property.name === "isArray") {
|
|
7756
7891
|
return parent.arguments.length === 1;
|
|
7757
7892
|
}
|
|
7758
|
-
return callee.type ===
|
|
7893
|
+
return callee.type === AST_NODE_TYPES41.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7759
7894
|
};
|
|
7760
7895
|
var isGuardTestPosition = (node) => {
|
|
7761
7896
|
let current = node;
|
|
7762
7897
|
let parent = current.parent;
|
|
7763
7898
|
while (parent !== void 0 && parent !== null) {
|
|
7764
7899
|
switch (parent.type) {
|
|
7765
|
-
case
|
|
7766
|
-
case
|
|
7767
|
-
case
|
|
7900
|
+
case AST_NODE_TYPES41.UnaryExpression:
|
|
7901
|
+
case AST_NODE_TYPES41.LogicalExpression:
|
|
7902
|
+
case AST_NODE_TYPES41.ChainExpression:
|
|
7768
7903
|
current = parent;
|
|
7769
7904
|
parent = parent.parent;
|
|
7770
7905
|
continue;
|
|
7771
|
-
case
|
|
7772
|
-
case
|
|
7773
|
-
case
|
|
7774
|
-
case
|
|
7775
|
-
case
|
|
7906
|
+
case AST_NODE_TYPES41.IfStatement:
|
|
7907
|
+
case AST_NODE_TYPES41.ConditionalExpression:
|
|
7908
|
+
case AST_NODE_TYPES41.WhileStatement:
|
|
7909
|
+
case AST_NODE_TYPES41.DoWhileStatement:
|
|
7910
|
+
case AST_NODE_TYPES41.ForStatement:
|
|
7776
7911
|
return parent.test === current;
|
|
7777
7912
|
default:
|
|
7778
7913
|
return false;
|
|
@@ -7782,7 +7917,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7782
7917
|
};
|
|
7783
7918
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7784
7919
|
const unwrapped = unwrap4(node);
|
|
7785
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7920
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES41.Identifier) {
|
|
7786
7921
|
return false;
|
|
7787
7922
|
}
|
|
7788
7923
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7825,11 +7960,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7825
7960
|
return {
|
|
7826
7961
|
VariableDeclarator(node) {
|
|
7827
7962
|
const scope = context.sourceCode.getScope(node);
|
|
7828
|
-
if (node.id.type ===
|
|
7963
|
+
if (node.id.type === AST_NODE_TYPES41.Identifier) {
|
|
7829
7964
|
trackInitializer(node);
|
|
7830
7965
|
return;
|
|
7831
7966
|
}
|
|
7832
|
-
if (node.id.type ===
|
|
7967
|
+
if (node.id.type === AST_NODE_TYPES41.ObjectPattern || node.id.type === AST_NODE_TYPES41.ArrayPattern) {
|
|
7833
7968
|
if (isRawPayloadSource(node.init)) {
|
|
7834
7969
|
if (!isFullyNarrowedPattern(node)) {
|
|
7835
7970
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7843,7 +7978,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7843
7978
|
},
|
|
7844
7979
|
AssignmentExpression(node) {
|
|
7845
7980
|
const scope = context.sourceCode.getScope(node);
|
|
7846
|
-
if (node.left.type ===
|
|
7981
|
+
if (node.left.type === AST_NODE_TYPES41.Identifier) {
|
|
7847
7982
|
const variable = findVariable2(scope, node.left.name);
|
|
7848
7983
|
if (variable === null) return;
|
|
7849
7984
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7853,7 +7988,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7853
7988
|
}
|
|
7854
7989
|
return;
|
|
7855
7990
|
}
|
|
7856
|
-
if (node.left.type ===
|
|
7991
|
+
if (node.left.type === AST_NODE_TYPES41.ObjectPattern || node.left.type === AST_NODE_TYPES41.ArrayPattern) {
|
|
7857
7992
|
if (isRawPayloadSource(node.right)) {
|
|
7858
7993
|
context.report({
|
|
7859
7994
|
node: node.left,
|
|
@@ -7870,15 +8005,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7870
8005
|
}
|
|
7871
8006
|
},
|
|
7872
8007
|
CallExpression(node) {
|
|
7873
|
-
if (node.callee.type !==
|
|
8008
|
+
if (node.callee.type !== AST_NODE_TYPES41.Identifier) return;
|
|
7874
8009
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7875
8010
|
return;
|
|
7876
8011
|
}
|
|
7877
8012
|
const scope = context.sourceCode.getScope(node);
|
|
7878
8013
|
for (const arg of node.arguments) {
|
|
7879
|
-
if (arg.type ===
|
|
8014
|
+
if (arg.type === AST_NODE_TYPES41.SpreadElement) continue;
|
|
7880
8015
|
const unwrapped = unwrap4(arg);
|
|
7881
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8016
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES41.Identifier) {
|
|
7882
8017
|
continue;
|
|
7883
8018
|
}
|
|
7884
8019
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7892,13 +8027,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7892
8027
|
const obj = unwrap4(node.object);
|
|
7893
8028
|
if (isRawPayloadSource(obj)) {
|
|
7894
8029
|
const parent = node.parent;
|
|
7895
|
-
if (parent.type ===
|
|
8030
|
+
if (parent.type === AST_NODE_TYPES41.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES41.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7896
8031
|
return;
|
|
7897
8032
|
}
|
|
7898
8033
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7899
8034
|
return;
|
|
7900
8035
|
}
|
|
7901
|
-
if (obj !== null && obj.type ===
|
|
8036
|
+
if (obj !== null && obj.type === AST_NODE_TYPES41.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7902
8037
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7903
8038
|
const variable = findVariable2(scope, obj.name);
|
|
7904
8039
|
if (variable !== null) {
|
|
@@ -7911,7 +8046,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7911
8046
|
});
|
|
7912
8047
|
|
|
7913
8048
|
// src/rules/prefer-semantic-colors.ts
|
|
7914
|
-
import { AST_NODE_TYPES as
|
|
8049
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
7915
8050
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
7916
8051
|
import { dirname, join, parse } from "path";
|
|
7917
8052
|
|
|
@@ -8011,8 +8146,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
8011
8146
|
]);
|
|
8012
8147
|
function jsxElementName(node) {
|
|
8013
8148
|
const name = node.openingElement.name;
|
|
8014
|
-
if (name.type ===
|
|
8015
|
-
if (name.type ===
|
|
8149
|
+
if (name.type === AST_NODE_TYPES42.JSXIdentifier) return name.name;
|
|
8150
|
+
if (name.type === AST_NODE_TYPES42.JSXMemberExpression && name.property.type === AST_NODE_TYPES42.JSXIdentifier) {
|
|
8016
8151
|
return name.property.name;
|
|
8017
8152
|
}
|
|
8018
8153
|
return null;
|
|
@@ -8038,7 +8173,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
8038
8173
|
var isInsideSvg = (node) => {
|
|
8039
8174
|
let current = node.parent;
|
|
8040
8175
|
while (current !== void 0 && current !== null) {
|
|
8041
|
-
if (current.type ===
|
|
8176
|
+
if (current.type === AST_NODE_TYPES42.JSXElement) {
|
|
8042
8177
|
const name = jsxElementName(current);
|
|
8043
8178
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
8044
8179
|
}
|
|
@@ -8049,7 +8184,7 @@ var isInsideSvg = (node) => {
|
|
|
8049
8184
|
var isInsideIconFactoryPath = (node) => {
|
|
8050
8185
|
let current = node.parent;
|
|
8051
8186
|
while (current !== void 0 && current !== null) {
|
|
8052
|
-
if (current.type ===
|
|
8187
|
+
if (current.type === AST_NODE_TYPES42.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES42.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES42.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES42.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
8053
8188
|
return true;
|
|
8054
8189
|
}
|
|
8055
8190
|
current = current.parent;
|
|
@@ -8186,12 +8321,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8186
8321
|
return root !== null && workspaceHasMarker(root);
|
|
8187
8322
|
};
|
|
8188
8323
|
var propName = (key) => {
|
|
8189
|
-
if (key.type ===
|
|
8190
|
-
if (key.type ===
|
|
8324
|
+
if (key.type === AST_NODE_TYPES42.Identifier) return key.name;
|
|
8325
|
+
if (key.type === AST_NODE_TYPES42.Literal && typeof key.value === "string") return key.value;
|
|
8191
8326
|
return null;
|
|
8192
8327
|
};
|
|
8193
8328
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8194
|
-
if (statement.type !==
|
|
8329
|
+
if (statement.type !== AST_NODE_TYPES42.ImportDeclaration && statement.type !== AST_NODE_TYPES42.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES42.ExportAllDeclaration) {
|
|
8195
8330
|
return false;
|
|
8196
8331
|
}
|
|
8197
8332
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8243,27 +8378,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8243
8378
|
const checkClassNode = (node) => {
|
|
8244
8379
|
if (node === null) return;
|
|
8245
8380
|
switch (node.type) {
|
|
8246
|
-
case
|
|
8381
|
+
case AST_NODE_TYPES42.Literal:
|
|
8247
8382
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8248
8383
|
break;
|
|
8249
|
-
case
|
|
8384
|
+
case AST_NODE_TYPES42.TemplateLiteral:
|
|
8250
8385
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8251
8386
|
break;
|
|
8252
|
-
case
|
|
8387
|
+
case AST_NODE_TYPES42.ArrayExpression:
|
|
8253
8388
|
for (const element of node.elements) {
|
|
8254
|
-
if (element !== null && element.type !==
|
|
8389
|
+
if (element !== null && element.type !== AST_NODE_TYPES42.SpreadElement) checkClassNode(element);
|
|
8255
8390
|
}
|
|
8256
8391
|
break;
|
|
8257
|
-
case
|
|
8392
|
+
case AST_NODE_TYPES42.ObjectExpression:
|
|
8258
8393
|
for (const property of node.properties) {
|
|
8259
|
-
if (property.type ===
|
|
8394
|
+
if (property.type === AST_NODE_TYPES42.Property) checkClassNode(property.value);
|
|
8260
8395
|
}
|
|
8261
8396
|
break;
|
|
8262
|
-
case
|
|
8397
|
+
case AST_NODE_TYPES42.ConditionalExpression:
|
|
8263
8398
|
checkClassNode(node.consequent);
|
|
8264
8399
|
checkClassNode(node.alternate);
|
|
8265
8400
|
break;
|
|
8266
|
-
case
|
|
8401
|
+
case AST_NODE_TYPES42.LogicalExpression:
|
|
8267
8402
|
checkClassNode(node.right);
|
|
8268
8403
|
break;
|
|
8269
8404
|
default:
|
|
@@ -8271,32 +8406,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8271
8406
|
}
|
|
8272
8407
|
};
|
|
8273
8408
|
const checkColorValueNode = (node) => {
|
|
8274
|
-
if (node.type ===
|
|
8409
|
+
if (node.type === AST_NODE_TYPES42.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
8275
8410
|
report(node, "inlineColor", { value: node.value });
|
|
8276
8411
|
}
|
|
8277
8412
|
};
|
|
8278
8413
|
return {
|
|
8279
8414
|
"JSXAttribute[name.name='className']"(node) {
|
|
8280
8415
|
if (node.value === null) return;
|
|
8281
|
-
if (node.value.type ===
|
|
8282
|
-
else if (node.value.type ===
|
|
8283
|
-
if (node.value.expression.type !==
|
|
8416
|
+
if (node.value.type === AST_NODE_TYPES42.Literal) checkClassNode(node.value);
|
|
8417
|
+
else if (node.value.type === AST_NODE_TYPES42.JSXExpressionContainer) {
|
|
8418
|
+
if (node.value.expression.type !== AST_NODE_TYPES42.JSXEmptyExpression) {
|
|
8284
8419
|
checkClassNode(node.value.expression);
|
|
8285
8420
|
}
|
|
8286
8421
|
}
|
|
8287
8422
|
},
|
|
8288
8423
|
CallExpression(node) {
|
|
8289
|
-
if (node.callee.type ===
|
|
8424
|
+
if (node.callee.type === AST_NODE_TYPES42.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES42.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
8290
8425
|
importsEmailOrPdfRenderer = true;
|
|
8291
8426
|
}
|
|
8292
|
-
if (node.callee.type ===
|
|
8427
|
+
if (node.callee.type === AST_NODE_TYPES42.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8293
8428
|
for (const arg of node.arguments) {
|
|
8294
|
-
if (arg.type !==
|
|
8429
|
+
if (arg.type !== AST_NODE_TYPES42.SpreadElement) checkClassNode(arg);
|
|
8295
8430
|
}
|
|
8296
8431
|
}
|
|
8297
8432
|
},
|
|
8298
8433
|
VariableDeclarator(node) {
|
|
8299
|
-
if (node.id.type ===
|
|
8434
|
+
if (node.id.type === AST_NODE_TYPES42.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8300
8435
|
checkClassNode(node.init);
|
|
8301
8436
|
}
|
|
8302
8437
|
},
|
|
@@ -8306,9 +8441,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8306
8441
|
},
|
|
8307
8442
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8308
8443
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8309
|
-
if (node.value?.type !==
|
|
8444
|
+
if (node.value?.type !== AST_NODE_TYPES42.Literal) return;
|
|
8310
8445
|
const owner = node.parent.name;
|
|
8311
|
-
if (owner.type ===
|
|
8446
|
+
if (owner.type === AST_NODE_TYPES42.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8312
8447
|
return;
|
|
8313
8448
|
}
|
|
8314
8449
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8322,7 +8457,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8322
8457
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8323
8458
|
},
|
|
8324
8459
|
ImportExpression(node) {
|
|
8325
|
-
if (node.source.type ===
|
|
8460
|
+
if (node.source.type === AST_NODE_TYPES42.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8326
8461
|
importsEmailOrPdfRenderer = true;
|
|
8327
8462
|
}
|
|
8328
8463
|
},
|
|
@@ -8528,7 +8663,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8528
8663
|
// src/rules/prefer-string-literal-union.ts
|
|
8529
8664
|
import {
|
|
8530
8665
|
ESLintUtils as ESLintUtils3,
|
|
8531
|
-
AST_NODE_TYPES as
|
|
8666
|
+
AST_NODE_TYPES as AST_NODE_TYPES43
|
|
8532
8667
|
} from "@typescript-eslint/utils";
|
|
8533
8668
|
import * as ts2 from "typescript";
|
|
8534
8669
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8572,19 +8707,19 @@ function isChoiceLikeName(name) {
|
|
|
8572
8707
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8573
8708
|
}
|
|
8574
8709
|
function keyName(key) {
|
|
8575
|
-
if (key.type ===
|
|
8710
|
+
if (key.type === AST_NODE_TYPES43.Identifier) {
|
|
8576
8711
|
return key.name;
|
|
8577
8712
|
}
|
|
8578
|
-
if (key.type ===
|
|
8713
|
+
if (key.type === AST_NODE_TYPES43.Literal && typeof key.value === "string") {
|
|
8579
8714
|
return key.value;
|
|
8580
8715
|
}
|
|
8581
8716
|
return null;
|
|
8582
8717
|
}
|
|
8583
8718
|
function isStringLiteralMember(t) {
|
|
8584
|
-
return t.type ===
|
|
8719
|
+
return t.type === AST_NODE_TYPES43.TSLiteralType && t.literal.type === AST_NODE_TYPES43.Literal && typeof t.literal.value === "string";
|
|
8585
8720
|
}
|
|
8586
8721
|
function isStringLiteralUnion(node) {
|
|
8587
|
-
if (node?.type !==
|
|
8722
|
+
if (node?.type !== AST_NODE_TYPES43.TSUnionType) {
|
|
8588
8723
|
return false;
|
|
8589
8724
|
}
|
|
8590
8725
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8613,12 +8748,12 @@ function bindingSourceExpression(decl) {
|
|
|
8613
8748
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8614
8749
|
}
|
|
8615
8750
|
function refKey(node) {
|
|
8616
|
-
if (node.type ===
|
|
8751
|
+
if (node.type === AST_NODE_TYPES43.Identifier) {
|
|
8617
8752
|
return node.name;
|
|
8618
8753
|
}
|
|
8619
|
-
if (node.type ===
|
|
8754
|
+
if (node.type === AST_NODE_TYPES43.MemberExpression && !node.computed) {
|
|
8620
8755
|
const inner = refKey(node.object);
|
|
8621
|
-
if (inner === null || node.property.type !==
|
|
8756
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
8622
8757
|
return null;
|
|
8623
8758
|
}
|
|
8624
8759
|
return `${inner}.${node.property.name}`;
|
|
@@ -8626,7 +8761,7 @@ function refKey(node) {
|
|
|
8626
8761
|
return null;
|
|
8627
8762
|
}
|
|
8628
8763
|
function strLiteral(node) {
|
|
8629
|
-
if (node.type ===
|
|
8764
|
+
if (node.type === AST_NODE_TYPES43.Literal && typeof node.value === "string") {
|
|
8630
8765
|
return node.value;
|
|
8631
8766
|
}
|
|
8632
8767
|
return null;
|
|
@@ -8779,7 +8914,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8779
8914
|
containersWithUnion.add(container);
|
|
8780
8915
|
return;
|
|
8781
8916
|
}
|
|
8782
|
-
if (typeNode?.type !==
|
|
8917
|
+
if (typeNode?.type !== AST_NODE_TYPES43.TSStringKeyword) {
|
|
8783
8918
|
return;
|
|
8784
8919
|
}
|
|
8785
8920
|
const name = keyName(key);
|
|
@@ -8867,10 +9002,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8867
9002
|
}
|
|
8868
9003
|
};
|
|
8869
9004
|
function refKeyText(node) {
|
|
8870
|
-
if (node.type ===
|
|
9005
|
+
if (node.type === AST_NODE_TYPES43.BinaryExpression) {
|
|
8871
9006
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8872
9007
|
}
|
|
8873
|
-
if (node.type ===
|
|
9008
|
+
if (node.type === AST_NODE_TYPES43.SwitchStatement) {
|
|
8874
9009
|
return refKey(node.discriminant) ?? "value";
|
|
8875
9010
|
}
|
|
8876
9011
|
return "value";
|
|
@@ -8879,7 +9014,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8879
9014
|
});
|
|
8880
9015
|
|
|
8881
9016
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8882
|
-
import { AST_NODE_TYPES as
|
|
9017
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
8883
9018
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8884
9019
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8885
9020
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8888,11 +9023,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8888
9023
|
var MIN_RUN_LENGTH = 2;
|
|
8889
9024
|
function literalText(node, getText) {
|
|
8890
9025
|
switch (node.type) {
|
|
8891
|
-
case
|
|
9026
|
+
case AST_NODE_TYPES44.Literal:
|
|
8892
9027
|
return "regex" in node ? null : getText(node);
|
|
8893
|
-
case
|
|
9028
|
+
case AST_NODE_TYPES44.TemplateLiteral:
|
|
8894
9029
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8895
|
-
case
|
|
9030
|
+
case AST_NODE_TYPES44.UnaryExpression:
|
|
8896
9031
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8897
9032
|
default:
|
|
8898
9033
|
return null;
|
|
@@ -8900,15 +9035,15 @@ function literalText(node, getText) {
|
|
|
8900
9035
|
}
|
|
8901
9036
|
function isPureReceiver(node) {
|
|
8902
9037
|
switch (node.type) {
|
|
8903
|
-
case
|
|
8904
|
-
case
|
|
9038
|
+
case AST_NODE_TYPES44.Identifier:
|
|
9039
|
+
case AST_NODE_TYPES44.ThisExpression:
|
|
8905
9040
|
return true;
|
|
8906
|
-
case
|
|
9041
|
+
case AST_NODE_TYPES44.MemberExpression:
|
|
8907
9042
|
if (node.optional) {
|
|
8908
9043
|
return false;
|
|
8909
9044
|
}
|
|
8910
9045
|
if (node.computed) {
|
|
8911
|
-
return node.property.type ===
|
|
9046
|
+
return node.property.type === AST_NODE_TYPES44.Literal && isPureReceiver(node.object);
|
|
8912
9047
|
}
|
|
8913
9048
|
return isPureReceiver(node.object);
|
|
8914
9049
|
default:
|
|
@@ -8916,7 +9051,7 @@ function isPureReceiver(node) {
|
|
|
8916
9051
|
}
|
|
8917
9052
|
}
|
|
8918
9053
|
function literalIndex(node) {
|
|
8919
|
-
if (node.type !==
|
|
9054
|
+
if (node.type !== AST_NODE_TYPES44.Literal || typeof node.value !== "number") {
|
|
8920
9055
|
return null;
|
|
8921
9056
|
}
|
|
8922
9057
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8942,24 +9077,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8942
9077
|
}
|
|
8943
9078
|
const { sourceCode } = context;
|
|
8944
9079
|
function parseAssertion(statement) {
|
|
8945
|
-
if (statement.type !==
|
|
9080
|
+
if (statement.type !== AST_NODE_TYPES44.ExpressionStatement) {
|
|
8946
9081
|
return null;
|
|
8947
9082
|
}
|
|
8948
9083
|
const call = statement.expression;
|
|
8949
|
-
if (call.type !==
|
|
9084
|
+
if (call.type !== AST_NODE_TYPES44.CallExpression) {
|
|
8950
9085
|
return null;
|
|
8951
9086
|
}
|
|
8952
9087
|
const callee = call.callee;
|
|
8953
|
-
if (callee.type !==
|
|
9088
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
8954
9089
|
return null;
|
|
8955
9090
|
}
|
|
8956
9091
|
const matcher = callee.property.name;
|
|
8957
9092
|
const expectCall = callee.object;
|
|
8958
|
-
if (expectCall.type !==
|
|
9093
|
+
if (expectCall.type !== AST_NODE_TYPES44.CallExpression || expectCall.callee.type !== AST_NODE_TYPES44.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8959
9094
|
return null;
|
|
8960
9095
|
}
|
|
8961
9096
|
const actual = expectCall.arguments[0];
|
|
8962
|
-
if (actual === void 0 || actual.type !==
|
|
9097
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES44.MemberExpression || actual.optional) {
|
|
8963
9098
|
return null;
|
|
8964
9099
|
}
|
|
8965
9100
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8973,7 +9108,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8973
9108
|
}
|
|
8974
9109
|
key = { kind: "index", index };
|
|
8975
9110
|
} else {
|
|
8976
|
-
if (actual.property.type !==
|
|
9111
|
+
if (actual.property.type !== AST_NODE_TYPES44.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8977
9112
|
return null;
|
|
8978
9113
|
}
|
|
8979
9114
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8985,7 +9120,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8985
9120
|
return null;
|
|
8986
9121
|
}
|
|
8987
9122
|
const expected = call.arguments[0];
|
|
8988
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
9123
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES44.SpreadElement) {
|
|
8989
9124
|
return null;
|
|
8990
9125
|
}
|
|
8991
9126
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9100,7 +9235,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9100
9235
|
});
|
|
9101
9236
|
|
|
9102
9237
|
// src/rules/prefer-zod-enum.ts
|
|
9103
|
-
import { AST_NODE_TYPES as
|
|
9238
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
9104
9239
|
var prefer_zod_enum_default = createRule({
|
|
9105
9240
|
name: "prefer-zod-enum",
|
|
9106
9241
|
meta: {
|
|
@@ -9120,25 +9255,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9120
9255
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9121
9256
|
function enumValues(node) {
|
|
9122
9257
|
const callee = node.callee;
|
|
9123
|
-
if (callee.type !==
|
|
9258
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES45.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES45.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
9124
9259
|
return null;
|
|
9125
9260
|
}
|
|
9126
9261
|
const argument = node.arguments[0];
|
|
9127
|
-
if (argument === void 0 || argument.type !==
|
|
9262
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES45.ArrayExpression || argument.elements.length === 0) {
|
|
9128
9263
|
return null;
|
|
9129
9264
|
}
|
|
9130
9265
|
const values = [];
|
|
9131
9266
|
let canFix = true;
|
|
9132
9267
|
for (const element of argument.elements) {
|
|
9133
|
-
if (element?.type ===
|
|
9268
|
+
if (element?.type === AST_NODE_TYPES45.SpreadElement) {
|
|
9134
9269
|
canFix = false;
|
|
9135
9270
|
continue;
|
|
9136
9271
|
}
|
|
9137
|
-
if (element === null || element.type !==
|
|
9272
|
+
if (element === null || element.type !== AST_NODE_TYPES45.CallExpression || element.callee.type !== AST_NODE_TYPES45.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES45.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES45.Identifier || element.callee.property.name !== "literal") {
|
|
9138
9273
|
return null;
|
|
9139
9274
|
}
|
|
9140
9275
|
const value = element.arguments[0];
|
|
9141
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9276
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES45.Literal || typeof value.value !== "string") {
|
|
9142
9277
|
canFix = false;
|
|
9143
9278
|
continue;
|
|
9144
9279
|
}
|
|
@@ -9148,11 +9283,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9148
9283
|
}
|
|
9149
9284
|
function buildFix(node, values) {
|
|
9150
9285
|
const argument = node.arguments[0];
|
|
9151
|
-
if (argument === void 0 || argument.type !==
|
|
9286
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES45.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9152
9287
|
return void 0;
|
|
9153
9288
|
}
|
|
9154
9289
|
const callee = node.callee;
|
|
9155
|
-
if (callee.type !==
|
|
9290
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.property.type !== AST_NODE_TYPES45.Identifier) {
|
|
9156
9291
|
return void 0;
|
|
9157
9292
|
}
|
|
9158
9293
|
return (fixer) => [
|
|
@@ -9169,7 +9304,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9169
9304
|
return;
|
|
9170
9305
|
}
|
|
9171
9306
|
for (const specifier of node.specifiers) {
|
|
9172
|
-
if (specifier.type ===
|
|
9307
|
+
if (specifier.type === AST_NODE_TYPES45.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES45.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES45.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES45.Identifier && specifier.imported.name === "z") {
|
|
9173
9308
|
zodNamespaces.add(specifier.local.name);
|
|
9174
9309
|
}
|
|
9175
9310
|
}
|
|
@@ -9191,7 +9326,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9191
9326
|
});
|
|
9192
9327
|
|
|
9193
9328
|
// src/rules/prefer-zod-infer.ts
|
|
9194
|
-
import { AST_NODE_TYPES as
|
|
9329
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46 } from "@typescript-eslint/utils";
|
|
9195
9330
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9196
9331
|
"describe",
|
|
9197
9332
|
"refine",
|
|
@@ -9228,44 +9363,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9228
9363
|
"Schema"
|
|
9229
9364
|
]);
|
|
9230
9365
|
var LEAF_NODE_TYPES = {
|
|
9231
|
-
string: [
|
|
9232
|
-
email: [
|
|
9233
|
-
url: [
|
|
9234
|
-
uuid: [
|
|
9235
|
-
ulid: [
|
|
9236
|
-
cuid: [
|
|
9237
|
-
cuid2: [
|
|
9238
|
-
nanoid: [
|
|
9239
|
-
iso: [
|
|
9240
|
-
number: [
|
|
9241
|
-
int: [
|
|
9242
|
-
float32: [
|
|
9243
|
-
float64: [
|
|
9244
|
-
boolean: [
|
|
9245
|
-
bigint: [
|
|
9246
|
-
symbol: [
|
|
9247
|
-
any: [
|
|
9248
|
-
unknown: [
|
|
9249
|
-
never: [
|
|
9250
|
-
void: [
|
|
9251
|
-
null: [
|
|
9252
|
-
undefined: [
|
|
9253
|
-
literal: [
|
|
9254
|
-
date: [
|
|
9255
|
-
array: [
|
|
9256
|
-
tuple: [
|
|
9257
|
-
object: [
|
|
9258
|
-
strictObject: [
|
|
9259
|
-
looseObject: [
|
|
9260
|
-
record: [
|
|
9261
|
-
map: [
|
|
9262
|
-
set: [
|
|
9263
|
-
promise: [
|
|
9264
|
-
enum: [
|
|
9265
|
-
nativeEnum: [
|
|
9266
|
-
union: [
|
|
9267
|
-
discriminatedUnion: [
|
|
9268
|
-
intersection: [
|
|
9366
|
+
string: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9367
|
+
email: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9368
|
+
url: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9369
|
+
uuid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9370
|
+
ulid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9371
|
+
cuid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9372
|
+
cuid2: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9373
|
+
nanoid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9374
|
+
iso: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9375
|
+
number: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9376
|
+
int: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9377
|
+
float32: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9378
|
+
float64: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9379
|
+
boolean: [AST_NODE_TYPES46.TSBooleanKeyword],
|
|
9380
|
+
bigint: [AST_NODE_TYPES46.TSBigIntKeyword],
|
|
9381
|
+
symbol: [AST_NODE_TYPES46.TSSymbolKeyword],
|
|
9382
|
+
any: [AST_NODE_TYPES46.TSAnyKeyword],
|
|
9383
|
+
unknown: [AST_NODE_TYPES46.TSUnknownKeyword],
|
|
9384
|
+
never: [AST_NODE_TYPES46.TSNeverKeyword],
|
|
9385
|
+
void: [AST_NODE_TYPES46.TSVoidKeyword],
|
|
9386
|
+
null: [AST_NODE_TYPES46.TSNullKeyword],
|
|
9387
|
+
undefined: [AST_NODE_TYPES46.TSUndefinedKeyword],
|
|
9388
|
+
literal: [AST_NODE_TYPES46.TSLiteralType],
|
|
9389
|
+
date: [AST_NODE_TYPES46.TSTypeReference],
|
|
9390
|
+
array: [AST_NODE_TYPES46.TSArrayType, AST_NODE_TYPES46.TSTypeReference],
|
|
9391
|
+
tuple: [AST_NODE_TYPES46.TSTupleType],
|
|
9392
|
+
object: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9393
|
+
strictObject: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9394
|
+
looseObject: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9395
|
+
record: [AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSTypeLiteral],
|
|
9396
|
+
map: [AST_NODE_TYPES46.TSTypeReference],
|
|
9397
|
+
set: [AST_NODE_TYPES46.TSTypeReference],
|
|
9398
|
+
promise: [AST_NODE_TYPES46.TSTypeReference],
|
|
9399
|
+
enum: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSLiteralType],
|
|
9400
|
+
nativeEnum: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSLiteralType],
|
|
9401
|
+
union: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference],
|
|
9402
|
+
discriminatedUnion: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference],
|
|
9403
|
+
intersection: [AST_NODE_TYPES46.TSIntersectionType, AST_NODE_TYPES46.TSTypeReference]
|
|
9269
9404
|
};
|
|
9270
9405
|
function normalizeSchemaName(name) {
|
|
9271
9406
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9274,20 +9409,20 @@ function normalizeTypeName(name) {
|
|
|
9274
9409
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9275
9410
|
}
|
|
9276
9411
|
function unwrapNullish(annotation) {
|
|
9277
|
-
if (annotation.type !==
|
|
9412
|
+
if (annotation.type !== AST_NODE_TYPES46.TSUnionType) {
|
|
9278
9413
|
return {
|
|
9279
9414
|
core: annotation,
|
|
9280
|
-
nullable: annotation.type ===
|
|
9415
|
+
nullable: annotation.type === AST_NODE_TYPES46.TSNullKeyword
|
|
9281
9416
|
};
|
|
9282
9417
|
}
|
|
9283
9418
|
const rest = [];
|
|
9284
9419
|
let nullable = false;
|
|
9285
9420
|
for (const member of annotation.types) {
|
|
9286
|
-
if (member.type ===
|
|
9421
|
+
if (member.type === AST_NODE_TYPES46.TSNullKeyword) {
|
|
9287
9422
|
nullable = true;
|
|
9288
9423
|
continue;
|
|
9289
9424
|
}
|
|
9290
|
-
if (member.type ===
|
|
9425
|
+
if (member.type === AST_NODE_TYPES46.TSUndefinedKeyword) {
|
|
9291
9426
|
continue;
|
|
9292
9427
|
}
|
|
9293
9428
|
rest.push(member);
|
|
@@ -9352,14 +9487,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9352
9487
|
function zodCallChain(node) {
|
|
9353
9488
|
const chain = [];
|
|
9354
9489
|
let current = node;
|
|
9355
|
-
while (current.type ===
|
|
9490
|
+
while (current.type === AST_NODE_TYPES46.CallExpression) {
|
|
9356
9491
|
const callee = current.callee;
|
|
9357
|
-
if (callee.type !==
|
|
9492
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9358
9493
|
return null;
|
|
9359
9494
|
}
|
|
9360
9495
|
chain.push(current);
|
|
9361
9496
|
const receiver = callee.object;
|
|
9362
|
-
if (receiver.type ===
|
|
9497
|
+
if (receiver.type === AST_NODE_TYPES46.Identifier) {
|
|
9363
9498
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9364
9499
|
}
|
|
9365
9500
|
current = receiver;
|
|
@@ -9368,19 +9503,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9368
9503
|
}
|
|
9369
9504
|
function methodName(call) {
|
|
9370
9505
|
const callee = call.callee;
|
|
9371
|
-
return callee.type ===
|
|
9506
|
+
return callee.type === AST_NODE_TYPES46.MemberExpression && callee.property.type === AST_NODE_TYPES46.Identifier ? callee.property.name : "";
|
|
9372
9507
|
}
|
|
9373
9508
|
function schemaField(node) {
|
|
9374
9509
|
const modifiers = [];
|
|
9375
9510
|
let current = node;
|
|
9376
9511
|
let leaf = null;
|
|
9377
|
-
while (current.type ===
|
|
9512
|
+
while (current.type === AST_NODE_TYPES46.CallExpression) {
|
|
9378
9513
|
const callee = current.callee;
|
|
9379
|
-
if (callee.type !==
|
|
9514
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9380
9515
|
break;
|
|
9381
9516
|
}
|
|
9382
9517
|
const receiver = callee.object;
|
|
9383
|
-
if (receiver.type ===
|
|
9518
|
+
if (receiver.type === AST_NODE_TYPES46.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9384
9519
|
leaf = callee.property.name;
|
|
9385
9520
|
break;
|
|
9386
9521
|
}
|
|
@@ -9411,16 +9546,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9411
9546
|
return null;
|
|
9412
9547
|
}
|
|
9413
9548
|
const shape = base.arguments[0];
|
|
9414
|
-
if (shape === void 0 || shape.type !==
|
|
9549
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES46.ObjectExpression) {
|
|
9415
9550
|
return null;
|
|
9416
9551
|
}
|
|
9417
9552
|
const fields = /* @__PURE__ */ new Map();
|
|
9418
9553
|
for (const property of shape.properties) {
|
|
9419
|
-
if (property.type !==
|
|
9554
|
+
if (property.type !== AST_NODE_TYPES46.Property || property.computed) {
|
|
9420
9555
|
return null;
|
|
9421
9556
|
}
|
|
9422
9557
|
const { key } = property;
|
|
9423
|
-
const name = key.type ===
|
|
9558
|
+
const name = key.type === AST_NODE_TYPES46.Identifier ? key.name : key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string" ? key.value : null;
|
|
9424
9559
|
if (name === null) {
|
|
9425
9560
|
return null;
|
|
9426
9561
|
}
|
|
@@ -9431,11 +9566,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9431
9566
|
function typeMembers(members) {
|
|
9432
9567
|
const result = /* @__PURE__ */ new Map();
|
|
9433
9568
|
for (const member of members) {
|
|
9434
|
-
if (member.type !==
|
|
9569
|
+
if (member.type !== AST_NODE_TYPES46.TSPropertySignature || member.computed) {
|
|
9435
9570
|
return null;
|
|
9436
9571
|
}
|
|
9437
9572
|
const { key } = member;
|
|
9438
|
-
const name = key.type ===
|
|
9573
|
+
const name = key.type === AST_NODE_TYPES46.Identifier ? key.name : key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string" ? key.value : null;
|
|
9439
9574
|
if (name === null) {
|
|
9440
9575
|
return null;
|
|
9441
9576
|
}
|
|
@@ -9449,8 +9584,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9449
9584
|
return result.size === 0 ? null : result;
|
|
9450
9585
|
}
|
|
9451
9586
|
function collectConstrainedNames(node) {
|
|
9452
|
-
if (node.type ===
|
|
9453
|
-
if (node.typeName.type ===
|
|
9587
|
+
if (node.type === AST_NODE_TYPES46.TSTypeReference) {
|
|
9588
|
+
if (node.typeName.type === AST_NODE_TYPES46.Identifier) {
|
|
9454
9589
|
constrainedTypeNames.add(node.typeName.name);
|
|
9455
9590
|
}
|
|
9456
9591
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9458,11 +9593,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9458
9593
|
}
|
|
9459
9594
|
return;
|
|
9460
9595
|
}
|
|
9461
|
-
if (node.type ===
|
|
9596
|
+
if (node.type === AST_NODE_TYPES46.TSArrayType) {
|
|
9462
9597
|
collectConstrainedNames(node.elementType);
|
|
9463
9598
|
return;
|
|
9464
9599
|
}
|
|
9465
|
-
if (node.type ===
|
|
9600
|
+
if (node.type === AST_NODE_TYPES46.TSUnionType || node.type === AST_NODE_TYPES46.TSIntersectionType) {
|
|
9466
9601
|
for (const member of node.types) {
|
|
9467
9602
|
collectConstrainedNames(member);
|
|
9468
9603
|
}
|
|
@@ -9506,13 +9641,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9506
9641
|
return;
|
|
9507
9642
|
}
|
|
9508
9643
|
for (const specifier of node.specifiers) {
|
|
9509
|
-
if (specifier.type ===
|
|
9644
|
+
if (specifier.type === AST_NODE_TYPES46.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES46.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES46.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES46.Identifier && specifier.imported.name === "z") {
|
|
9510
9645
|
zodNamespaces.add(specifier.local.name);
|
|
9511
9646
|
}
|
|
9512
9647
|
}
|
|
9513
9648
|
},
|
|
9514
9649
|
VariableDeclarator(node) {
|
|
9515
|
-
if (node.id.type !==
|
|
9650
|
+
if (node.id.type !== AST_NODE_TYPES46.Identifier || node.init == null) {
|
|
9516
9651
|
return;
|
|
9517
9652
|
}
|
|
9518
9653
|
const fields = schemaFields(node.init);
|
|
@@ -9522,14 +9657,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9522
9657
|
},
|
|
9523
9658
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9524
9659
|
"MemberExpression[computed=false]"(node) {
|
|
9525
|
-
if (node.object.type ===
|
|
9660
|
+
if (node.object.type === AST_NODE_TYPES46.Identifier && node.property.type === AST_NODE_TYPES46.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9526
9661
|
reshapedSchemaNames.add(node.object.name);
|
|
9527
9662
|
}
|
|
9528
9663
|
},
|
|
9529
9664
|
/** Records every type argument carried by a Zod constraint. */
|
|
9530
9665
|
TSTypeReference(node) {
|
|
9531
9666
|
const { typeName } = node;
|
|
9532
|
-
const referenced = typeName.type ===
|
|
9667
|
+
const referenced = typeName.type === AST_NODE_TYPES46.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES46.TSQualifiedName && typeName.right.type === AST_NODE_TYPES46.Identifier ? typeName.right.name : null;
|
|
9533
9668
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9534
9669
|
return;
|
|
9535
9670
|
}
|
|
@@ -9547,7 +9682,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9547
9682
|
}
|
|
9548
9683
|
},
|
|
9549
9684
|
TSTypeAliasDeclaration(node) {
|
|
9550
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9685
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES46.TSTypeLiteral) {
|
|
9551
9686
|
return;
|
|
9552
9687
|
}
|
|
9553
9688
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9592,10 +9727,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9592
9727
|
});
|
|
9593
9728
|
|
|
9594
9729
|
// src/rules/require-assert-never.ts
|
|
9595
|
-
import { AST_NODE_TYPES as
|
|
9730
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9596
9731
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9597
|
-
if (statement.type ===
|
|
9598
|
-
if (statement.type ===
|
|
9732
|
+
if (statement.type === AST_NODE_TYPES47.EmptyStatement) return false;
|
|
9733
|
+
if (statement.type === AST_NODE_TYPES47.BlockStatement) {
|
|
9599
9734
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9600
9735
|
}
|
|
9601
9736
|
return true;
|
|
@@ -9611,7 +9746,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9611
9746
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9612
9747
|
}
|
|
9613
9748
|
const only = defaultCase.consequent[0];
|
|
9614
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9749
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES47.BlockStatement && only.body.length === 0) {
|
|
9615
9750
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9616
9751
|
}
|
|
9617
9752
|
return false;
|
|
@@ -9651,7 +9786,7 @@ var require_assert_never_default = createRule({
|
|
|
9651
9786
|
});
|
|
9652
9787
|
|
|
9653
9788
|
// src/rules/require-fetch-timeout.ts
|
|
9654
|
-
import { AST_NODE_TYPES as
|
|
9789
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
9655
9790
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9656
9791
|
"globalThis",
|
|
9657
9792
|
"window",
|
|
@@ -9667,14 +9802,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9667
9802
|
return false;
|
|
9668
9803
|
}
|
|
9669
9804
|
function initProvablyLacksSignal(init) {
|
|
9670
|
-
if (init.type !==
|
|
9805
|
+
if (init.type !== AST_NODE_TYPES48.ObjectExpression) {
|
|
9671
9806
|
return false;
|
|
9672
9807
|
}
|
|
9673
9808
|
for (const prop of init.properties) {
|
|
9674
|
-
if (prop.type ===
|
|
9809
|
+
if (prop.type === AST_NODE_TYPES48.SpreadElement) {
|
|
9675
9810
|
return false;
|
|
9676
9811
|
}
|
|
9677
|
-
if (prop.key.type ===
|
|
9812
|
+
if (prop.key.type === AST_NODE_TYPES48.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES48.Literal && prop.key.value === "signal") {
|
|
9678
9813
|
return false;
|
|
9679
9814
|
}
|
|
9680
9815
|
if (prop.computed) {
|
|
@@ -9684,7 +9819,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9684
9819
|
return true;
|
|
9685
9820
|
}
|
|
9686
9821
|
function isStringish(node) {
|
|
9687
|
-
return node.type ===
|
|
9822
|
+
return node.type === AST_NODE_TYPES48.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES48.TemplateLiteral;
|
|
9688
9823
|
}
|
|
9689
9824
|
var require_fetch_timeout_default = createRule({
|
|
9690
9825
|
name: "require-fetch-timeout",
|
|
@@ -9725,10 +9860,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
9725
9860
|
return variable === null || variable.defs.length === 0;
|
|
9726
9861
|
}
|
|
9727
9862
|
function isGlobalFetchCall2(callee) {
|
|
9728
|
-
if (callee.type ===
|
|
9863
|
+
if (callee.type === AST_NODE_TYPES48.Identifier) {
|
|
9729
9864
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9730
9865
|
}
|
|
9731
|
-
return callee.type ===
|
|
9866
|
+
return callee.type === AST_NODE_TYPES48.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES48.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES48.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9732
9867
|
}
|
|
9733
9868
|
return {
|
|
9734
9869
|
CallExpression(node) {
|
|
@@ -9748,7 +9883,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9748
9883
|
});
|
|
9749
9884
|
|
|
9750
9885
|
// src/rules/require-interface-for-injected-service.ts
|
|
9751
|
-
import { AST_NODE_TYPES as
|
|
9886
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49 } from "@typescript-eslint/utils";
|
|
9752
9887
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9753
9888
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9754
9889
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9756,20 +9891,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9756
9891
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9757
9892
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9758
9893
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9759
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9760
|
-
var qualifiedName = (name) => name.type ===
|
|
9894
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES49.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES49.ExportDefaultDeclaration;
|
|
9895
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES49.Identifier ? name.name : name.type === AST_NODE_TYPES49.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9761
9896
|
var readTypeReference = (annotation) => {
|
|
9762
|
-
if (annotation === void 0 || annotation.type !==
|
|
9897
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES49.TSTypeReference) return null;
|
|
9763
9898
|
const { typeName } = annotation;
|
|
9764
|
-
const rightmost = typeName.type ===
|
|
9899
|
+
const rightmost = typeName.type === AST_NODE_TYPES49.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES49.TSQualifiedName ? typeName.right.name : null;
|
|
9765
9900
|
if (rightmost === null) return null;
|
|
9766
9901
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9767
9902
|
};
|
|
9768
9903
|
var namedParameterCollaborator = (annotated) => {
|
|
9769
9904
|
let target = annotated;
|
|
9770
|
-
if (target.type ===
|
|
9771
|
-
if (target.type ===
|
|
9772
|
-
if (target.type !==
|
|
9905
|
+
if (target.type === AST_NODE_TYPES49.TSParameterProperty) target = target.parameter;
|
|
9906
|
+
if (target.type === AST_NODE_TYPES49.AssignmentPattern) target = target.left;
|
|
9907
|
+
if (target.type !== AST_NODE_TYPES49.Identifier) return null;
|
|
9773
9908
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9774
9909
|
if (reference === null) return null;
|
|
9775
9910
|
return { name: target.name, ...reference };
|
|
@@ -9777,8 +9912,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9777
9912
|
var propertySignatureTypes = (members) => {
|
|
9778
9913
|
const types = /* @__PURE__ */ new Map();
|
|
9779
9914
|
for (const member of members) {
|
|
9780
|
-
if (member.type !==
|
|
9781
|
-
if (member.computed || member.key.type !==
|
|
9915
|
+
if (member.type !== AST_NODE_TYPES49.TSPropertySignature) continue;
|
|
9916
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9782
9917
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9783
9918
|
if (reference === null) continue;
|
|
9784
9919
|
types.set(member.key.name, reference);
|
|
@@ -9789,18 +9924,18 @@ var fileTypeIndex = (program) => {
|
|
|
9789
9924
|
const objects = /* @__PURE__ */ new Map();
|
|
9790
9925
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9791
9926
|
for (const statement of program.body) {
|
|
9792
|
-
const declaration = statement.type ===
|
|
9793
|
-
if (declaration?.type ===
|
|
9927
|
+
const declaration = statement.type === AST_NODE_TYPES49.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9928
|
+
if (declaration?.type === AST_NODE_TYPES49.TSInterfaceDeclaration) {
|
|
9794
9929
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9795
9930
|
continue;
|
|
9796
9931
|
}
|
|
9797
|
-
if (declaration?.type !==
|
|
9932
|
+
if (declaration?.type !== AST_NODE_TYPES49.TSTypeAliasDeclaration) continue;
|
|
9798
9933
|
const aliased = declaration.typeAnnotation;
|
|
9799
|
-
if (aliased.type ===
|
|
9934
|
+
if (aliased.type === AST_NODE_TYPES49.TSFunctionType || aliased.type === AST_NODE_TYPES49.TSConstructorType) {
|
|
9800
9935
|
functionAliases.add(declaration.id.name);
|
|
9801
9936
|
continue;
|
|
9802
9937
|
}
|
|
9803
|
-
const literals = aliased.type ===
|
|
9938
|
+
const literals = aliased.type === AST_NODE_TYPES49.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES49.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES49.TSTypeLiteral) : [];
|
|
9804
9939
|
if (literals.length === 0) continue;
|
|
9805
9940
|
const merged = /* @__PURE__ */ new Map();
|
|
9806
9941
|
for (const literal of literals) {
|
|
@@ -9813,10 +9948,10 @@ var fileTypeIndex = (program) => {
|
|
|
9813
9948
|
return { objects, functionAliases };
|
|
9814
9949
|
};
|
|
9815
9950
|
var bagMemberTypes = (annotation, declared) => {
|
|
9816
|
-
if (annotation.type ===
|
|
9951
|
+
if (annotation.type === AST_NODE_TYPES49.TSTypeLiteral) {
|
|
9817
9952
|
return propertySignatureTypes(annotation.members);
|
|
9818
9953
|
}
|
|
9819
|
-
if (annotation.type !==
|
|
9954
|
+
if (annotation.type !== AST_NODE_TYPES49.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES49.Identifier) {
|
|
9820
9955
|
return null;
|
|
9821
9956
|
}
|
|
9822
9957
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9828,11 +9963,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9828
9963
|
if (members === null) return [];
|
|
9829
9964
|
const collaborators = [];
|
|
9830
9965
|
for (const property of pattern.properties) {
|
|
9831
|
-
if (property.type !==
|
|
9832
|
-
if (property.key.type !==
|
|
9966
|
+
if (property.type !== AST_NODE_TYPES49.Property || property.computed) continue;
|
|
9967
|
+
if (property.key.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9833
9968
|
const key = property.key.name;
|
|
9834
|
-
const bound = property.value.type ===
|
|
9835
|
-
if (bound.type !==
|
|
9969
|
+
const bound = property.value.type === AST_NODE_TYPES49.AssignmentPattern ? property.value.left : property.value;
|
|
9970
|
+
if (bound.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9836
9971
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9837
9972
|
const reference = members.get(key);
|
|
9838
9973
|
if (reference === void 0) continue;
|
|
@@ -9842,8 +9977,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9842
9977
|
};
|
|
9843
9978
|
var parameterCollaborators = (parameter, declared) => {
|
|
9844
9979
|
let target = parameter;
|
|
9845
|
-
if (target.type ===
|
|
9846
|
-
if (target.type ===
|
|
9980
|
+
if (target.type === AST_NODE_TYPES49.AssignmentPattern) target = target.left;
|
|
9981
|
+
if (target.type === AST_NODE_TYPES49.ObjectPattern) {
|
|
9847
9982
|
return objectPatternCollaborators(target, declared);
|
|
9848
9983
|
}
|
|
9849
9984
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9862,17 +9997,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9862
9997
|
let constructedFields = 0;
|
|
9863
9998
|
if (body2 !== null && body2 !== void 0) {
|
|
9864
9999
|
for (const statement of body2.body) {
|
|
9865
|
-
if (statement.type !==
|
|
10000
|
+
if (statement.type !== AST_NODE_TYPES49.ExpressionStatement) continue;
|
|
9866
10001
|
const expression = statement.expression;
|
|
9867
|
-
if (expression.type !==
|
|
10002
|
+
if (expression.type !== AST_NODE_TYPES49.AssignmentExpression || expression.operator !== "=" || expression.left.type !== AST_NODE_TYPES49.MemberExpression || expression.left.object.type !== AST_NODE_TYPES49.ThisExpression) {
|
|
9868
10003
|
continue;
|
|
9869
10004
|
}
|
|
9870
10005
|
const source = expression.right;
|
|
9871
|
-
if (source.type ===
|
|
10006
|
+
if (source.type === AST_NODE_TYPES49.NewExpression) {
|
|
9872
10007
|
constructedFields += 1;
|
|
9873
|
-
} else if (source.type ===
|
|
10008
|
+
} else if (source.type === AST_NODE_TYPES49.Identifier) {
|
|
9874
10009
|
storedFrom.add(source.name);
|
|
9875
|
-
} else if (source.type ===
|
|
10010
|
+
} else if (source.type === AST_NODE_TYPES49.MemberExpression && source.object.type === AST_NODE_TYPES49.Identifier) {
|
|
9876
10011
|
storedFrom.add(source.object.name);
|
|
9877
10012
|
}
|
|
9878
10013
|
}
|
|
@@ -9880,7 +10015,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9880
10015
|
const collaborators = [];
|
|
9881
10016
|
for (const parameter of ctor.value.params) {
|
|
9882
10017
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9883
|
-
const stored = parameter.type ===
|
|
10018
|
+
const stored = parameter.type === AST_NODE_TYPES49.TSParameterProperty || storedFrom.has(reference.name);
|
|
9884
10019
|
if (!stored) continue;
|
|
9885
10020
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9886
10021
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9914,19 +10049,19 @@ var subtreeHas = (root, found) => {
|
|
|
9914
10049
|
return hit;
|
|
9915
10050
|
};
|
|
9916
10051
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9917
|
-
if (node.type ===
|
|
10052
|
+
if (node.type === AST_NODE_TYPES49.CallExpression) {
|
|
9918
10053
|
const { callee } = node;
|
|
9919
|
-
if (callee.type ===
|
|
9920
|
-
return callee.type ===
|
|
10054
|
+
if (callee.type === AST_NODE_TYPES49.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
10055
|
+
return callee.type === AST_NODE_TYPES49.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES49.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9921
10056
|
}
|
|
9922
|
-
return node.type ===
|
|
10057
|
+
return node.type === AST_NODE_TYPES49.TSTypeReference && node.typeName.type === AST_NODE_TYPES49.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9923
10058
|
});
|
|
9924
10059
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9925
10060
|
var fileInterfaceNames = (program) => {
|
|
9926
10061
|
const names = [];
|
|
9927
10062
|
for (const statement of program.body) {
|
|
9928
|
-
const declaration = statement.type ===
|
|
9929
|
-
if (declaration?.type ===
|
|
10063
|
+
const declaration = statement.type === AST_NODE_TYPES49.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10064
|
+
if (declaration?.type === AST_NODE_TYPES49.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9930
10065
|
}
|
|
9931
10066
|
return names;
|
|
9932
10067
|
};
|
|
@@ -9944,11 +10079,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9944
10079
|
var publicMethodNames = (body2) => {
|
|
9945
10080
|
const names = [];
|
|
9946
10081
|
for (const member of body2.body) {
|
|
9947
|
-
if (member.type !==
|
|
10082
|
+
if (member.type !== AST_NODE_TYPES49.MethodDefinition) continue;
|
|
9948
10083
|
if (member.kind !== "method" || member.static) continue;
|
|
9949
10084
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9950
|
-
if (member.key.type ===
|
|
9951
|
-
if (member.key.type ===
|
|
10085
|
+
if (member.key.type === AST_NODE_TYPES49.PrivateIdentifier) continue;
|
|
10086
|
+
if (member.key.type === AST_NODE_TYPES49.Identifier) names.push(member.key.name);
|
|
9952
10087
|
else names.push("\u2026");
|
|
9953
10088
|
}
|
|
9954
10089
|
return names;
|
|
@@ -9981,7 +10116,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9981
10116
|
if (node.implements.length > 0) return;
|
|
9982
10117
|
if (node.decorators.length > 0) return;
|
|
9983
10118
|
const ctor = node.body.body.find(
|
|
9984
|
-
(member) => member.type ===
|
|
10119
|
+
(member) => member.type === AST_NODE_TYPES49.MethodDefinition && member.kind === "constructor"
|
|
9985
10120
|
);
|
|
9986
10121
|
if (ctor === void 0) return;
|
|
9987
10122
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -10010,37 +10145,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10010
10145
|
});
|
|
10011
10146
|
|
|
10012
10147
|
// src/rules/require-static-next-matcher.ts
|
|
10013
|
-
import { AST_NODE_TYPES as
|
|
10148
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
10014
10149
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
10015
|
-
function
|
|
10016
|
-
if (node.type ===
|
|
10017
|
-
return
|
|
10150
|
+
function unwrapExpression2(node) {
|
|
10151
|
+
if (node.type === AST_NODE_TYPES50.TSAsExpression || node.type === AST_NODE_TYPES50.TSSatisfiesExpression || node.type === AST_NODE_TYPES50.TSNonNullExpression || node.type === AST_NODE_TYPES50.TSTypeAssertion) {
|
|
10152
|
+
return unwrapExpression2(node.expression);
|
|
10018
10153
|
}
|
|
10019
10154
|
return node;
|
|
10020
10155
|
}
|
|
10021
10156
|
function isStaticValue(node) {
|
|
10022
|
-
const value =
|
|
10023
|
-
if (value.type ===
|
|
10157
|
+
const value = unwrapExpression2(node);
|
|
10158
|
+
if (value.type === AST_NODE_TYPES50.Literal) {
|
|
10024
10159
|
return true;
|
|
10025
10160
|
}
|
|
10026
|
-
if (value.type ===
|
|
10161
|
+
if (value.type === AST_NODE_TYPES50.TemplateLiteral) {
|
|
10027
10162
|
return value.expressions.length === 0;
|
|
10028
10163
|
}
|
|
10029
|
-
if (value.type ===
|
|
10164
|
+
if (value.type === AST_NODE_TYPES50.ArrayExpression) {
|
|
10030
10165
|
return value.elements.every(
|
|
10031
|
-
(element) => element !== null && element.type !==
|
|
10166
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES50.SpreadElement && isStaticValue(element)
|
|
10032
10167
|
);
|
|
10033
10168
|
}
|
|
10034
|
-
if (value.type ===
|
|
10169
|
+
if (value.type === AST_NODE_TYPES50.ObjectExpression) {
|
|
10035
10170
|
return value.properties.every(
|
|
10036
|
-
(property) => property.type ===
|
|
10171
|
+
(property) => property.type === AST_NODE_TYPES50.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES50.AssignmentPattern && isStaticValue(property.value)
|
|
10037
10172
|
);
|
|
10038
10173
|
}
|
|
10039
10174
|
return false;
|
|
10040
10175
|
}
|
|
10041
10176
|
function propertyName2(property) {
|
|
10042
10177
|
if (property.computed) return null;
|
|
10043
|
-
if (property.key.type ===
|
|
10178
|
+
if (property.key.type === AST_NODE_TYPES50.Identifier) return property.key.name;
|
|
10044
10179
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
10045
10180
|
}
|
|
10046
10181
|
var require_static_next_matcher_default = createRule({
|
|
@@ -10062,19 +10197,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
10062
10197
|
}
|
|
10063
10198
|
return {
|
|
10064
10199
|
ExportNamedDeclaration(node) {
|
|
10065
|
-
if (node.declaration?.type !==
|
|
10200
|
+
if (node.declaration?.type !== AST_NODE_TYPES50.VariableDeclaration) {
|
|
10066
10201
|
return;
|
|
10067
10202
|
}
|
|
10068
10203
|
for (const declaration of node.declaration.declarations) {
|
|
10069
|
-
if (declaration.id.type !==
|
|
10204
|
+
if (declaration.id.type !== AST_NODE_TYPES50.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
10070
10205
|
continue;
|
|
10071
10206
|
}
|
|
10072
|
-
const config =
|
|
10073
|
-
if (config.type !==
|
|
10207
|
+
const config = unwrapExpression2(declaration.init);
|
|
10208
|
+
if (config.type !== AST_NODE_TYPES50.ObjectExpression) {
|
|
10074
10209
|
continue;
|
|
10075
10210
|
}
|
|
10076
10211
|
for (const property of config.properties) {
|
|
10077
|
-
if (property.type !==
|
|
10212
|
+
if (property.type !== AST_NODE_TYPES50.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES50.AssignmentPattern) {
|
|
10078
10213
|
continue;
|
|
10079
10214
|
}
|
|
10080
10215
|
if (!isStaticValue(property.value)) {
|
|
@@ -10088,18 +10223,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
10088
10223
|
});
|
|
10089
10224
|
|
|
10090
10225
|
// src/rules/require-zod-form-validation.ts
|
|
10091
|
-
import { AST_NODE_TYPES as
|
|
10226
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51 } from "@typescript-eslint/utils";
|
|
10092
10227
|
var looksLikeZodSchema = (node) => {
|
|
10093
10228
|
let current = node;
|
|
10094
10229
|
while (true) {
|
|
10095
|
-
if (current.type ===
|
|
10230
|
+
if (current.type === AST_NODE_TYPES51.Identifier) {
|
|
10096
10231
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10097
10232
|
}
|
|
10098
|
-
if (current.type ===
|
|
10233
|
+
if (current.type === AST_NODE_TYPES51.CallExpression) {
|
|
10099
10234
|
current = current.callee;
|
|
10100
10235
|
continue;
|
|
10101
10236
|
}
|
|
10102
|
-
if (current.type ===
|
|
10237
|
+
if (current.type === AST_NODE_TYPES51.MemberExpression) {
|
|
10103
10238
|
current = current.object;
|
|
10104
10239
|
continue;
|
|
10105
10240
|
}
|
|
@@ -10107,23 +10242,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10107
10242
|
}
|
|
10108
10243
|
};
|
|
10109
10244
|
var isZodParseCall = (node) => {
|
|
10110
|
-
if (node.type !==
|
|
10245
|
+
if (node.type !== AST_NODE_TYPES51.CallExpression) return false;
|
|
10111
10246
|
const callee = node.callee;
|
|
10112
|
-
if (callee.type !==
|
|
10247
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return false;
|
|
10113
10248
|
if (callee.computed) return false;
|
|
10114
|
-
if (callee.property.type !==
|
|
10249
|
+
if (callee.property.type !== AST_NODE_TYPES51.Identifier) return false;
|
|
10115
10250
|
const method = callee.property.name;
|
|
10116
10251
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10117
10252
|
return looksLikeZodSchema(callee.object);
|
|
10118
10253
|
};
|
|
10119
10254
|
var isFormDataMethodCall = (node) => {
|
|
10120
10255
|
let current = node;
|
|
10121
|
-
if (current.type ===
|
|
10256
|
+
if (current.type === AST_NODE_TYPES51.AwaitExpression) {
|
|
10122
10257
|
current = current.argument;
|
|
10123
10258
|
}
|
|
10124
|
-
if (current.type !==
|
|
10259
|
+
if (current.type !== AST_NODE_TYPES51.CallExpression) return false;
|
|
10125
10260
|
const callee = current.callee;
|
|
10126
|
-
return callee.type ===
|
|
10261
|
+
return callee.type === AST_NODE_TYPES51.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES51.Identifier && callee.property.name === "formData";
|
|
10127
10262
|
};
|
|
10128
10263
|
var require_zod_form_validation_default = createRule({
|
|
10129
10264
|
name: "require-zod-form-validation",
|
|
@@ -10143,14 +10278,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10143
10278
|
return {};
|
|
10144
10279
|
}
|
|
10145
10280
|
const isFormSourceIdentifier = (node) => {
|
|
10146
|
-
if (node.type !==
|
|
10281
|
+
if (node.type !== AST_NODE_TYPES51.Identifier) return false;
|
|
10147
10282
|
if (/formdata/i.test(node.name)) return true;
|
|
10148
10283
|
let scope = context.sourceCode.getScope(node);
|
|
10149
10284
|
while (scope !== null) {
|
|
10150
10285
|
const variable = scope.set.get(node.name);
|
|
10151
10286
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10152
10287
|
const def = variable.defs[0];
|
|
10153
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10288
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES51.VariableDeclarator && def.node.init !== null) {
|
|
10154
10289
|
return isFormDataMethodCall(def.node.init);
|
|
10155
10290
|
}
|
|
10156
10291
|
return false;
|
|
@@ -10161,8 +10296,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10161
10296
|
};
|
|
10162
10297
|
const isFormDataGetCall = (node) => {
|
|
10163
10298
|
const callee = node.callee;
|
|
10164
|
-
if (callee.type !==
|
|
10165
|
-
if (callee.property.type !==
|
|
10299
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return false;
|
|
10300
|
+
if (callee.property.type !== AST_NODE_TYPES51.Identifier || callee.property.name !== "get") {
|
|
10166
10301
|
return false;
|
|
10167
10302
|
}
|
|
10168
10303
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10177,11 +10312,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10177
10312
|
};
|
|
10178
10313
|
const isInstanceofNarrowing = (node) => {
|
|
10179
10314
|
const parent = node.parent;
|
|
10180
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10315
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES51.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES51.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
10181
10316
|
};
|
|
10182
10317
|
const boundDeclarator = (node) => {
|
|
10183
10318
|
const parent = node.parent;
|
|
10184
|
-
if (parent.type ===
|
|
10319
|
+
if (parent.type === AST_NODE_TYPES51.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES51.Identifier) {
|
|
10185
10320
|
return parent;
|
|
10186
10321
|
}
|
|
10187
10322
|
return null;
|
|
@@ -10240,7 +10375,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10240
10375
|
});
|
|
10241
10376
|
|
|
10242
10377
|
// src/rules/zod-naming-convention.ts
|
|
10243
|
-
import { AST_NODE_TYPES as
|
|
10378
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
10244
10379
|
var CONVENTIONS = {
|
|
10245
10380
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10246
10381
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10265,15 +10400,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10265
10400
|
"registry",
|
|
10266
10401
|
"implement"
|
|
10267
10402
|
]);
|
|
10268
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10403
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES52.Identifier ? callee.property.name : null;
|
|
10269
10404
|
var calleeChainStartsWithZ = (node) => {
|
|
10270
10405
|
let current = node;
|
|
10271
|
-
while (current.type ===
|
|
10406
|
+
while (current.type === AST_NODE_TYPES52.MemberExpression) {
|
|
10272
10407
|
const receiver = current.object;
|
|
10273
|
-
if (receiver.type ===
|
|
10408
|
+
if (receiver.type === AST_NODE_TYPES52.Identifier && receiver.name === "z") {
|
|
10274
10409
|
return true;
|
|
10275
10410
|
}
|
|
10276
|
-
if (receiver.type ===
|
|
10411
|
+
if (receiver.type === AST_NODE_TYPES52.CallExpression) {
|
|
10277
10412
|
current = receiver.callee;
|
|
10278
10413
|
continue;
|
|
10279
10414
|
}
|
|
@@ -10318,13 +10453,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10318
10453
|
VariableDeclarator(node) {
|
|
10319
10454
|
const init = node.init;
|
|
10320
10455
|
if (init === null || init === void 0) return;
|
|
10321
|
-
if (init.type !==
|
|
10456
|
+
if (init.type !== AST_NODE_TYPES52.CallExpression) return;
|
|
10322
10457
|
const callee = init.callee;
|
|
10323
|
-
if (callee.type !==
|
|
10458
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression) return;
|
|
10324
10459
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10325
10460
|
const terminal = terminalMethodName(callee);
|
|
10326
10461
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10327
|
-
if (node.id.type !==
|
|
10462
|
+
if (node.id.type !== AST_NODE_TYPES52.Identifier) return;
|
|
10328
10463
|
if (test.test(node.id.name)) return;
|
|
10329
10464
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10330
10465
|
context.report({
|
|
@@ -10436,6 +10571,7 @@ var rules = {
|
|
|
10436
10571
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10437
10572
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10438
10573
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10574
|
+
"prefer-immutable-module-constant": prefer_immutable_module_constant_default,
|
|
10439
10575
|
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
10440
10576
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10441
10577
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
@@ -10459,7 +10595,7 @@ var rules = {
|
|
|
10459
10595
|
};
|
|
10460
10596
|
var meta = {
|
|
10461
10597
|
name: "@sarj/eslint-plugin",
|
|
10462
|
-
version: "9.
|
|
10598
|
+
version: "9.13.0"
|
|
10463
10599
|
};
|
|
10464
10600
|
var applicationOnlyRules = [
|
|
10465
10601
|
"no-restricted-library-load",
|
|
@@ -10504,6 +10640,7 @@ var recommendedRules = {
|
|
|
10504
10640
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10505
10641
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10506
10642
|
"@sarj/prefer-input-group-search": "error",
|
|
10643
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10507
10644
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10508
10645
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10509
10646
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10565,6 +10702,7 @@ var strictRules = {
|
|
|
10565
10702
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10566
10703
|
"@sarj/prefer-discriminated-union": "error",
|
|
10567
10704
|
"@sarj/prefer-input-group-search": "error",
|
|
10705
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10568
10706
|
"@sarj/prefer-module-level-constant": "error",
|
|
10569
10707
|
"@sarj/prefer-module-level-schema": "error",
|
|
10570
10708
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10615,4 +10753,3 @@ export {
|
|
|
10615
10753
|
rules,
|
|
10616
10754
|
strictRules
|
|
10617
10755
|
};
|
|
10618
|
-
//# sourceMappingURL=index.js.map
|