@sarj/eslint-plugin 9.12.1 → 9.13.1
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/index.cjs +505 -357
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +502 -354
- package/package.json +5 -3
- 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,154 @@ var prefer_input_group_search_default = createRule({
|
|
|
6708
6708
|
}
|
|
6709
6709
|
});
|
|
6710
6710
|
|
|
6711
|
+
// src/rules/prefer-immutable-module-constant.ts
|
|
6712
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES35, ASTUtils as ASTUtils3 } 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, isUnshadowedGlobal) {
|
|
6742
|
+
const inner = unwrapExpression(node);
|
|
6743
|
+
if (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" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
|
|
6744
|
+
const argument = inner.arguments[0];
|
|
6745
|
+
return argument !== void 0 && argument.type !== AST_NODE_TYPES35.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
|
|
6746
|
+
}
|
|
6747
|
+
return false;
|
|
6748
|
+
}
|
|
6749
|
+
function collectionKind(node, isUnshadowedGlobal) {
|
|
6750
|
+
const inner = unwrapExpression(node);
|
|
6751
|
+
if (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" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES35.SpreadElement) {
|
|
6752
|
+
return collectionKind(inner.arguments[0], isUnshadowedGlobal);
|
|
6753
|
+
}
|
|
6754
|
+
if (inner.type === AST_NODE_TYPES35.ArrayExpression || inner.type === AST_NODE_TYPES35.ObjectExpression) {
|
|
6755
|
+
return "literal";
|
|
6756
|
+
}
|
|
6757
|
+
if (inner.type === AST_NODE_TYPES35.NewExpression && inner.callee.type === AST_NODE_TYPES35.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
|
|
6758
|
+
return inner.callee.name;
|
|
6759
|
+
}
|
|
6760
|
+
return null;
|
|
6761
|
+
}
|
|
6762
|
+
function isReadonlyType(node, kind) {
|
|
6763
|
+
if (node.type === AST_NODE_TYPES35.TSTypeOperator && node.operator === "readonly") {
|
|
6764
|
+
return true;
|
|
6765
|
+
}
|
|
6766
|
+
if (node.type !== AST_NODE_TYPES35.TSTypeReference || node.typeName.type !== AST_NODE_TYPES35.Identifier) {
|
|
6767
|
+
return false;
|
|
6768
|
+
}
|
|
6769
|
+
if (node.typeName.name === "Readonly") {
|
|
6770
|
+
return kind === "literal";
|
|
6771
|
+
}
|
|
6772
|
+
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6773
|
+
}
|
|
6774
|
+
function declaredReadonlyType(node, kind) {
|
|
6775
|
+
const annotation = node.id.type === AST_NODE_TYPES35.Identifier ? node.id.typeAnnotation : void 0;
|
|
6776
|
+
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6777
|
+
return true;
|
|
6778
|
+
}
|
|
6779
|
+
return node.init?.type === AST_NODE_TYPES35.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6780
|
+
}
|
|
6781
|
+
function referenceMutates(identifier) {
|
|
6782
|
+
let member = identifier.parent;
|
|
6783
|
+
if (member?.type !== AST_NODE_TYPES35.MemberExpression || member.object !== identifier) {
|
|
6784
|
+
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";
|
|
6785
|
+
}
|
|
6786
|
+
while (member.parent.type === AST_NODE_TYPES35.MemberExpression && member.parent.object === member) {
|
|
6787
|
+
member = member.parent;
|
|
6788
|
+
}
|
|
6789
|
+
const parent = member.parent;
|
|
6790
|
+
if (parent?.type === AST_NODE_TYPES35.AssignmentExpression && parent.left === member) {
|
|
6791
|
+
return true;
|
|
6792
|
+
}
|
|
6793
|
+
if (parent?.type === AST_NODE_TYPES35.UpdateExpression && parent.argument === member) {
|
|
6794
|
+
return true;
|
|
6795
|
+
}
|
|
6796
|
+
if (parent?.type === AST_NODE_TYPES35.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6797
|
+
return true;
|
|
6798
|
+
}
|
|
6799
|
+
return parent?.type === AST_NODE_TYPES35.CallExpression && parent.callee === member && member.property.type === AST_NODE_TYPES35.Identifier && MUTATING_METHODS.has(member.property.name);
|
|
6800
|
+
}
|
|
6801
|
+
var prefer_immutable_module_constant_default = createRule({
|
|
6802
|
+
name: "prefer-immutable-module-constant",
|
|
6803
|
+
meta: {
|
|
6804
|
+
type: "suggestion",
|
|
6805
|
+
docs: {
|
|
6806
|
+
description: "Require module-level constant collections to expose readonly state."
|
|
6807
|
+
},
|
|
6808
|
+
schema: [],
|
|
6809
|
+
messages: {
|
|
6810
|
+
preferAsConst: "Module constant `{{name}}` is a mutable literal. Add `as const` or use `Object.freeze` so consumers cannot mutate shared state.",
|
|
6811
|
+
preferReadonlyCollection: "Module constant `{{name}}` is a mutable {{kind}}. Expose it as `Readonly{{kind}}` or an immutable collection."
|
|
6812
|
+
}
|
|
6813
|
+
},
|
|
6814
|
+
defaultOptions: [],
|
|
6815
|
+
create(context) {
|
|
6816
|
+
const sourceCode = context.sourceCode;
|
|
6817
|
+
const isUnshadowedGlobal = (identifier) => {
|
|
6818
|
+
const variable = ASTUtils3.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6819
|
+
return variable === null || variable.defs.length === 0;
|
|
6820
|
+
};
|
|
6821
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
6822
|
+
return {};
|
|
6823
|
+
}
|
|
6824
|
+
return {
|
|
6825
|
+
VariableDeclarator(node) {
|
|
6826
|
+
const declaration = node.parent;
|
|
6827
|
+
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)) {
|
|
6828
|
+
return;
|
|
6829
|
+
}
|
|
6830
|
+
const container = declaration.parent;
|
|
6831
|
+
if (container.type !== AST_NODE_TYPES35.Program && !(container.type === AST_NODE_TYPES35.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES35.Program)) {
|
|
6832
|
+
return;
|
|
6833
|
+
}
|
|
6834
|
+
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init, isUnshadowedGlobal)) {
|
|
6835
|
+
return;
|
|
6836
|
+
}
|
|
6837
|
+
const kind = collectionKind(node.init, isUnshadowedGlobal);
|
|
6838
|
+
if (kind === null || declaredReadonlyType(node, kind)) {
|
|
6839
|
+
return;
|
|
6840
|
+
}
|
|
6841
|
+
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6842
|
+
if (variable?.references.some(
|
|
6843
|
+
(reference) => reference.identifier.type === AST_NODE_TYPES35.Identifier && referenceMutates(reference.identifier)
|
|
6844
|
+
) === true) {
|
|
6845
|
+
return;
|
|
6846
|
+
}
|
|
6847
|
+
context.report({
|
|
6848
|
+
node: node.id,
|
|
6849
|
+
messageId: kind === "literal" ? "preferAsConst" : "preferReadonlyCollection",
|
|
6850
|
+
data: { name: node.id.name, kind }
|
|
6851
|
+
});
|
|
6852
|
+
}
|
|
6853
|
+
};
|
|
6854
|
+
}
|
|
6855
|
+
});
|
|
6856
|
+
|
|
6711
6857
|
// src/rules/prefer-shadcn-primitives.ts
|
|
6712
|
-
import { AST_NODE_TYPES as
|
|
6858
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36 } from "@typescript-eslint/utils";
|
|
6713
6859
|
var SHADCN_PRIMITIVES = {
|
|
6714
6860
|
button: "Button",
|
|
6715
6861
|
dialog: "Dialog or AlertDialog family",
|
|
@@ -6730,15 +6876,15 @@ var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
6730
6876
|
"textarea"
|
|
6731
6877
|
]);
|
|
6732
6878
|
function rawElementName(node) {
|
|
6733
|
-
if (node.name.type !==
|
|
6879
|
+
if (node.name.type !== AST_NODE_TYPES36.JSXIdentifier) return null;
|
|
6734
6880
|
const name = node.name.name;
|
|
6735
6881
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6736
6882
|
}
|
|
6737
6883
|
function staticExpressionString(expression) {
|
|
6738
|
-
if (expression.type ===
|
|
6884
|
+
if (expression.type === AST_NODE_TYPES36.Literal) {
|
|
6739
6885
|
return typeof expression.value === "string" ? expression.value : null;
|
|
6740
6886
|
}
|
|
6741
|
-
if (expression.type ===
|
|
6887
|
+
if (expression.type === AST_NODE_TYPES36.TemplateLiteral) {
|
|
6742
6888
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6743
6889
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6744
6890
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -6748,24 +6894,24 @@ function staticExpressionString(expression) {
|
|
|
6748
6894
|
}
|
|
6749
6895
|
return value;
|
|
6750
6896
|
}
|
|
6751
|
-
if (expression.type ===
|
|
6897
|
+
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
6898
|
return staticExpressionString(expression.expression);
|
|
6753
6899
|
}
|
|
6754
6900
|
return null;
|
|
6755
6901
|
}
|
|
6756
6902
|
function staticString(value) {
|
|
6757
|
-
if (value?.type ===
|
|
6903
|
+
if (value?.type === AST_NODE_TYPES36.Literal) {
|
|
6758
6904
|
return typeof value.value === "string" ? value.value : null;
|
|
6759
6905
|
}
|
|
6760
|
-
if (value?.type !==
|
|
6906
|
+
if (value?.type !== AST_NODE_TYPES36.JSXExpressionContainer) return null;
|
|
6761
6907
|
return staticExpressionString(value.expression);
|
|
6762
6908
|
}
|
|
6763
6909
|
function effectiveAttribute(node, attributeName) {
|
|
6764
6910
|
for (const attribute of node.attributes.toReversed()) {
|
|
6765
|
-
if (attribute.type ===
|
|
6911
|
+
if (attribute.type === AST_NODE_TYPES36.JSXSpreadAttribute) {
|
|
6766
6912
|
return { kind: "unknown" };
|
|
6767
6913
|
}
|
|
6768
|
-
if (attribute.name.type !==
|
|
6914
|
+
if (attribute.name.type !== AST_NODE_TYPES36.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6769
6915
|
continue;
|
|
6770
6916
|
}
|
|
6771
6917
|
const value = staticString(attribute.value);
|
|
@@ -6774,7 +6920,7 @@ function effectiveAttribute(node, attributeName) {
|
|
|
6774
6920
|
return { kind: "missing" };
|
|
6775
6921
|
}
|
|
6776
6922
|
function isLabelableElement(node) {
|
|
6777
|
-
if (node.openingElement.name.type !==
|
|
6923
|
+
if (node.openingElement.name.type !== AST_NODE_TYPES36.JSXIdentifier) {
|
|
6778
6924
|
return false;
|
|
6779
6925
|
}
|
|
6780
6926
|
const name = node.openingElement.name.name;
|
|
@@ -6786,10 +6932,10 @@ function isLabelableElement(node) {
|
|
|
6786
6932
|
}
|
|
6787
6933
|
function containsLabelableElement(node) {
|
|
6788
6934
|
return node.children.some((child) => {
|
|
6789
|
-
if (child.type ===
|
|
6935
|
+
if (child.type === AST_NODE_TYPES36.JSXElement) {
|
|
6790
6936
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6791
6937
|
}
|
|
6792
|
-
if (child.type ===
|
|
6938
|
+
if (child.type === AST_NODE_TYPES36.JSXFragment) {
|
|
6793
6939
|
return containsLabelableElement(child);
|
|
6794
6940
|
}
|
|
6795
6941
|
return false;
|
|
@@ -6798,7 +6944,7 @@ function containsLabelableElement(node) {
|
|
|
6798
6944
|
function isStaticallyAssociatedLabel(node) {
|
|
6799
6945
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6800
6946
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6801
|
-
return node.parent.type ===
|
|
6947
|
+
return node.parent.type === AST_NODE_TYPES36.JSXElement && containsLabelableElement(node.parent);
|
|
6802
6948
|
}
|
|
6803
6949
|
function replacementFor(node, element) {
|
|
6804
6950
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -6842,7 +6988,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
6842
6988
|
});
|
|
6843
6989
|
|
|
6844
6990
|
// src/rules/prefer-module-level-constant.ts
|
|
6845
|
-
import { AST_NODE_TYPES as
|
|
6991
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37 } from "@typescript-eslint/utils";
|
|
6846
6992
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6847
6993
|
var MAX_LITERAL_DEPTH = 4;
|
|
6848
6994
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6851,7 +6997,7 @@ var IGNORE_PATTERNS2 = [
|
|
|
6851
6997
|
/\.generated\.tsx?$/,
|
|
6852
6998
|
/\.d\.ts$/
|
|
6853
6999
|
];
|
|
6854
|
-
var
|
|
7000
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
6855
7001
|
// Array
|
|
6856
7002
|
"push",
|
|
6857
7003
|
"pop",
|
|
@@ -6871,9 +7017,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6871
7017
|
"assign"
|
|
6872
7018
|
]);
|
|
6873
7019
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
7020
|
+
AST_NODE_TYPES37.FunctionDeclaration,
|
|
7021
|
+
AST_NODE_TYPES37.FunctionExpression,
|
|
7022
|
+
AST_NODE_TYPES37.ArrowFunctionExpression
|
|
6877
7023
|
]);
|
|
6878
7024
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6879
7025
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6886,14 +7032,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6886
7032
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6887
7033
|
}
|
|
6888
7034
|
function unwrap3(node) {
|
|
6889
|
-
if (node.type ===
|
|
7035
|
+
if (node.type === AST_NODE_TYPES37.TSAsExpression || node.type === AST_NODE_TYPES37.TSSatisfiesExpression || node.type === AST_NODE_TYPES37.TSNonNullExpression) {
|
|
6890
7036
|
return unwrap3(node.expression);
|
|
6891
7037
|
}
|
|
6892
7038
|
return node;
|
|
6893
7039
|
}
|
|
6894
7040
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6895
7041
|
function isRegexLiteral(node) {
|
|
6896
|
-
return node.type ===
|
|
7042
|
+
return node.type === AST_NODE_TYPES37.Literal && "regex" in node && node.regex !== void 0;
|
|
6897
7043
|
}
|
|
6898
7044
|
function isLiteralOnly(node, depth) {
|
|
6899
7045
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6901,29 +7047,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6901
7047
|
}
|
|
6902
7048
|
const inner = unwrap3(node);
|
|
6903
7049
|
switch (inner.type) {
|
|
6904
|
-
case
|
|
7050
|
+
case AST_NODE_TYPES37.Literal: {
|
|
6905
7051
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6906
7052
|
}
|
|
6907
|
-
case
|
|
7053
|
+
case AST_NODE_TYPES37.TemplateLiteral: {
|
|
6908
7054
|
return inner.expressions.length === 0;
|
|
6909
7055
|
}
|
|
6910
|
-
case
|
|
6911
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
7056
|
+
case AST_NODE_TYPES37.UnaryExpression: {
|
|
7057
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES37.Literal && typeof inner.argument.value === "number";
|
|
6912
7058
|
}
|
|
6913
|
-
case
|
|
7059
|
+
case AST_NODE_TYPES37.ArrayExpression: {
|
|
6914
7060
|
return inner.elements.every(
|
|
6915
|
-
(el) => el !== null && el.type !==
|
|
7061
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES37.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6916
7062
|
);
|
|
6917
7063
|
}
|
|
6918
|
-
case
|
|
7064
|
+
case AST_NODE_TYPES37.ObjectExpression: {
|
|
6919
7065
|
return inner.properties.every((prop) => {
|
|
6920
|
-
if (prop.type !==
|
|
7066
|
+
if (prop.type !== AST_NODE_TYPES37.Property) {
|
|
6921
7067
|
return false;
|
|
6922
7068
|
}
|
|
6923
7069
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6924
7070
|
return false;
|
|
6925
7071
|
}
|
|
6926
|
-
if (prop.computed && prop.key.type !==
|
|
7072
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES37.Literal) {
|
|
6927
7073
|
return false;
|
|
6928
7074
|
}
|
|
6929
7075
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6936,7 +7082,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6936
7082
|
}
|
|
6937
7083
|
function unwrapObjectFreeze(node) {
|
|
6938
7084
|
const inner = unwrap3(node);
|
|
6939
|
-
if (inner.type ===
|
|
7085
|
+
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
7086
|
return unwrap3(inner.arguments[0]);
|
|
6941
7087
|
}
|
|
6942
7088
|
return inner;
|
|
@@ -6952,19 +7098,19 @@ function classify(init, checkRegex) {
|
|
|
6952
7098
|
}
|
|
6953
7099
|
return { kind: "regex", size: 1 };
|
|
6954
7100
|
}
|
|
6955
|
-
if (node.type ===
|
|
7101
|
+
if (node.type === AST_NODE_TYPES37.ArrayExpression) {
|
|
6956
7102
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6957
7103
|
}
|
|
6958
|
-
if (node.type ===
|
|
7104
|
+
if (node.type === AST_NODE_TYPES37.ObjectExpression) {
|
|
6959
7105
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6960
7106
|
}
|
|
6961
|
-
if (node.type ===
|
|
7107
|
+
if (node.type === AST_NODE_TYPES37.NewExpression && node.callee.type === AST_NODE_TYPES37.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6962
7108
|
const arg = node.arguments[0];
|
|
6963
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
7109
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES37.SpreadElement) {
|
|
6964
7110
|
return null;
|
|
6965
7111
|
}
|
|
6966
7112
|
const entries = unwrap3(arg);
|
|
6967
|
-
if (entries.type !==
|
|
7113
|
+
if (entries.type !== AST_NODE_TYPES37.ArrayExpression) {
|
|
6968
7114
|
return null;
|
|
6969
7115
|
}
|
|
6970
7116
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6993,10 +7139,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6993
7139
|
);
|
|
6994
7140
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6995
7141
|
const callee = node.callee;
|
|
6996
|
-
if (callee.type ===
|
|
7142
|
+
if (callee.type === AST_NODE_TYPES37.Identifier && callee.name === "structuredClone") {
|
|
6997
7143
|
return true;
|
|
6998
7144
|
}
|
|
6999
|
-
if (callee.type !==
|
|
7145
|
+
if (callee.type !== AST_NODE_TYPES37.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES37.Identifier || callee.property.type !== AST_NODE_TYPES37.Identifier) {
|
|
7000
7146
|
return false;
|
|
7001
7147
|
}
|
|
7002
7148
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -7010,38 +7156,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
7010
7156
|
}
|
|
7011
7157
|
function isSafeRead(identifier) {
|
|
7012
7158
|
const parent = identifier.parent;
|
|
7013
|
-
if (parent.type ===
|
|
7159
|
+
if (parent.type === AST_NODE_TYPES37.MemberExpression) {
|
|
7014
7160
|
if (parent.object !== identifier) {
|
|
7015
7161
|
return true;
|
|
7016
7162
|
}
|
|
7017
7163
|
const grandparent = parent.parent;
|
|
7018
|
-
if (grandparent.type ===
|
|
7164
|
+
if (grandparent.type === AST_NODE_TYPES37.AssignmentExpression && grandparent.left === parent) {
|
|
7019
7165
|
return false;
|
|
7020
7166
|
}
|
|
7021
|
-
if (grandparent.type ===
|
|
7167
|
+
if (grandparent.type === AST_NODE_TYPES37.UpdateExpression) {
|
|
7022
7168
|
return false;
|
|
7023
7169
|
}
|
|
7024
|
-
if (grandparent.type ===
|
|
7170
|
+
if (grandparent.type === AST_NODE_TYPES37.UnaryExpression && grandparent.operator === "delete") {
|
|
7025
7171
|
return false;
|
|
7026
7172
|
}
|
|
7027
|
-
if (!parent.computed && parent.property.type ===
|
|
7173
|
+
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
7174
|
return false;
|
|
7029
7175
|
}
|
|
7030
7176
|
return true;
|
|
7031
7177
|
}
|
|
7032
|
-
if (parent.type ===
|
|
7178
|
+
if (parent.type === AST_NODE_TYPES37.ForOfStatement && parent.right === identifier) {
|
|
7033
7179
|
return true;
|
|
7034
7180
|
}
|
|
7035
|
-
if (parent.type ===
|
|
7181
|
+
if (parent.type === AST_NODE_TYPES37.SpreadElement) {
|
|
7036
7182
|
return true;
|
|
7037
7183
|
}
|
|
7038
|
-
if (parent.type ===
|
|
7184
|
+
if (parent.type === AST_NODE_TYPES37.BinaryExpression) {
|
|
7039
7185
|
return true;
|
|
7040
7186
|
}
|
|
7041
|
-
if (parent.type ===
|
|
7187
|
+
if (parent.type === AST_NODE_TYPES37.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
7042
7188
|
return true;
|
|
7043
7189
|
}
|
|
7044
|
-
if (parent.type ===
|
|
7190
|
+
if (parent.type === AST_NODE_TYPES37.UnaryExpression && parent.operator !== "delete") {
|
|
7045
7191
|
return true;
|
|
7046
7192
|
}
|
|
7047
7193
|
return false;
|
|
@@ -7065,7 +7211,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7065
7211
|
}
|
|
7066
7212
|
],
|
|
7067
7213
|
messages: {
|
|
7068
|
-
hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope so it is allocated once
|
|
7214
|
+
hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope in immutable form (`as const`, a readonly collection, or `Object.freeze`) so it is allocated once without exposing mutable shared state.",
|
|
7069
7215
|
hoistRegex: "`{{name}}` is a constant regex recompiled on every call. Hoist it to module scope."
|
|
7070
7216
|
}
|
|
7071
7217
|
},
|
|
@@ -7096,7 +7242,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7096
7242
|
if (reference.isWrite()) {
|
|
7097
7243
|
return false;
|
|
7098
7244
|
}
|
|
7099
|
-
if (reference.identifier.type !==
|
|
7245
|
+
if (reference.identifier.type !== AST_NODE_TYPES37.Identifier) {
|
|
7100
7246
|
return false;
|
|
7101
7247
|
}
|
|
7102
7248
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7108,10 +7254,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7108
7254
|
return {
|
|
7109
7255
|
VariableDeclarator(node) {
|
|
7110
7256
|
const declaration = node.parent;
|
|
7111
|
-
if (declaration.type !==
|
|
7257
|
+
if (declaration.type !== AST_NODE_TYPES37.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7112
7258
|
return;
|
|
7113
7259
|
}
|
|
7114
|
-
if (node.id.type !==
|
|
7260
|
+
if (node.id.type !== AST_NODE_TYPES37.Identifier || node.init === null) {
|
|
7115
7261
|
return;
|
|
7116
7262
|
}
|
|
7117
7263
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7138,7 +7284,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7138
7284
|
});
|
|
7139
7285
|
|
|
7140
7286
|
// src/rules/prefer-module-level-schema.ts
|
|
7141
|
-
import { AST_NODE_TYPES as
|
|
7287
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
7142
7288
|
|
|
7143
7289
|
// src/rules/_zod.ts
|
|
7144
7290
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7204,9 +7350,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7204
7350
|
"intl"
|
|
7205
7351
|
]);
|
|
7206
7352
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7353
|
+
AST_NODE_TYPES38.ArrowFunctionExpression,
|
|
7354
|
+
AST_NODE_TYPES38.FunctionDeclaration,
|
|
7355
|
+
AST_NODE_TYPES38.FunctionExpression
|
|
7210
7356
|
]);
|
|
7211
7357
|
function schemaExpression(node) {
|
|
7212
7358
|
let current = node;
|
|
@@ -7215,10 +7361,10 @@ function schemaExpression(node) {
|
|
|
7215
7361
|
if (parent === void 0) {
|
|
7216
7362
|
return current;
|
|
7217
7363
|
}
|
|
7218
|
-
if (parent.type ===
|
|
7364
|
+
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
7365
|
return current;
|
|
7220
7366
|
}
|
|
7221
|
-
if (parent.type ===
|
|
7367
|
+
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
7368
|
current = parent;
|
|
7223
7369
|
continue;
|
|
7224
7370
|
}
|
|
@@ -7269,22 +7415,22 @@ function subtreeSome(root, predicate) {
|
|
|
7269
7415
|
function readsReceiver(node) {
|
|
7270
7416
|
return subtreeSome(
|
|
7271
7417
|
node,
|
|
7272
|
-
(inner) => inner.type ===
|
|
7418
|
+
(inner) => inner.type === AST_NODE_TYPES38.ThisExpression || inner.type === AST_NODE_TYPES38.Super || inner.type === AST_NODE_TYPES38.Identifier && inner.name === "arguments"
|
|
7273
7419
|
);
|
|
7274
7420
|
}
|
|
7275
7421
|
function buildsLocalizedText(node) {
|
|
7276
7422
|
return subtreeSome(node, (inner) => {
|
|
7277
|
-
if (inner.type ===
|
|
7423
|
+
if (inner.type === AST_NODE_TYPES38.TaggedTemplateExpression) {
|
|
7278
7424
|
return true;
|
|
7279
7425
|
}
|
|
7280
|
-
if (inner.type !==
|
|
7426
|
+
if (inner.type !== AST_NODE_TYPES38.CallExpression) {
|
|
7281
7427
|
return false;
|
|
7282
7428
|
}
|
|
7283
7429
|
const { callee } = inner;
|
|
7284
|
-
if (callee.type ===
|
|
7430
|
+
if (callee.type === AST_NODE_TYPES38.Identifier) {
|
|
7285
7431
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7286
7432
|
}
|
|
7287
|
-
return callee.type ===
|
|
7433
|
+
return callee.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES38.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7288
7434
|
});
|
|
7289
7435
|
}
|
|
7290
7436
|
function collectReferences(scope, out) {
|
|
@@ -7341,15 +7487,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7341
7487
|
}
|
|
7342
7488
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7343
7489
|
function isZodCall(node) {
|
|
7344
|
-
return node.type ===
|
|
7490
|
+
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
7491
|
}
|
|
7346
7492
|
function isCovered(node) {
|
|
7347
7493
|
let current = node.parent ?? void 0;
|
|
7348
7494
|
while (current !== void 0) {
|
|
7349
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7495
|
+
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
7496
|
return true;
|
|
7351
7497
|
}
|
|
7352
|
-
if (current.type ===
|
|
7498
|
+
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
7499
|
return true;
|
|
7354
7500
|
}
|
|
7355
7501
|
current = current.parent ?? void 0;
|
|
@@ -7364,11 +7510,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7364
7510
|
if (parent === void 0) {
|
|
7365
7511
|
return confirmed;
|
|
7366
7512
|
}
|
|
7367
|
-
if (parent.type ===
|
|
7513
|
+
if (parent.type === AST_NODE_TYPES38.Property && parent.value === current || parent.type === AST_NODE_TYPES38.ObjectExpression || parent.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
7368
7514
|
current = parent;
|
|
7369
7515
|
continue;
|
|
7370
7516
|
}
|
|
7371
|
-
if (parent.type ===
|
|
7517
|
+
if (parent.type === AST_NODE_TYPES38.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7372
7518
|
current = schemaExpression(parent);
|
|
7373
7519
|
confirmed = current;
|
|
7374
7520
|
continue;
|
|
@@ -7378,7 +7524,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7378
7524
|
}
|
|
7379
7525
|
function isSchemaComposition(node) {
|
|
7380
7526
|
const { callee } = node;
|
|
7381
|
-
const isCombinator = callee.type ===
|
|
7527
|
+
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
7528
|
return isCombinator || isZodCall(node);
|
|
7383
7529
|
}
|
|
7384
7530
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7412,13 +7558,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7412
7558
|
}
|
|
7413
7559
|
function ownerName(enclosing) {
|
|
7414
7560
|
const parent = enclosing.parent ?? void 0;
|
|
7415
|
-
if (enclosing.type ===
|
|
7561
|
+
if (enclosing.type === AST_NODE_TYPES38.FunctionDeclaration && enclosing.id !== null) {
|
|
7416
7562
|
return enclosing.id.name;
|
|
7417
7563
|
}
|
|
7418
|
-
if (parent !== void 0 && parent.type ===
|
|
7564
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES38.VariableDeclarator && parent.id.type === AST_NODE_TYPES38.Identifier) {
|
|
7419
7565
|
return parent.id.name;
|
|
7420
7566
|
}
|
|
7421
|
-
if (parent !== void 0 && (parent.type ===
|
|
7567
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES38.MethodDefinition || parent.type === AST_NODE_TYPES38.Property) && parent.key.type === AST_NODE_TYPES38.Identifier) {
|
|
7422
7568
|
return parent.key.name;
|
|
7423
7569
|
}
|
|
7424
7570
|
return "this function";
|
|
@@ -7429,7 +7575,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7429
7575
|
return;
|
|
7430
7576
|
}
|
|
7431
7577
|
for (const specifier of node.specifiers) {
|
|
7432
|
-
if (specifier.type ===
|
|
7578
|
+
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
7579
|
zodNamespaces.add(specifier.local.name);
|
|
7434
7580
|
}
|
|
7435
7581
|
}
|
|
@@ -7439,7 +7585,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7439
7585
|
return;
|
|
7440
7586
|
}
|
|
7441
7587
|
const callee = node.callee;
|
|
7442
|
-
if (callee.property.type !==
|
|
7588
|
+
if (callee.property.type !== AST_NODE_TYPES38.Identifier) {
|
|
7443
7589
|
return;
|
|
7444
7590
|
}
|
|
7445
7591
|
const factory = callee.property.name;
|
|
@@ -7454,7 +7600,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7454
7600
|
return;
|
|
7455
7601
|
}
|
|
7456
7602
|
const shape = node.arguments[0];
|
|
7457
|
-
if (shape !== void 0 && shape.type ===
|
|
7603
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES38.ObjectExpression && shape.properties.length < minProperties) {
|
|
7458
7604
|
return;
|
|
7459
7605
|
}
|
|
7460
7606
|
const expression = schemaExpression(node);
|
|
@@ -7482,9 +7628,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7482
7628
|
});
|
|
7483
7629
|
|
|
7484
7630
|
// src/rules/prefer-native-random-uuid.ts
|
|
7485
|
-
import { AST_NODE_TYPES as
|
|
7631
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
7486
7632
|
function requireUuid(node) {
|
|
7487
|
-
return node?.type ===
|
|
7633
|
+
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
7634
|
}
|
|
7489
7635
|
var prefer_native_random_uuid_default = createRule({
|
|
7490
7636
|
name: "prefer-native-random-uuid",
|
|
@@ -7505,7 +7651,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7505
7651
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7506
7652
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7507
7653
|
function resolve(identifier) {
|
|
7508
|
-
return
|
|
7654
|
+
return ASTUtils4.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7509
7655
|
}
|
|
7510
7656
|
function record(identifier, destination) {
|
|
7511
7657
|
const variable = resolve(identifier);
|
|
@@ -7527,37 +7673,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7527
7673
|
ImportDeclaration(node) {
|
|
7528
7674
|
if (node.source.value !== "uuid") return;
|
|
7529
7675
|
for (const specifier of node.specifiers) {
|
|
7530
|
-
if (specifier.type ===
|
|
7676
|
+
if (specifier.type === AST_NODE_TYPES39.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES39.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7531
7677
|
record(specifier.local, directBindings);
|
|
7532
|
-
} else if (specifier.type ===
|
|
7678
|
+
} else if (specifier.type === AST_NODE_TYPES39.ImportNamespaceSpecifier) {
|
|
7533
7679
|
record(specifier.local, namespaceBindings);
|
|
7534
7680
|
}
|
|
7535
7681
|
}
|
|
7536
7682
|
},
|
|
7537
7683
|
VariableDeclarator(node) {
|
|
7538
7684
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7539
|
-
if (node.init?.type !==
|
|
7685
|
+
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
7686
|
return;
|
|
7541
7687
|
}
|
|
7542
|
-
if (node.id.type ===
|
|
7688
|
+
if (node.id.type === AST_NODE_TYPES39.Identifier) {
|
|
7543
7689
|
record(node.id, namespaceBindings);
|
|
7544
7690
|
return;
|
|
7545
7691
|
}
|
|
7546
|
-
if (node.id.type !==
|
|
7692
|
+
if (node.id.type !== AST_NODE_TYPES39.ObjectPattern) return;
|
|
7547
7693
|
for (const property of node.id.properties) {
|
|
7548
|
-
if (property.type ===
|
|
7694
|
+
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
7695
|
record(property.value, directBindings);
|
|
7550
7696
|
}
|
|
7551
7697
|
}
|
|
7552
7698
|
},
|
|
7553
7699
|
"CallExpression:exit"(node) {
|
|
7554
7700
|
if (node.arguments.length !== 0) return;
|
|
7555
|
-
if (node.callee.type ===
|
|
7701
|
+
if (node.callee.type === AST_NODE_TYPES39.Identifier) {
|
|
7556
7702
|
const variable2 = resolve(node.callee);
|
|
7557
7703
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7558
7704
|
return;
|
|
7559
7705
|
}
|
|
7560
|
-
if (node.callee.type !==
|
|
7706
|
+
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
7707
|
return;
|
|
7562
7708
|
}
|
|
7563
7709
|
const variable = resolve(node.callee.object);
|
|
@@ -7568,20 +7714,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7568
7714
|
});
|
|
7569
7715
|
|
|
7570
7716
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7571
|
-
import { AST_NODE_TYPES as
|
|
7717
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
7572
7718
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7573
7719
|
function propertyName(node) {
|
|
7574
7720
|
const key = node.key;
|
|
7575
|
-
if (key.type ===
|
|
7576
|
-
if (key.type ===
|
|
7721
|
+
if (key.type === AST_NODE_TYPES40.Identifier) return key.name;
|
|
7722
|
+
if (key.type === AST_NODE_TYPES40.Literal) return String(key.value);
|
|
7577
7723
|
return "collection";
|
|
7578
7724
|
}
|
|
7579
7725
|
function isArrayType(node) {
|
|
7580
|
-
if (node.type ===
|
|
7581
|
-
return node.type ===
|
|
7726
|
+
if (node.type === AST_NODE_TYPES40.TSArrayType) return true;
|
|
7727
|
+
return node.type === AST_NODE_TYPES40.TSTypeReference && node.typeName.type === AST_NODE_TYPES40.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7582
7728
|
}
|
|
7583
7729
|
function isNullishType(node) {
|
|
7584
|
-
return node.type ===
|
|
7730
|
+
return node.type === AST_NODE_TYPES40.TSNullKeyword || node.type === AST_NODE_TYPES40.TSUndefinedKeyword;
|
|
7585
7731
|
}
|
|
7586
7732
|
function isNullableArrayOnly(node) {
|
|
7587
7733
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7609,7 +7755,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7609
7755
|
if (node.optional) return;
|
|
7610
7756
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7611
7757
|
if (annotation === void 0) return;
|
|
7612
|
-
if (annotation.type !==
|
|
7758
|
+
if (annotation.type !== AST_NODE_TYPES40.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7613
7759
|
return;
|
|
7614
7760
|
}
|
|
7615
7761
|
context.report({
|
|
@@ -7622,7 +7768,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7622
7768
|
TSPropertySignature: checkOptionalProperty,
|
|
7623
7769
|
PropertyDefinition: checkOptionalProperty,
|
|
7624
7770
|
TSTypeAliasDeclaration(node) {
|
|
7625
|
-
if (node.typeAnnotation.type !==
|
|
7771
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES40.TSUnionType) return;
|
|
7626
7772
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7627
7773
|
context.report({
|
|
7628
7774
|
node,
|
|
@@ -7635,13 +7781,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7635
7781
|
});
|
|
7636
7782
|
|
|
7637
7783
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7638
|
-
import { AST_NODE_TYPES as
|
|
7784
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
7639
7785
|
var unwrap4 = (node) => {
|
|
7640
7786
|
let current = node;
|
|
7641
7787
|
while (current !== null && current !== void 0) {
|
|
7642
|
-
if (current.type ===
|
|
7788
|
+
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
7789
|
current = current.expression;
|
|
7644
|
-
} else if (current.type ===
|
|
7790
|
+
} else if (current.type === AST_NODE_TYPES41.ChainExpression) {
|
|
7645
7791
|
current = current.expression;
|
|
7646
7792
|
} else {
|
|
7647
7793
|
break;
|
|
@@ -7656,23 +7802,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7656
7802
|
]);
|
|
7657
7803
|
var isSchemaParseReference = (node) => {
|
|
7658
7804
|
const inner = unwrap4(node);
|
|
7659
|
-
return inner !== null && inner.type ===
|
|
7805
|
+
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
7806
|
};
|
|
7661
7807
|
var isRawPayloadSource = (node) => {
|
|
7662
7808
|
let current = unwrap4(node);
|
|
7663
7809
|
if (current === null) return false;
|
|
7664
|
-
if (current.type ===
|
|
7810
|
+
if (current.type === AST_NODE_TYPES41.AwaitExpression) {
|
|
7665
7811
|
current = unwrap4(current.argument);
|
|
7666
7812
|
}
|
|
7667
|
-
if (current === null || current.type !==
|
|
7813
|
+
if (current === null || current.type !== AST_NODE_TYPES41.CallExpression) {
|
|
7668
7814
|
return false;
|
|
7669
7815
|
}
|
|
7670
7816
|
const callee = unwrap4(current.callee);
|
|
7671
|
-
if (callee === null || callee.type !==
|
|
7817
|
+
if (callee === null || callee.type !== AST_NODE_TYPES41.MemberExpression) {
|
|
7672
7818
|
return false;
|
|
7673
7819
|
}
|
|
7674
7820
|
const property = unwrap4(callee.property);
|
|
7675
|
-
if (property === null || property.type !==
|
|
7821
|
+
if (property === null || property.type !== AST_NODE_TYPES41.Identifier) {
|
|
7676
7822
|
return false;
|
|
7677
7823
|
}
|
|
7678
7824
|
if (property.name === "json") {
|
|
@@ -7682,16 +7828,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7682
7828
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7683
7829
|
}
|
|
7684
7830
|
const object = unwrap4(callee.object);
|
|
7685
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7831
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES41.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7686
7832
|
};
|
|
7687
7833
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7688
7834
|
var isLocalFileRead = (node) => {
|
|
7689
7835
|
let found = false;
|
|
7690
7836
|
const visit = (current) => {
|
|
7691
7837
|
if (found || current === null || current === void 0) return;
|
|
7692
|
-
if (current.type ===
|
|
7838
|
+
if (current.type === AST_NODE_TYPES41.CallExpression) {
|
|
7693
7839
|
const callee = unwrap4(current.callee);
|
|
7694
|
-
const name = callee?.type ===
|
|
7840
|
+
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
7841
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7696
7842
|
found = true;
|
|
7697
7843
|
return;
|
|
@@ -7713,15 +7859,15 @@ var isLocalFileRead = (node) => {
|
|
|
7713
7859
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7714
7860
|
var isInsideAssertion = (node) => {
|
|
7715
7861
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7716
|
-
if (current.type !==
|
|
7862
|
+
if (current.type !== AST_NODE_TYPES41.CallExpression) continue;
|
|
7717
7863
|
let callee = current.callee;
|
|
7718
|
-
while (callee.type ===
|
|
7864
|
+
while (callee.type === AST_NODE_TYPES41.MemberExpression) {
|
|
7719
7865
|
callee = callee.object;
|
|
7720
7866
|
}
|
|
7721
|
-
if (callee.type ===
|
|
7867
|
+
if (callee.type === AST_NODE_TYPES41.CallExpression) {
|
|
7722
7868
|
callee = callee.callee;
|
|
7723
7869
|
}
|
|
7724
|
-
if (callee.type ===
|
|
7870
|
+
if (callee.type === AST_NODE_TYPES41.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7725
7871
|
return true;
|
|
7726
7872
|
}
|
|
7727
7873
|
}
|
|
@@ -7740,39 +7886,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7740
7886
|
var isValidationRead = (node) => {
|
|
7741
7887
|
let current = node;
|
|
7742
7888
|
let parent = current.parent;
|
|
7743
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7889
|
+
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
7890
|
current = parent;
|
|
7745
7891
|
parent = parent.parent;
|
|
7746
7892
|
}
|
|
7747
7893
|
if (parent === null || parent === void 0) return false;
|
|
7748
|
-
if (parent.type ===
|
|
7894
|
+
if (parent.type === AST_NODE_TYPES41.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7749
7895
|
return true;
|
|
7750
7896
|
}
|
|
7751
|
-
if (parent.type !==
|
|
7897
|
+
if (parent.type !== AST_NODE_TYPES41.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7752
7898
|
return false;
|
|
7753
7899
|
}
|
|
7754
7900
|
const callee = parent.callee;
|
|
7755
|
-
if (callee.type ===
|
|
7901
|
+
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
7902
|
return parent.arguments.length === 1;
|
|
7757
7903
|
}
|
|
7758
|
-
return callee.type ===
|
|
7904
|
+
return callee.type === AST_NODE_TYPES41.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7759
7905
|
};
|
|
7760
7906
|
var isGuardTestPosition = (node) => {
|
|
7761
7907
|
let current = node;
|
|
7762
7908
|
let parent = current.parent;
|
|
7763
7909
|
while (parent !== void 0 && parent !== null) {
|
|
7764
7910
|
switch (parent.type) {
|
|
7765
|
-
case
|
|
7766
|
-
case
|
|
7767
|
-
case
|
|
7911
|
+
case AST_NODE_TYPES41.UnaryExpression:
|
|
7912
|
+
case AST_NODE_TYPES41.LogicalExpression:
|
|
7913
|
+
case AST_NODE_TYPES41.ChainExpression:
|
|
7768
7914
|
current = parent;
|
|
7769
7915
|
parent = parent.parent;
|
|
7770
7916
|
continue;
|
|
7771
|
-
case
|
|
7772
|
-
case
|
|
7773
|
-
case
|
|
7774
|
-
case
|
|
7775
|
-
case
|
|
7917
|
+
case AST_NODE_TYPES41.IfStatement:
|
|
7918
|
+
case AST_NODE_TYPES41.ConditionalExpression:
|
|
7919
|
+
case AST_NODE_TYPES41.WhileStatement:
|
|
7920
|
+
case AST_NODE_TYPES41.DoWhileStatement:
|
|
7921
|
+
case AST_NODE_TYPES41.ForStatement:
|
|
7776
7922
|
return parent.test === current;
|
|
7777
7923
|
default:
|
|
7778
7924
|
return false;
|
|
@@ -7782,7 +7928,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7782
7928
|
};
|
|
7783
7929
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7784
7930
|
const unwrapped = unwrap4(node);
|
|
7785
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7931
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES41.Identifier) {
|
|
7786
7932
|
return false;
|
|
7787
7933
|
}
|
|
7788
7934
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7825,11 +7971,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7825
7971
|
return {
|
|
7826
7972
|
VariableDeclarator(node) {
|
|
7827
7973
|
const scope = context.sourceCode.getScope(node);
|
|
7828
|
-
if (node.id.type ===
|
|
7974
|
+
if (node.id.type === AST_NODE_TYPES41.Identifier) {
|
|
7829
7975
|
trackInitializer(node);
|
|
7830
7976
|
return;
|
|
7831
7977
|
}
|
|
7832
|
-
if (node.id.type ===
|
|
7978
|
+
if (node.id.type === AST_NODE_TYPES41.ObjectPattern || node.id.type === AST_NODE_TYPES41.ArrayPattern) {
|
|
7833
7979
|
if (isRawPayloadSource(node.init)) {
|
|
7834
7980
|
if (!isFullyNarrowedPattern(node)) {
|
|
7835
7981
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7843,7 +7989,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7843
7989
|
},
|
|
7844
7990
|
AssignmentExpression(node) {
|
|
7845
7991
|
const scope = context.sourceCode.getScope(node);
|
|
7846
|
-
if (node.left.type ===
|
|
7992
|
+
if (node.left.type === AST_NODE_TYPES41.Identifier) {
|
|
7847
7993
|
const variable = findVariable2(scope, node.left.name);
|
|
7848
7994
|
if (variable === null) return;
|
|
7849
7995
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7853,7 +7999,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7853
7999
|
}
|
|
7854
8000
|
return;
|
|
7855
8001
|
}
|
|
7856
|
-
if (node.left.type ===
|
|
8002
|
+
if (node.left.type === AST_NODE_TYPES41.ObjectPattern || node.left.type === AST_NODE_TYPES41.ArrayPattern) {
|
|
7857
8003
|
if (isRawPayloadSource(node.right)) {
|
|
7858
8004
|
context.report({
|
|
7859
8005
|
node: node.left,
|
|
@@ -7870,15 +8016,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7870
8016
|
}
|
|
7871
8017
|
},
|
|
7872
8018
|
CallExpression(node) {
|
|
7873
|
-
if (node.callee.type !==
|
|
8019
|
+
if (node.callee.type !== AST_NODE_TYPES41.Identifier) return;
|
|
7874
8020
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7875
8021
|
return;
|
|
7876
8022
|
}
|
|
7877
8023
|
const scope = context.sourceCode.getScope(node);
|
|
7878
8024
|
for (const arg of node.arguments) {
|
|
7879
|
-
if (arg.type ===
|
|
8025
|
+
if (arg.type === AST_NODE_TYPES41.SpreadElement) continue;
|
|
7880
8026
|
const unwrapped = unwrap4(arg);
|
|
7881
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8027
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES41.Identifier) {
|
|
7882
8028
|
continue;
|
|
7883
8029
|
}
|
|
7884
8030
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7892,13 +8038,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7892
8038
|
const obj = unwrap4(node.object);
|
|
7893
8039
|
if (isRawPayloadSource(obj)) {
|
|
7894
8040
|
const parent = node.parent;
|
|
7895
|
-
if (parent.type ===
|
|
8041
|
+
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
8042
|
return;
|
|
7897
8043
|
}
|
|
7898
8044
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7899
8045
|
return;
|
|
7900
8046
|
}
|
|
7901
|
-
if (obj !== null && obj.type ===
|
|
8047
|
+
if (obj !== null && obj.type === AST_NODE_TYPES41.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7902
8048
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7903
8049
|
const variable = findVariable2(scope, obj.name);
|
|
7904
8050
|
if (variable !== null) {
|
|
@@ -7911,7 +8057,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7911
8057
|
});
|
|
7912
8058
|
|
|
7913
8059
|
// src/rules/prefer-semantic-colors.ts
|
|
7914
|
-
import { AST_NODE_TYPES as
|
|
8060
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
7915
8061
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
7916
8062
|
import { dirname, join, parse } from "path";
|
|
7917
8063
|
|
|
@@ -8011,8 +8157,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
8011
8157
|
]);
|
|
8012
8158
|
function jsxElementName(node) {
|
|
8013
8159
|
const name = node.openingElement.name;
|
|
8014
|
-
if (name.type ===
|
|
8015
|
-
if (name.type ===
|
|
8160
|
+
if (name.type === AST_NODE_TYPES42.JSXIdentifier) return name.name;
|
|
8161
|
+
if (name.type === AST_NODE_TYPES42.JSXMemberExpression && name.property.type === AST_NODE_TYPES42.JSXIdentifier) {
|
|
8016
8162
|
return name.property.name;
|
|
8017
8163
|
}
|
|
8018
8164
|
return null;
|
|
@@ -8038,7 +8184,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
8038
8184
|
var isInsideSvg = (node) => {
|
|
8039
8185
|
let current = node.parent;
|
|
8040
8186
|
while (current !== void 0 && current !== null) {
|
|
8041
|
-
if (current.type ===
|
|
8187
|
+
if (current.type === AST_NODE_TYPES42.JSXElement) {
|
|
8042
8188
|
const name = jsxElementName(current);
|
|
8043
8189
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
8044
8190
|
}
|
|
@@ -8049,7 +8195,7 @@ var isInsideSvg = (node) => {
|
|
|
8049
8195
|
var isInsideIconFactoryPath = (node) => {
|
|
8050
8196
|
let current = node.parent;
|
|
8051
8197
|
while (current !== void 0 && current !== null) {
|
|
8052
|
-
if (current.type ===
|
|
8198
|
+
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
8199
|
return true;
|
|
8054
8200
|
}
|
|
8055
8201
|
current = current.parent;
|
|
@@ -8186,12 +8332,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8186
8332
|
return root !== null && workspaceHasMarker(root);
|
|
8187
8333
|
};
|
|
8188
8334
|
var propName = (key) => {
|
|
8189
|
-
if (key.type ===
|
|
8190
|
-
if (key.type ===
|
|
8335
|
+
if (key.type === AST_NODE_TYPES42.Identifier) return key.name;
|
|
8336
|
+
if (key.type === AST_NODE_TYPES42.Literal && typeof key.value === "string") return key.value;
|
|
8191
8337
|
return null;
|
|
8192
8338
|
};
|
|
8193
8339
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8194
|
-
if (statement.type !==
|
|
8340
|
+
if (statement.type !== AST_NODE_TYPES42.ImportDeclaration && statement.type !== AST_NODE_TYPES42.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES42.ExportAllDeclaration) {
|
|
8195
8341
|
return false;
|
|
8196
8342
|
}
|
|
8197
8343
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8243,27 +8389,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8243
8389
|
const checkClassNode = (node) => {
|
|
8244
8390
|
if (node === null) return;
|
|
8245
8391
|
switch (node.type) {
|
|
8246
|
-
case
|
|
8392
|
+
case AST_NODE_TYPES42.Literal:
|
|
8247
8393
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8248
8394
|
break;
|
|
8249
|
-
case
|
|
8395
|
+
case AST_NODE_TYPES42.TemplateLiteral:
|
|
8250
8396
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8251
8397
|
break;
|
|
8252
|
-
case
|
|
8398
|
+
case AST_NODE_TYPES42.ArrayExpression:
|
|
8253
8399
|
for (const element of node.elements) {
|
|
8254
|
-
if (element !== null && element.type !==
|
|
8400
|
+
if (element !== null && element.type !== AST_NODE_TYPES42.SpreadElement) checkClassNode(element);
|
|
8255
8401
|
}
|
|
8256
8402
|
break;
|
|
8257
|
-
case
|
|
8403
|
+
case AST_NODE_TYPES42.ObjectExpression:
|
|
8258
8404
|
for (const property of node.properties) {
|
|
8259
|
-
if (property.type ===
|
|
8405
|
+
if (property.type === AST_NODE_TYPES42.Property) checkClassNode(property.value);
|
|
8260
8406
|
}
|
|
8261
8407
|
break;
|
|
8262
|
-
case
|
|
8408
|
+
case AST_NODE_TYPES42.ConditionalExpression:
|
|
8263
8409
|
checkClassNode(node.consequent);
|
|
8264
8410
|
checkClassNode(node.alternate);
|
|
8265
8411
|
break;
|
|
8266
|
-
case
|
|
8412
|
+
case AST_NODE_TYPES42.LogicalExpression:
|
|
8267
8413
|
checkClassNode(node.right);
|
|
8268
8414
|
break;
|
|
8269
8415
|
default:
|
|
@@ -8271,32 +8417,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8271
8417
|
}
|
|
8272
8418
|
};
|
|
8273
8419
|
const checkColorValueNode = (node) => {
|
|
8274
|
-
if (node.type ===
|
|
8420
|
+
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
8421
|
report(node, "inlineColor", { value: node.value });
|
|
8276
8422
|
}
|
|
8277
8423
|
};
|
|
8278
8424
|
return {
|
|
8279
8425
|
"JSXAttribute[name.name='className']"(node) {
|
|
8280
8426
|
if (node.value === null) return;
|
|
8281
|
-
if (node.value.type ===
|
|
8282
|
-
else if (node.value.type ===
|
|
8283
|
-
if (node.value.expression.type !==
|
|
8427
|
+
if (node.value.type === AST_NODE_TYPES42.Literal) checkClassNode(node.value);
|
|
8428
|
+
else if (node.value.type === AST_NODE_TYPES42.JSXExpressionContainer) {
|
|
8429
|
+
if (node.value.expression.type !== AST_NODE_TYPES42.JSXEmptyExpression) {
|
|
8284
8430
|
checkClassNode(node.value.expression);
|
|
8285
8431
|
}
|
|
8286
8432
|
}
|
|
8287
8433
|
},
|
|
8288
8434
|
CallExpression(node) {
|
|
8289
|
-
if (node.callee.type ===
|
|
8435
|
+
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
8436
|
importsEmailOrPdfRenderer = true;
|
|
8291
8437
|
}
|
|
8292
|
-
if (node.callee.type ===
|
|
8438
|
+
if (node.callee.type === AST_NODE_TYPES42.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8293
8439
|
for (const arg of node.arguments) {
|
|
8294
|
-
if (arg.type !==
|
|
8440
|
+
if (arg.type !== AST_NODE_TYPES42.SpreadElement) checkClassNode(arg);
|
|
8295
8441
|
}
|
|
8296
8442
|
}
|
|
8297
8443
|
},
|
|
8298
8444
|
VariableDeclarator(node) {
|
|
8299
|
-
if (node.id.type ===
|
|
8445
|
+
if (node.id.type === AST_NODE_TYPES42.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8300
8446
|
checkClassNode(node.init);
|
|
8301
8447
|
}
|
|
8302
8448
|
},
|
|
@@ -8306,9 +8452,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8306
8452
|
},
|
|
8307
8453
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8308
8454
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8309
|
-
if (node.value?.type !==
|
|
8455
|
+
if (node.value?.type !== AST_NODE_TYPES42.Literal) return;
|
|
8310
8456
|
const owner = node.parent.name;
|
|
8311
|
-
if (owner.type ===
|
|
8457
|
+
if (owner.type === AST_NODE_TYPES42.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8312
8458
|
return;
|
|
8313
8459
|
}
|
|
8314
8460
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8322,7 +8468,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8322
8468
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8323
8469
|
},
|
|
8324
8470
|
ImportExpression(node) {
|
|
8325
|
-
if (node.source.type ===
|
|
8471
|
+
if (node.source.type === AST_NODE_TYPES42.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8326
8472
|
importsEmailOrPdfRenderer = true;
|
|
8327
8473
|
}
|
|
8328
8474
|
},
|
|
@@ -8528,7 +8674,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8528
8674
|
// src/rules/prefer-string-literal-union.ts
|
|
8529
8675
|
import {
|
|
8530
8676
|
ESLintUtils as ESLintUtils3,
|
|
8531
|
-
AST_NODE_TYPES as
|
|
8677
|
+
AST_NODE_TYPES as AST_NODE_TYPES43
|
|
8532
8678
|
} from "@typescript-eslint/utils";
|
|
8533
8679
|
import * as ts2 from "typescript";
|
|
8534
8680
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8572,19 +8718,19 @@ function isChoiceLikeName(name) {
|
|
|
8572
8718
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8573
8719
|
}
|
|
8574
8720
|
function keyName(key) {
|
|
8575
|
-
if (key.type ===
|
|
8721
|
+
if (key.type === AST_NODE_TYPES43.Identifier) {
|
|
8576
8722
|
return key.name;
|
|
8577
8723
|
}
|
|
8578
|
-
if (key.type ===
|
|
8724
|
+
if (key.type === AST_NODE_TYPES43.Literal && typeof key.value === "string") {
|
|
8579
8725
|
return key.value;
|
|
8580
8726
|
}
|
|
8581
8727
|
return null;
|
|
8582
8728
|
}
|
|
8583
8729
|
function isStringLiteralMember(t) {
|
|
8584
|
-
return t.type ===
|
|
8730
|
+
return t.type === AST_NODE_TYPES43.TSLiteralType && t.literal.type === AST_NODE_TYPES43.Literal && typeof t.literal.value === "string";
|
|
8585
8731
|
}
|
|
8586
8732
|
function isStringLiteralUnion(node) {
|
|
8587
|
-
if (node?.type !==
|
|
8733
|
+
if (node?.type !== AST_NODE_TYPES43.TSUnionType) {
|
|
8588
8734
|
return false;
|
|
8589
8735
|
}
|
|
8590
8736
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8613,12 +8759,12 @@ function bindingSourceExpression(decl) {
|
|
|
8613
8759
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8614
8760
|
}
|
|
8615
8761
|
function refKey(node) {
|
|
8616
|
-
if (node.type ===
|
|
8762
|
+
if (node.type === AST_NODE_TYPES43.Identifier) {
|
|
8617
8763
|
return node.name;
|
|
8618
8764
|
}
|
|
8619
|
-
if (node.type ===
|
|
8765
|
+
if (node.type === AST_NODE_TYPES43.MemberExpression && !node.computed) {
|
|
8620
8766
|
const inner = refKey(node.object);
|
|
8621
|
-
if (inner === null || node.property.type !==
|
|
8767
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
8622
8768
|
return null;
|
|
8623
8769
|
}
|
|
8624
8770
|
return `${inner}.${node.property.name}`;
|
|
@@ -8626,7 +8772,7 @@ function refKey(node) {
|
|
|
8626
8772
|
return null;
|
|
8627
8773
|
}
|
|
8628
8774
|
function strLiteral(node) {
|
|
8629
|
-
if (node.type ===
|
|
8775
|
+
if (node.type === AST_NODE_TYPES43.Literal && typeof node.value === "string") {
|
|
8630
8776
|
return node.value;
|
|
8631
8777
|
}
|
|
8632
8778
|
return null;
|
|
@@ -8779,7 +8925,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8779
8925
|
containersWithUnion.add(container);
|
|
8780
8926
|
return;
|
|
8781
8927
|
}
|
|
8782
|
-
if (typeNode?.type !==
|
|
8928
|
+
if (typeNode?.type !== AST_NODE_TYPES43.TSStringKeyword) {
|
|
8783
8929
|
return;
|
|
8784
8930
|
}
|
|
8785
8931
|
const name = keyName(key);
|
|
@@ -8867,10 +9013,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8867
9013
|
}
|
|
8868
9014
|
};
|
|
8869
9015
|
function refKeyText(node) {
|
|
8870
|
-
if (node.type ===
|
|
9016
|
+
if (node.type === AST_NODE_TYPES43.BinaryExpression) {
|
|
8871
9017
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8872
9018
|
}
|
|
8873
|
-
if (node.type ===
|
|
9019
|
+
if (node.type === AST_NODE_TYPES43.SwitchStatement) {
|
|
8874
9020
|
return refKey(node.discriminant) ?? "value";
|
|
8875
9021
|
}
|
|
8876
9022
|
return "value";
|
|
@@ -8879,7 +9025,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8879
9025
|
});
|
|
8880
9026
|
|
|
8881
9027
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8882
|
-
import { AST_NODE_TYPES as
|
|
9028
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
8883
9029
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8884
9030
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8885
9031
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8888,11 +9034,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8888
9034
|
var MIN_RUN_LENGTH = 2;
|
|
8889
9035
|
function literalText(node, getText) {
|
|
8890
9036
|
switch (node.type) {
|
|
8891
|
-
case
|
|
9037
|
+
case AST_NODE_TYPES44.Literal:
|
|
8892
9038
|
return "regex" in node ? null : getText(node);
|
|
8893
|
-
case
|
|
9039
|
+
case AST_NODE_TYPES44.TemplateLiteral:
|
|
8894
9040
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8895
|
-
case
|
|
9041
|
+
case AST_NODE_TYPES44.UnaryExpression:
|
|
8896
9042
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8897
9043
|
default:
|
|
8898
9044
|
return null;
|
|
@@ -8900,15 +9046,15 @@ function literalText(node, getText) {
|
|
|
8900
9046
|
}
|
|
8901
9047
|
function isPureReceiver(node) {
|
|
8902
9048
|
switch (node.type) {
|
|
8903
|
-
case
|
|
8904
|
-
case
|
|
9049
|
+
case AST_NODE_TYPES44.Identifier:
|
|
9050
|
+
case AST_NODE_TYPES44.ThisExpression:
|
|
8905
9051
|
return true;
|
|
8906
|
-
case
|
|
9052
|
+
case AST_NODE_TYPES44.MemberExpression:
|
|
8907
9053
|
if (node.optional) {
|
|
8908
9054
|
return false;
|
|
8909
9055
|
}
|
|
8910
9056
|
if (node.computed) {
|
|
8911
|
-
return node.property.type ===
|
|
9057
|
+
return node.property.type === AST_NODE_TYPES44.Literal && isPureReceiver(node.object);
|
|
8912
9058
|
}
|
|
8913
9059
|
return isPureReceiver(node.object);
|
|
8914
9060
|
default:
|
|
@@ -8916,7 +9062,7 @@ function isPureReceiver(node) {
|
|
|
8916
9062
|
}
|
|
8917
9063
|
}
|
|
8918
9064
|
function literalIndex(node) {
|
|
8919
|
-
if (node.type !==
|
|
9065
|
+
if (node.type !== AST_NODE_TYPES44.Literal || typeof node.value !== "number") {
|
|
8920
9066
|
return null;
|
|
8921
9067
|
}
|
|
8922
9068
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8942,24 +9088,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8942
9088
|
}
|
|
8943
9089
|
const { sourceCode } = context;
|
|
8944
9090
|
function parseAssertion(statement) {
|
|
8945
|
-
if (statement.type !==
|
|
9091
|
+
if (statement.type !== AST_NODE_TYPES44.ExpressionStatement) {
|
|
8946
9092
|
return null;
|
|
8947
9093
|
}
|
|
8948
9094
|
const call = statement.expression;
|
|
8949
|
-
if (call.type !==
|
|
9095
|
+
if (call.type !== AST_NODE_TYPES44.CallExpression) {
|
|
8950
9096
|
return null;
|
|
8951
9097
|
}
|
|
8952
9098
|
const callee = call.callee;
|
|
8953
|
-
if (callee.type !==
|
|
9099
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
8954
9100
|
return null;
|
|
8955
9101
|
}
|
|
8956
9102
|
const matcher = callee.property.name;
|
|
8957
9103
|
const expectCall = callee.object;
|
|
8958
|
-
if (expectCall.type !==
|
|
9104
|
+
if (expectCall.type !== AST_NODE_TYPES44.CallExpression || expectCall.callee.type !== AST_NODE_TYPES44.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8959
9105
|
return null;
|
|
8960
9106
|
}
|
|
8961
9107
|
const actual = expectCall.arguments[0];
|
|
8962
|
-
if (actual === void 0 || actual.type !==
|
|
9108
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES44.MemberExpression || actual.optional) {
|
|
8963
9109
|
return null;
|
|
8964
9110
|
}
|
|
8965
9111
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8973,7 +9119,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8973
9119
|
}
|
|
8974
9120
|
key = { kind: "index", index };
|
|
8975
9121
|
} else {
|
|
8976
|
-
if (actual.property.type !==
|
|
9122
|
+
if (actual.property.type !== AST_NODE_TYPES44.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8977
9123
|
return null;
|
|
8978
9124
|
}
|
|
8979
9125
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8985,7 +9131,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8985
9131
|
return null;
|
|
8986
9132
|
}
|
|
8987
9133
|
const expected = call.arguments[0];
|
|
8988
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
9134
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES44.SpreadElement) {
|
|
8989
9135
|
return null;
|
|
8990
9136
|
}
|
|
8991
9137
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9100,7 +9246,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9100
9246
|
});
|
|
9101
9247
|
|
|
9102
9248
|
// src/rules/prefer-zod-enum.ts
|
|
9103
|
-
import { AST_NODE_TYPES as
|
|
9249
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
9104
9250
|
var prefer_zod_enum_default = createRule({
|
|
9105
9251
|
name: "prefer-zod-enum",
|
|
9106
9252
|
meta: {
|
|
@@ -9120,25 +9266,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9120
9266
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9121
9267
|
function enumValues(node) {
|
|
9122
9268
|
const callee = node.callee;
|
|
9123
|
-
if (callee.type !==
|
|
9269
|
+
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
9270
|
return null;
|
|
9125
9271
|
}
|
|
9126
9272
|
const argument = node.arguments[0];
|
|
9127
|
-
if (argument === void 0 || argument.type !==
|
|
9273
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES45.ArrayExpression || argument.elements.length === 0) {
|
|
9128
9274
|
return null;
|
|
9129
9275
|
}
|
|
9130
9276
|
const values = [];
|
|
9131
9277
|
let canFix = true;
|
|
9132
9278
|
for (const element of argument.elements) {
|
|
9133
|
-
if (element?.type ===
|
|
9279
|
+
if (element?.type === AST_NODE_TYPES45.SpreadElement) {
|
|
9134
9280
|
canFix = false;
|
|
9135
9281
|
continue;
|
|
9136
9282
|
}
|
|
9137
|
-
if (element === null || element.type !==
|
|
9283
|
+
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
9284
|
return null;
|
|
9139
9285
|
}
|
|
9140
9286
|
const value = element.arguments[0];
|
|
9141
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9287
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES45.Literal || typeof value.value !== "string") {
|
|
9142
9288
|
canFix = false;
|
|
9143
9289
|
continue;
|
|
9144
9290
|
}
|
|
@@ -9148,11 +9294,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9148
9294
|
}
|
|
9149
9295
|
function buildFix(node, values) {
|
|
9150
9296
|
const argument = node.arguments[0];
|
|
9151
|
-
if (argument === void 0 || argument.type !==
|
|
9297
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES45.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9152
9298
|
return void 0;
|
|
9153
9299
|
}
|
|
9154
9300
|
const callee = node.callee;
|
|
9155
|
-
if (callee.type !==
|
|
9301
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.property.type !== AST_NODE_TYPES45.Identifier) {
|
|
9156
9302
|
return void 0;
|
|
9157
9303
|
}
|
|
9158
9304
|
return (fixer) => [
|
|
@@ -9169,7 +9315,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9169
9315
|
return;
|
|
9170
9316
|
}
|
|
9171
9317
|
for (const specifier of node.specifiers) {
|
|
9172
|
-
if (specifier.type ===
|
|
9318
|
+
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
9319
|
zodNamespaces.add(specifier.local.name);
|
|
9174
9320
|
}
|
|
9175
9321
|
}
|
|
@@ -9191,7 +9337,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9191
9337
|
});
|
|
9192
9338
|
|
|
9193
9339
|
// src/rules/prefer-zod-infer.ts
|
|
9194
|
-
import { AST_NODE_TYPES as
|
|
9340
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46 } from "@typescript-eslint/utils";
|
|
9195
9341
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9196
9342
|
"describe",
|
|
9197
9343
|
"refine",
|
|
@@ -9228,44 +9374,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9228
9374
|
"Schema"
|
|
9229
9375
|
]);
|
|
9230
9376
|
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: [
|
|
9377
|
+
string: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9378
|
+
email: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9379
|
+
url: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9380
|
+
uuid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9381
|
+
ulid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9382
|
+
cuid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9383
|
+
cuid2: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9384
|
+
nanoid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9385
|
+
iso: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9386
|
+
number: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9387
|
+
int: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9388
|
+
float32: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9389
|
+
float64: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9390
|
+
boolean: [AST_NODE_TYPES46.TSBooleanKeyword],
|
|
9391
|
+
bigint: [AST_NODE_TYPES46.TSBigIntKeyword],
|
|
9392
|
+
symbol: [AST_NODE_TYPES46.TSSymbolKeyword],
|
|
9393
|
+
any: [AST_NODE_TYPES46.TSAnyKeyword],
|
|
9394
|
+
unknown: [AST_NODE_TYPES46.TSUnknownKeyword],
|
|
9395
|
+
never: [AST_NODE_TYPES46.TSNeverKeyword],
|
|
9396
|
+
void: [AST_NODE_TYPES46.TSVoidKeyword],
|
|
9397
|
+
null: [AST_NODE_TYPES46.TSNullKeyword],
|
|
9398
|
+
undefined: [AST_NODE_TYPES46.TSUndefinedKeyword],
|
|
9399
|
+
literal: [AST_NODE_TYPES46.TSLiteralType],
|
|
9400
|
+
date: [AST_NODE_TYPES46.TSTypeReference],
|
|
9401
|
+
array: [AST_NODE_TYPES46.TSArrayType, AST_NODE_TYPES46.TSTypeReference],
|
|
9402
|
+
tuple: [AST_NODE_TYPES46.TSTupleType],
|
|
9403
|
+
object: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9404
|
+
strictObject: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9405
|
+
looseObject: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9406
|
+
record: [AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSTypeLiteral],
|
|
9407
|
+
map: [AST_NODE_TYPES46.TSTypeReference],
|
|
9408
|
+
set: [AST_NODE_TYPES46.TSTypeReference],
|
|
9409
|
+
promise: [AST_NODE_TYPES46.TSTypeReference],
|
|
9410
|
+
enum: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSLiteralType],
|
|
9411
|
+
nativeEnum: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSLiteralType],
|
|
9412
|
+
union: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference],
|
|
9413
|
+
discriminatedUnion: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference],
|
|
9414
|
+
intersection: [AST_NODE_TYPES46.TSIntersectionType, AST_NODE_TYPES46.TSTypeReference]
|
|
9269
9415
|
};
|
|
9270
9416
|
function normalizeSchemaName(name) {
|
|
9271
9417
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9274,20 +9420,20 @@ function normalizeTypeName(name) {
|
|
|
9274
9420
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9275
9421
|
}
|
|
9276
9422
|
function unwrapNullish(annotation) {
|
|
9277
|
-
if (annotation.type !==
|
|
9423
|
+
if (annotation.type !== AST_NODE_TYPES46.TSUnionType) {
|
|
9278
9424
|
return {
|
|
9279
9425
|
core: annotation,
|
|
9280
|
-
nullable: annotation.type ===
|
|
9426
|
+
nullable: annotation.type === AST_NODE_TYPES46.TSNullKeyword
|
|
9281
9427
|
};
|
|
9282
9428
|
}
|
|
9283
9429
|
const rest = [];
|
|
9284
9430
|
let nullable = false;
|
|
9285
9431
|
for (const member of annotation.types) {
|
|
9286
|
-
if (member.type ===
|
|
9432
|
+
if (member.type === AST_NODE_TYPES46.TSNullKeyword) {
|
|
9287
9433
|
nullable = true;
|
|
9288
9434
|
continue;
|
|
9289
9435
|
}
|
|
9290
|
-
if (member.type ===
|
|
9436
|
+
if (member.type === AST_NODE_TYPES46.TSUndefinedKeyword) {
|
|
9291
9437
|
continue;
|
|
9292
9438
|
}
|
|
9293
9439
|
rest.push(member);
|
|
@@ -9352,14 +9498,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9352
9498
|
function zodCallChain(node) {
|
|
9353
9499
|
const chain = [];
|
|
9354
9500
|
let current = node;
|
|
9355
|
-
while (current.type ===
|
|
9501
|
+
while (current.type === AST_NODE_TYPES46.CallExpression) {
|
|
9356
9502
|
const callee = current.callee;
|
|
9357
|
-
if (callee.type !==
|
|
9503
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9358
9504
|
return null;
|
|
9359
9505
|
}
|
|
9360
9506
|
chain.push(current);
|
|
9361
9507
|
const receiver = callee.object;
|
|
9362
|
-
if (receiver.type ===
|
|
9508
|
+
if (receiver.type === AST_NODE_TYPES46.Identifier) {
|
|
9363
9509
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9364
9510
|
}
|
|
9365
9511
|
current = receiver;
|
|
@@ -9368,19 +9514,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9368
9514
|
}
|
|
9369
9515
|
function methodName(call) {
|
|
9370
9516
|
const callee = call.callee;
|
|
9371
|
-
return callee.type ===
|
|
9517
|
+
return callee.type === AST_NODE_TYPES46.MemberExpression && callee.property.type === AST_NODE_TYPES46.Identifier ? callee.property.name : "";
|
|
9372
9518
|
}
|
|
9373
9519
|
function schemaField(node) {
|
|
9374
9520
|
const modifiers = [];
|
|
9375
9521
|
let current = node;
|
|
9376
9522
|
let leaf = null;
|
|
9377
|
-
while (current.type ===
|
|
9523
|
+
while (current.type === AST_NODE_TYPES46.CallExpression) {
|
|
9378
9524
|
const callee = current.callee;
|
|
9379
|
-
if (callee.type !==
|
|
9525
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9380
9526
|
break;
|
|
9381
9527
|
}
|
|
9382
9528
|
const receiver = callee.object;
|
|
9383
|
-
if (receiver.type ===
|
|
9529
|
+
if (receiver.type === AST_NODE_TYPES46.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9384
9530
|
leaf = callee.property.name;
|
|
9385
9531
|
break;
|
|
9386
9532
|
}
|
|
@@ -9411,16 +9557,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9411
9557
|
return null;
|
|
9412
9558
|
}
|
|
9413
9559
|
const shape = base.arguments[0];
|
|
9414
|
-
if (shape === void 0 || shape.type !==
|
|
9560
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES46.ObjectExpression) {
|
|
9415
9561
|
return null;
|
|
9416
9562
|
}
|
|
9417
9563
|
const fields = /* @__PURE__ */ new Map();
|
|
9418
9564
|
for (const property of shape.properties) {
|
|
9419
|
-
if (property.type !==
|
|
9565
|
+
if (property.type !== AST_NODE_TYPES46.Property || property.computed) {
|
|
9420
9566
|
return null;
|
|
9421
9567
|
}
|
|
9422
9568
|
const { key } = property;
|
|
9423
|
-
const name = key.type ===
|
|
9569
|
+
const name = key.type === AST_NODE_TYPES46.Identifier ? key.name : key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string" ? key.value : null;
|
|
9424
9570
|
if (name === null) {
|
|
9425
9571
|
return null;
|
|
9426
9572
|
}
|
|
@@ -9431,11 +9577,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9431
9577
|
function typeMembers(members) {
|
|
9432
9578
|
const result = /* @__PURE__ */ new Map();
|
|
9433
9579
|
for (const member of members) {
|
|
9434
|
-
if (member.type !==
|
|
9580
|
+
if (member.type !== AST_NODE_TYPES46.TSPropertySignature || member.computed) {
|
|
9435
9581
|
return null;
|
|
9436
9582
|
}
|
|
9437
9583
|
const { key } = member;
|
|
9438
|
-
const name = key.type ===
|
|
9584
|
+
const name = key.type === AST_NODE_TYPES46.Identifier ? key.name : key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string" ? key.value : null;
|
|
9439
9585
|
if (name === null) {
|
|
9440
9586
|
return null;
|
|
9441
9587
|
}
|
|
@@ -9449,8 +9595,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9449
9595
|
return result.size === 0 ? null : result;
|
|
9450
9596
|
}
|
|
9451
9597
|
function collectConstrainedNames(node) {
|
|
9452
|
-
if (node.type ===
|
|
9453
|
-
if (node.typeName.type ===
|
|
9598
|
+
if (node.type === AST_NODE_TYPES46.TSTypeReference) {
|
|
9599
|
+
if (node.typeName.type === AST_NODE_TYPES46.Identifier) {
|
|
9454
9600
|
constrainedTypeNames.add(node.typeName.name);
|
|
9455
9601
|
}
|
|
9456
9602
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9458,11 +9604,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9458
9604
|
}
|
|
9459
9605
|
return;
|
|
9460
9606
|
}
|
|
9461
|
-
if (node.type ===
|
|
9607
|
+
if (node.type === AST_NODE_TYPES46.TSArrayType) {
|
|
9462
9608
|
collectConstrainedNames(node.elementType);
|
|
9463
9609
|
return;
|
|
9464
9610
|
}
|
|
9465
|
-
if (node.type ===
|
|
9611
|
+
if (node.type === AST_NODE_TYPES46.TSUnionType || node.type === AST_NODE_TYPES46.TSIntersectionType) {
|
|
9466
9612
|
for (const member of node.types) {
|
|
9467
9613
|
collectConstrainedNames(member);
|
|
9468
9614
|
}
|
|
@@ -9506,13 +9652,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9506
9652
|
return;
|
|
9507
9653
|
}
|
|
9508
9654
|
for (const specifier of node.specifiers) {
|
|
9509
|
-
if (specifier.type ===
|
|
9655
|
+
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
9656
|
zodNamespaces.add(specifier.local.name);
|
|
9511
9657
|
}
|
|
9512
9658
|
}
|
|
9513
9659
|
},
|
|
9514
9660
|
VariableDeclarator(node) {
|
|
9515
|
-
if (node.id.type !==
|
|
9661
|
+
if (node.id.type !== AST_NODE_TYPES46.Identifier || node.init == null) {
|
|
9516
9662
|
return;
|
|
9517
9663
|
}
|
|
9518
9664
|
const fields = schemaFields(node.init);
|
|
@@ -9522,14 +9668,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9522
9668
|
},
|
|
9523
9669
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9524
9670
|
"MemberExpression[computed=false]"(node) {
|
|
9525
|
-
if (node.object.type ===
|
|
9671
|
+
if (node.object.type === AST_NODE_TYPES46.Identifier && node.property.type === AST_NODE_TYPES46.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9526
9672
|
reshapedSchemaNames.add(node.object.name);
|
|
9527
9673
|
}
|
|
9528
9674
|
},
|
|
9529
9675
|
/** Records every type argument carried by a Zod constraint. */
|
|
9530
9676
|
TSTypeReference(node) {
|
|
9531
9677
|
const { typeName } = node;
|
|
9532
|
-
const referenced = typeName.type ===
|
|
9678
|
+
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
9679
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9534
9680
|
return;
|
|
9535
9681
|
}
|
|
@@ -9547,7 +9693,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9547
9693
|
}
|
|
9548
9694
|
},
|
|
9549
9695
|
TSTypeAliasDeclaration(node) {
|
|
9550
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9696
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES46.TSTypeLiteral) {
|
|
9551
9697
|
return;
|
|
9552
9698
|
}
|
|
9553
9699
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9592,10 +9738,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9592
9738
|
});
|
|
9593
9739
|
|
|
9594
9740
|
// src/rules/require-assert-never.ts
|
|
9595
|
-
import { AST_NODE_TYPES as
|
|
9741
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9596
9742
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9597
|
-
if (statement.type ===
|
|
9598
|
-
if (statement.type ===
|
|
9743
|
+
if (statement.type === AST_NODE_TYPES47.EmptyStatement) return false;
|
|
9744
|
+
if (statement.type === AST_NODE_TYPES47.BlockStatement) {
|
|
9599
9745
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9600
9746
|
}
|
|
9601
9747
|
return true;
|
|
@@ -9611,7 +9757,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9611
9757
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9612
9758
|
}
|
|
9613
9759
|
const only = defaultCase.consequent[0];
|
|
9614
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9760
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES47.BlockStatement && only.body.length === 0) {
|
|
9615
9761
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9616
9762
|
}
|
|
9617
9763
|
return false;
|
|
@@ -9651,7 +9797,7 @@ var require_assert_never_default = createRule({
|
|
|
9651
9797
|
});
|
|
9652
9798
|
|
|
9653
9799
|
// src/rules/require-fetch-timeout.ts
|
|
9654
|
-
import { AST_NODE_TYPES as
|
|
9800
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48, ASTUtils as ASTUtils5 } from "@typescript-eslint/utils";
|
|
9655
9801
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9656
9802
|
"globalThis",
|
|
9657
9803
|
"window",
|
|
@@ -9667,14 +9813,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9667
9813
|
return false;
|
|
9668
9814
|
}
|
|
9669
9815
|
function initProvablyLacksSignal(init) {
|
|
9670
|
-
if (init.type !==
|
|
9816
|
+
if (init.type !== AST_NODE_TYPES48.ObjectExpression) {
|
|
9671
9817
|
return false;
|
|
9672
9818
|
}
|
|
9673
9819
|
for (const prop of init.properties) {
|
|
9674
|
-
if (prop.type ===
|
|
9820
|
+
if (prop.type === AST_NODE_TYPES48.SpreadElement) {
|
|
9675
9821
|
return false;
|
|
9676
9822
|
}
|
|
9677
|
-
if (prop.key.type ===
|
|
9823
|
+
if (prop.key.type === AST_NODE_TYPES48.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES48.Literal && prop.key.value === "signal") {
|
|
9678
9824
|
return false;
|
|
9679
9825
|
}
|
|
9680
9826
|
if (prop.computed) {
|
|
@@ -9684,7 +9830,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9684
9830
|
return true;
|
|
9685
9831
|
}
|
|
9686
9832
|
function isStringish(node) {
|
|
9687
|
-
return node.type ===
|
|
9833
|
+
return node.type === AST_NODE_TYPES48.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES48.TemplateLiteral;
|
|
9688
9834
|
}
|
|
9689
9835
|
var require_fetch_timeout_default = createRule({
|
|
9690
9836
|
name: "require-fetch-timeout",
|
|
@@ -9721,14 +9867,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9721
9867
|
}
|
|
9722
9868
|
function resolvesToGlobal(identifier) {
|
|
9723
9869
|
const scope = context.sourceCode.getScope(identifier);
|
|
9724
|
-
const variable =
|
|
9870
|
+
const variable = ASTUtils5.findVariable(scope, identifier.name);
|
|
9725
9871
|
return variable === null || variable.defs.length === 0;
|
|
9726
9872
|
}
|
|
9727
9873
|
function isGlobalFetchCall2(callee) {
|
|
9728
|
-
if (callee.type ===
|
|
9874
|
+
if (callee.type === AST_NODE_TYPES48.Identifier) {
|
|
9729
9875
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9730
9876
|
}
|
|
9731
|
-
return callee.type ===
|
|
9877
|
+
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
9878
|
}
|
|
9733
9879
|
return {
|
|
9734
9880
|
CallExpression(node) {
|
|
@@ -9748,7 +9894,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9748
9894
|
});
|
|
9749
9895
|
|
|
9750
9896
|
// src/rules/require-interface-for-injected-service.ts
|
|
9751
|
-
import { AST_NODE_TYPES as
|
|
9897
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49 } from "@typescript-eslint/utils";
|
|
9752
9898
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9753
9899
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9754
9900
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9756,20 +9902,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9756
9902
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9757
9903
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9758
9904
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9759
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9760
|
-
var qualifiedName = (name) => name.type ===
|
|
9905
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES49.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES49.ExportDefaultDeclaration;
|
|
9906
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES49.Identifier ? name.name : name.type === AST_NODE_TYPES49.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9761
9907
|
var readTypeReference = (annotation) => {
|
|
9762
|
-
if (annotation === void 0 || annotation.type !==
|
|
9908
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES49.TSTypeReference) return null;
|
|
9763
9909
|
const { typeName } = annotation;
|
|
9764
|
-
const rightmost = typeName.type ===
|
|
9910
|
+
const rightmost = typeName.type === AST_NODE_TYPES49.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES49.TSQualifiedName ? typeName.right.name : null;
|
|
9765
9911
|
if (rightmost === null) return null;
|
|
9766
9912
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9767
9913
|
};
|
|
9768
9914
|
var namedParameterCollaborator = (annotated) => {
|
|
9769
9915
|
let target = annotated;
|
|
9770
|
-
if (target.type ===
|
|
9771
|
-
if (target.type ===
|
|
9772
|
-
if (target.type !==
|
|
9916
|
+
if (target.type === AST_NODE_TYPES49.TSParameterProperty) target = target.parameter;
|
|
9917
|
+
if (target.type === AST_NODE_TYPES49.AssignmentPattern) target = target.left;
|
|
9918
|
+
if (target.type !== AST_NODE_TYPES49.Identifier) return null;
|
|
9773
9919
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9774
9920
|
if (reference === null) return null;
|
|
9775
9921
|
return { name: target.name, ...reference };
|
|
@@ -9777,8 +9923,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9777
9923
|
var propertySignatureTypes = (members) => {
|
|
9778
9924
|
const types = /* @__PURE__ */ new Map();
|
|
9779
9925
|
for (const member of members) {
|
|
9780
|
-
if (member.type !==
|
|
9781
|
-
if (member.computed || member.key.type !==
|
|
9926
|
+
if (member.type !== AST_NODE_TYPES49.TSPropertySignature) continue;
|
|
9927
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9782
9928
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9783
9929
|
if (reference === null) continue;
|
|
9784
9930
|
types.set(member.key.name, reference);
|
|
@@ -9789,18 +9935,18 @@ var fileTypeIndex = (program) => {
|
|
|
9789
9935
|
const objects = /* @__PURE__ */ new Map();
|
|
9790
9936
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9791
9937
|
for (const statement of program.body) {
|
|
9792
|
-
const declaration = statement.type ===
|
|
9793
|
-
if (declaration?.type ===
|
|
9938
|
+
const declaration = statement.type === AST_NODE_TYPES49.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9939
|
+
if (declaration?.type === AST_NODE_TYPES49.TSInterfaceDeclaration) {
|
|
9794
9940
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9795
9941
|
continue;
|
|
9796
9942
|
}
|
|
9797
|
-
if (declaration?.type !==
|
|
9943
|
+
if (declaration?.type !== AST_NODE_TYPES49.TSTypeAliasDeclaration) continue;
|
|
9798
9944
|
const aliased = declaration.typeAnnotation;
|
|
9799
|
-
if (aliased.type ===
|
|
9945
|
+
if (aliased.type === AST_NODE_TYPES49.TSFunctionType || aliased.type === AST_NODE_TYPES49.TSConstructorType) {
|
|
9800
9946
|
functionAliases.add(declaration.id.name);
|
|
9801
9947
|
continue;
|
|
9802
9948
|
}
|
|
9803
|
-
const literals = aliased.type ===
|
|
9949
|
+
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
9950
|
if (literals.length === 0) continue;
|
|
9805
9951
|
const merged = /* @__PURE__ */ new Map();
|
|
9806
9952
|
for (const literal of literals) {
|
|
@@ -9813,10 +9959,10 @@ var fileTypeIndex = (program) => {
|
|
|
9813
9959
|
return { objects, functionAliases };
|
|
9814
9960
|
};
|
|
9815
9961
|
var bagMemberTypes = (annotation, declared) => {
|
|
9816
|
-
if (annotation.type ===
|
|
9962
|
+
if (annotation.type === AST_NODE_TYPES49.TSTypeLiteral) {
|
|
9817
9963
|
return propertySignatureTypes(annotation.members);
|
|
9818
9964
|
}
|
|
9819
|
-
if (annotation.type !==
|
|
9965
|
+
if (annotation.type !== AST_NODE_TYPES49.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES49.Identifier) {
|
|
9820
9966
|
return null;
|
|
9821
9967
|
}
|
|
9822
9968
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9828,11 +9974,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9828
9974
|
if (members === null) return [];
|
|
9829
9975
|
const collaborators = [];
|
|
9830
9976
|
for (const property of pattern.properties) {
|
|
9831
|
-
if (property.type !==
|
|
9832
|
-
if (property.key.type !==
|
|
9977
|
+
if (property.type !== AST_NODE_TYPES49.Property || property.computed) continue;
|
|
9978
|
+
if (property.key.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9833
9979
|
const key = property.key.name;
|
|
9834
|
-
const bound = property.value.type ===
|
|
9835
|
-
if (bound.type !==
|
|
9980
|
+
const bound = property.value.type === AST_NODE_TYPES49.AssignmentPattern ? property.value.left : property.value;
|
|
9981
|
+
if (bound.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9836
9982
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9837
9983
|
const reference = members.get(key);
|
|
9838
9984
|
if (reference === void 0) continue;
|
|
@@ -9842,8 +9988,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9842
9988
|
};
|
|
9843
9989
|
var parameterCollaborators = (parameter, declared) => {
|
|
9844
9990
|
let target = parameter;
|
|
9845
|
-
if (target.type ===
|
|
9846
|
-
if (target.type ===
|
|
9991
|
+
if (target.type === AST_NODE_TYPES49.AssignmentPattern) target = target.left;
|
|
9992
|
+
if (target.type === AST_NODE_TYPES49.ObjectPattern) {
|
|
9847
9993
|
return objectPatternCollaborators(target, declared);
|
|
9848
9994
|
}
|
|
9849
9995
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9862,17 +10008,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9862
10008
|
let constructedFields = 0;
|
|
9863
10009
|
if (body2 !== null && body2 !== void 0) {
|
|
9864
10010
|
for (const statement of body2.body) {
|
|
9865
|
-
if (statement.type !==
|
|
10011
|
+
if (statement.type !== AST_NODE_TYPES49.ExpressionStatement) continue;
|
|
9866
10012
|
const expression = statement.expression;
|
|
9867
|
-
if (expression.type !==
|
|
10013
|
+
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
10014
|
continue;
|
|
9869
10015
|
}
|
|
9870
10016
|
const source = expression.right;
|
|
9871
|
-
if (source.type ===
|
|
10017
|
+
if (source.type === AST_NODE_TYPES49.NewExpression) {
|
|
9872
10018
|
constructedFields += 1;
|
|
9873
|
-
} else if (source.type ===
|
|
10019
|
+
} else if (source.type === AST_NODE_TYPES49.Identifier) {
|
|
9874
10020
|
storedFrom.add(source.name);
|
|
9875
|
-
} else if (source.type ===
|
|
10021
|
+
} else if (source.type === AST_NODE_TYPES49.MemberExpression && source.object.type === AST_NODE_TYPES49.Identifier) {
|
|
9876
10022
|
storedFrom.add(source.object.name);
|
|
9877
10023
|
}
|
|
9878
10024
|
}
|
|
@@ -9880,7 +10026,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9880
10026
|
const collaborators = [];
|
|
9881
10027
|
for (const parameter of ctor.value.params) {
|
|
9882
10028
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9883
|
-
const stored = parameter.type ===
|
|
10029
|
+
const stored = parameter.type === AST_NODE_TYPES49.TSParameterProperty || storedFrom.has(reference.name);
|
|
9884
10030
|
if (!stored) continue;
|
|
9885
10031
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9886
10032
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9914,19 +10060,19 @@ var subtreeHas = (root, found) => {
|
|
|
9914
10060
|
return hit;
|
|
9915
10061
|
};
|
|
9916
10062
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9917
|
-
if (node.type ===
|
|
10063
|
+
if (node.type === AST_NODE_TYPES49.CallExpression) {
|
|
9918
10064
|
const { callee } = node;
|
|
9919
|
-
if (callee.type ===
|
|
9920
|
-
return callee.type ===
|
|
10065
|
+
if (callee.type === AST_NODE_TYPES49.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
10066
|
+
return callee.type === AST_NODE_TYPES49.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES49.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9921
10067
|
}
|
|
9922
|
-
return node.type ===
|
|
10068
|
+
return node.type === AST_NODE_TYPES49.TSTypeReference && node.typeName.type === AST_NODE_TYPES49.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9923
10069
|
});
|
|
9924
10070
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9925
10071
|
var fileInterfaceNames = (program) => {
|
|
9926
10072
|
const names = [];
|
|
9927
10073
|
for (const statement of program.body) {
|
|
9928
|
-
const declaration = statement.type ===
|
|
9929
|
-
if (declaration?.type ===
|
|
10074
|
+
const declaration = statement.type === AST_NODE_TYPES49.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10075
|
+
if (declaration?.type === AST_NODE_TYPES49.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9930
10076
|
}
|
|
9931
10077
|
return names;
|
|
9932
10078
|
};
|
|
@@ -9944,11 +10090,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9944
10090
|
var publicMethodNames = (body2) => {
|
|
9945
10091
|
const names = [];
|
|
9946
10092
|
for (const member of body2.body) {
|
|
9947
|
-
if (member.type !==
|
|
10093
|
+
if (member.type !== AST_NODE_TYPES49.MethodDefinition) continue;
|
|
9948
10094
|
if (member.kind !== "method" || member.static) continue;
|
|
9949
10095
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9950
|
-
if (member.key.type ===
|
|
9951
|
-
if (member.key.type ===
|
|
10096
|
+
if (member.key.type === AST_NODE_TYPES49.PrivateIdentifier) continue;
|
|
10097
|
+
if (member.key.type === AST_NODE_TYPES49.Identifier) names.push(member.key.name);
|
|
9952
10098
|
else names.push("\u2026");
|
|
9953
10099
|
}
|
|
9954
10100
|
return names;
|
|
@@ -9981,7 +10127,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9981
10127
|
if (node.implements.length > 0) return;
|
|
9982
10128
|
if (node.decorators.length > 0) return;
|
|
9983
10129
|
const ctor = node.body.body.find(
|
|
9984
|
-
(member) => member.type ===
|
|
10130
|
+
(member) => member.type === AST_NODE_TYPES49.MethodDefinition && member.kind === "constructor"
|
|
9985
10131
|
);
|
|
9986
10132
|
if (ctor === void 0) return;
|
|
9987
10133
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -10010,37 +10156,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10010
10156
|
});
|
|
10011
10157
|
|
|
10012
10158
|
// src/rules/require-static-next-matcher.ts
|
|
10013
|
-
import { AST_NODE_TYPES as
|
|
10159
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
10014
10160
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
10015
|
-
function
|
|
10016
|
-
if (node.type ===
|
|
10017
|
-
return
|
|
10161
|
+
function unwrapExpression2(node) {
|
|
10162
|
+
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) {
|
|
10163
|
+
return unwrapExpression2(node.expression);
|
|
10018
10164
|
}
|
|
10019
10165
|
return node;
|
|
10020
10166
|
}
|
|
10021
10167
|
function isStaticValue(node) {
|
|
10022
|
-
const value =
|
|
10023
|
-
if (value.type ===
|
|
10168
|
+
const value = unwrapExpression2(node);
|
|
10169
|
+
if (value.type === AST_NODE_TYPES50.Literal) {
|
|
10024
10170
|
return true;
|
|
10025
10171
|
}
|
|
10026
|
-
if (value.type ===
|
|
10172
|
+
if (value.type === AST_NODE_TYPES50.TemplateLiteral) {
|
|
10027
10173
|
return value.expressions.length === 0;
|
|
10028
10174
|
}
|
|
10029
|
-
if (value.type ===
|
|
10175
|
+
if (value.type === AST_NODE_TYPES50.ArrayExpression) {
|
|
10030
10176
|
return value.elements.every(
|
|
10031
|
-
(element) => element !== null && element.type !==
|
|
10177
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES50.SpreadElement && isStaticValue(element)
|
|
10032
10178
|
);
|
|
10033
10179
|
}
|
|
10034
|
-
if (value.type ===
|
|
10180
|
+
if (value.type === AST_NODE_TYPES50.ObjectExpression) {
|
|
10035
10181
|
return value.properties.every(
|
|
10036
|
-
(property) => property.type ===
|
|
10182
|
+
(property) => property.type === AST_NODE_TYPES50.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES50.AssignmentPattern && isStaticValue(property.value)
|
|
10037
10183
|
);
|
|
10038
10184
|
}
|
|
10039
10185
|
return false;
|
|
10040
10186
|
}
|
|
10041
10187
|
function propertyName2(property) {
|
|
10042
10188
|
if (property.computed) return null;
|
|
10043
|
-
if (property.key.type ===
|
|
10189
|
+
if (property.key.type === AST_NODE_TYPES50.Identifier) return property.key.name;
|
|
10044
10190
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
10045
10191
|
}
|
|
10046
10192
|
var require_static_next_matcher_default = createRule({
|
|
@@ -10062,19 +10208,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
10062
10208
|
}
|
|
10063
10209
|
return {
|
|
10064
10210
|
ExportNamedDeclaration(node) {
|
|
10065
|
-
if (node.declaration?.type !==
|
|
10211
|
+
if (node.declaration?.type !== AST_NODE_TYPES50.VariableDeclaration) {
|
|
10066
10212
|
return;
|
|
10067
10213
|
}
|
|
10068
10214
|
for (const declaration of node.declaration.declarations) {
|
|
10069
|
-
if (declaration.id.type !==
|
|
10215
|
+
if (declaration.id.type !== AST_NODE_TYPES50.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
10070
10216
|
continue;
|
|
10071
10217
|
}
|
|
10072
|
-
const config =
|
|
10073
|
-
if (config.type !==
|
|
10218
|
+
const config = unwrapExpression2(declaration.init);
|
|
10219
|
+
if (config.type !== AST_NODE_TYPES50.ObjectExpression) {
|
|
10074
10220
|
continue;
|
|
10075
10221
|
}
|
|
10076
10222
|
for (const property of config.properties) {
|
|
10077
|
-
if (property.type !==
|
|
10223
|
+
if (property.type !== AST_NODE_TYPES50.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES50.AssignmentPattern) {
|
|
10078
10224
|
continue;
|
|
10079
10225
|
}
|
|
10080
10226
|
if (!isStaticValue(property.value)) {
|
|
@@ -10088,18 +10234,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
10088
10234
|
});
|
|
10089
10235
|
|
|
10090
10236
|
// src/rules/require-zod-form-validation.ts
|
|
10091
|
-
import { AST_NODE_TYPES as
|
|
10237
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51 } from "@typescript-eslint/utils";
|
|
10092
10238
|
var looksLikeZodSchema = (node) => {
|
|
10093
10239
|
let current = node;
|
|
10094
10240
|
while (true) {
|
|
10095
|
-
if (current.type ===
|
|
10241
|
+
if (current.type === AST_NODE_TYPES51.Identifier) {
|
|
10096
10242
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10097
10243
|
}
|
|
10098
|
-
if (current.type ===
|
|
10244
|
+
if (current.type === AST_NODE_TYPES51.CallExpression) {
|
|
10099
10245
|
current = current.callee;
|
|
10100
10246
|
continue;
|
|
10101
10247
|
}
|
|
10102
|
-
if (current.type ===
|
|
10248
|
+
if (current.type === AST_NODE_TYPES51.MemberExpression) {
|
|
10103
10249
|
current = current.object;
|
|
10104
10250
|
continue;
|
|
10105
10251
|
}
|
|
@@ -10107,23 +10253,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10107
10253
|
}
|
|
10108
10254
|
};
|
|
10109
10255
|
var isZodParseCall = (node) => {
|
|
10110
|
-
if (node.type !==
|
|
10256
|
+
if (node.type !== AST_NODE_TYPES51.CallExpression) return false;
|
|
10111
10257
|
const callee = node.callee;
|
|
10112
|
-
if (callee.type !==
|
|
10258
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return false;
|
|
10113
10259
|
if (callee.computed) return false;
|
|
10114
|
-
if (callee.property.type !==
|
|
10260
|
+
if (callee.property.type !== AST_NODE_TYPES51.Identifier) return false;
|
|
10115
10261
|
const method = callee.property.name;
|
|
10116
10262
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10117
10263
|
return looksLikeZodSchema(callee.object);
|
|
10118
10264
|
};
|
|
10119
10265
|
var isFormDataMethodCall = (node) => {
|
|
10120
10266
|
let current = node;
|
|
10121
|
-
if (current.type ===
|
|
10267
|
+
if (current.type === AST_NODE_TYPES51.AwaitExpression) {
|
|
10122
10268
|
current = current.argument;
|
|
10123
10269
|
}
|
|
10124
|
-
if (current.type !==
|
|
10270
|
+
if (current.type !== AST_NODE_TYPES51.CallExpression) return false;
|
|
10125
10271
|
const callee = current.callee;
|
|
10126
|
-
return callee.type ===
|
|
10272
|
+
return callee.type === AST_NODE_TYPES51.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES51.Identifier && callee.property.name === "formData";
|
|
10127
10273
|
};
|
|
10128
10274
|
var require_zod_form_validation_default = createRule({
|
|
10129
10275
|
name: "require-zod-form-validation",
|
|
@@ -10143,14 +10289,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10143
10289
|
return {};
|
|
10144
10290
|
}
|
|
10145
10291
|
const isFormSourceIdentifier = (node) => {
|
|
10146
|
-
if (node.type !==
|
|
10292
|
+
if (node.type !== AST_NODE_TYPES51.Identifier) return false;
|
|
10147
10293
|
if (/formdata/i.test(node.name)) return true;
|
|
10148
10294
|
let scope = context.sourceCode.getScope(node);
|
|
10149
10295
|
while (scope !== null) {
|
|
10150
10296
|
const variable = scope.set.get(node.name);
|
|
10151
10297
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10152
10298
|
const def = variable.defs[0];
|
|
10153
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10299
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES51.VariableDeclarator && def.node.init !== null) {
|
|
10154
10300
|
return isFormDataMethodCall(def.node.init);
|
|
10155
10301
|
}
|
|
10156
10302
|
return false;
|
|
@@ -10161,8 +10307,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10161
10307
|
};
|
|
10162
10308
|
const isFormDataGetCall = (node) => {
|
|
10163
10309
|
const callee = node.callee;
|
|
10164
|
-
if (callee.type !==
|
|
10165
|
-
if (callee.property.type !==
|
|
10310
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return false;
|
|
10311
|
+
if (callee.property.type !== AST_NODE_TYPES51.Identifier || callee.property.name !== "get") {
|
|
10166
10312
|
return false;
|
|
10167
10313
|
}
|
|
10168
10314
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10177,11 +10323,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10177
10323
|
};
|
|
10178
10324
|
const isInstanceofNarrowing = (node) => {
|
|
10179
10325
|
const parent = node.parent;
|
|
10180
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10326
|
+
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
10327
|
};
|
|
10182
10328
|
const boundDeclarator = (node) => {
|
|
10183
10329
|
const parent = node.parent;
|
|
10184
|
-
if (parent.type ===
|
|
10330
|
+
if (parent.type === AST_NODE_TYPES51.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES51.Identifier) {
|
|
10185
10331
|
return parent;
|
|
10186
10332
|
}
|
|
10187
10333
|
return null;
|
|
@@ -10240,7 +10386,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10240
10386
|
});
|
|
10241
10387
|
|
|
10242
10388
|
// src/rules/zod-naming-convention.ts
|
|
10243
|
-
import { AST_NODE_TYPES as
|
|
10389
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
10244
10390
|
var CONVENTIONS = {
|
|
10245
10391
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10246
10392
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10265,15 +10411,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10265
10411
|
"registry",
|
|
10266
10412
|
"implement"
|
|
10267
10413
|
]);
|
|
10268
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10414
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES52.Identifier ? callee.property.name : null;
|
|
10269
10415
|
var calleeChainStartsWithZ = (node) => {
|
|
10270
10416
|
let current = node;
|
|
10271
|
-
while (current.type ===
|
|
10417
|
+
while (current.type === AST_NODE_TYPES52.MemberExpression) {
|
|
10272
10418
|
const receiver = current.object;
|
|
10273
|
-
if (receiver.type ===
|
|
10419
|
+
if (receiver.type === AST_NODE_TYPES52.Identifier && receiver.name === "z") {
|
|
10274
10420
|
return true;
|
|
10275
10421
|
}
|
|
10276
|
-
if (receiver.type ===
|
|
10422
|
+
if (receiver.type === AST_NODE_TYPES52.CallExpression) {
|
|
10277
10423
|
current = receiver.callee;
|
|
10278
10424
|
continue;
|
|
10279
10425
|
}
|
|
@@ -10318,13 +10464,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10318
10464
|
VariableDeclarator(node) {
|
|
10319
10465
|
const init = node.init;
|
|
10320
10466
|
if (init === null || init === void 0) return;
|
|
10321
|
-
if (init.type !==
|
|
10467
|
+
if (init.type !== AST_NODE_TYPES52.CallExpression) return;
|
|
10322
10468
|
const callee = init.callee;
|
|
10323
|
-
if (callee.type !==
|
|
10469
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression) return;
|
|
10324
10470
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10325
10471
|
const terminal = terminalMethodName(callee);
|
|
10326
10472
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10327
|
-
if (node.id.type !==
|
|
10473
|
+
if (node.id.type !== AST_NODE_TYPES52.Identifier) return;
|
|
10328
10474
|
if (test.test(node.id.name)) return;
|
|
10329
10475
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10330
10476
|
context.report({
|
|
@@ -10436,6 +10582,7 @@ var rules = {
|
|
|
10436
10582
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10437
10583
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10438
10584
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10585
|
+
"prefer-immutable-module-constant": prefer_immutable_module_constant_default,
|
|
10439
10586
|
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
10440
10587
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10441
10588
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
@@ -10459,7 +10606,7 @@ var rules = {
|
|
|
10459
10606
|
};
|
|
10460
10607
|
var meta = {
|
|
10461
10608
|
name: "@sarj/eslint-plugin",
|
|
10462
|
-
version: "9.
|
|
10609
|
+
version: "9.13.1"
|
|
10463
10610
|
};
|
|
10464
10611
|
var applicationOnlyRules = [
|
|
10465
10612
|
"no-restricted-library-load",
|
|
@@ -10504,6 +10651,7 @@ var recommendedRules = {
|
|
|
10504
10651
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10505
10652
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10506
10653
|
"@sarj/prefer-input-group-search": "error",
|
|
10654
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10507
10655
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10508
10656
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10509
10657
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10565,6 +10713,7 @@ var strictRules = {
|
|
|
10565
10713
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10566
10714
|
"@sarj/prefer-discriminated-union": "error",
|
|
10567
10715
|
"@sarj/prefer-input-group-search": "error",
|
|
10716
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10568
10717
|
"@sarj/prefer-module-level-constant": "error",
|
|
10569
10718
|
"@sarj/prefer-module-level-schema": "error",
|
|
10570
10719
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10615,4 +10764,3 @@ export {
|
|
|
10615
10764
|
rules,
|
|
10616
10765
|
strictRules
|
|
10617
10766
|
};
|
|
10618
|
-
//# sourceMappingURL=index.js.map
|