@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.cjs
CHANGED
|
@@ -683,7 +683,7 @@ var CODE_KEYWORD_RE = /^(import |export |const |let |var |function\b|class |inte
|
|
|
683
683
|
var CODE_TAIL_RE = /[;{}()]\s*$|=>\s*$|,\s*$/;
|
|
684
684
|
var ASSIGN_RE = /^[A-Za-z_$][\w.$[\]]*\s*(?:=(?![=>])|\+=|-=|\*=)\s*\S.*[;)}\]]\s*$/;
|
|
685
685
|
var CALL_RE = /^[A-Za-z_$][\w.$]*\([^)]*\)\s*;?\s*$/;
|
|
686
|
-
var ASSERTION_CODE_RE = /^(?:await\s+)?(?:expect(?:TypeOf)
|
|
686
|
+
var ASSERTION_CODE_RE = /^(?:await\s+)?(?:expect(?:TypeOf)?|assert(?:\.\w+)?)\s*\(/;
|
|
687
687
|
var PSEUDOCODE_RE = /%\w+%|\[opt\]|(?:^|\s)<[A-Za-z]\w*>|…|\.\.\./;
|
|
688
688
|
function stripCommentMarker(line) {
|
|
689
689
|
return line.replace(/^\s*\/{1,2}/, "").replace(/^\s*\*+/, "").trim();
|
|
@@ -6747,8 +6747,154 @@ var prefer_input_group_search_default = createRule({
|
|
|
6747
6747
|
}
|
|
6748
6748
|
});
|
|
6749
6749
|
|
|
6750
|
-
// src/rules/prefer-
|
|
6750
|
+
// src/rules/prefer-immutable-module-constant.ts
|
|
6751
6751
|
var import_utils49 = require("@typescript-eslint/utils");
|
|
6752
|
+
var CONSTANT_NAME = /^_?[A-Z][A-Z0-9_]*$/;
|
|
6753
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
6754
|
+
"add",
|
|
6755
|
+
"clear",
|
|
6756
|
+
"copyWithin",
|
|
6757
|
+
"delete",
|
|
6758
|
+
"fill",
|
|
6759
|
+
"pop",
|
|
6760
|
+
"push",
|
|
6761
|
+
"reverse",
|
|
6762
|
+
"set",
|
|
6763
|
+
"shift",
|
|
6764
|
+
"sort",
|
|
6765
|
+
"splice",
|
|
6766
|
+
"unshift"
|
|
6767
|
+
]);
|
|
6768
|
+
function isAsConst(node, sourceText) {
|
|
6769
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6770
|
+
return isAsConst(node.expression, sourceText);
|
|
6771
|
+
}
|
|
6772
|
+
return node.type === import_utils49.AST_NODE_TYPES.TSAsExpression && sourceText(node.typeAnnotation).trim() === "const";
|
|
6773
|
+
}
|
|
6774
|
+
function unwrapExpression(node) {
|
|
6775
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSAsExpression || node.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6776
|
+
return unwrapExpression(node.expression);
|
|
6777
|
+
}
|
|
6778
|
+
return node;
|
|
6779
|
+
}
|
|
6780
|
+
function isObjectFreeze(node, isUnshadowedGlobal) {
|
|
6781
|
+
const inner = unwrapExpression(node);
|
|
6782
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1) {
|
|
6783
|
+
const argument = inner.arguments[0];
|
|
6784
|
+
return argument !== void 0 && argument.type !== import_utils49.AST_NODE_TYPES.SpreadElement && collectionKind(argument, isUnshadowedGlobal) === "literal";
|
|
6785
|
+
}
|
|
6786
|
+
return false;
|
|
6787
|
+
}
|
|
6788
|
+
function collectionKind(node, isUnshadowedGlobal) {
|
|
6789
|
+
const inner = unwrapExpression(node);
|
|
6790
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && isUnshadowedGlobal(inner.callee.object) && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils49.AST_NODE_TYPES.SpreadElement) {
|
|
6791
|
+
return collectionKind(inner.arguments[0], isUnshadowedGlobal);
|
|
6792
|
+
}
|
|
6793
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.ArrayExpression || inner.type === import_utils49.AST_NODE_TYPES.ObjectExpression) {
|
|
6794
|
+
return "literal";
|
|
6795
|
+
}
|
|
6796
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.NewExpression && inner.callee.type === import_utils49.AST_NODE_TYPES.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map") && isUnshadowedGlobal(inner.callee)) {
|
|
6797
|
+
return inner.callee.name;
|
|
6798
|
+
}
|
|
6799
|
+
return null;
|
|
6800
|
+
}
|
|
6801
|
+
function isReadonlyType(node, kind) {
|
|
6802
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSTypeOperator && node.operator === "readonly") {
|
|
6803
|
+
return true;
|
|
6804
|
+
}
|
|
6805
|
+
if (node.type !== import_utils49.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
6806
|
+
return false;
|
|
6807
|
+
}
|
|
6808
|
+
if (node.typeName.name === "Readonly") {
|
|
6809
|
+
return kind === "literal";
|
|
6810
|
+
}
|
|
6811
|
+
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6812
|
+
}
|
|
6813
|
+
function declaredReadonlyType(node, kind) {
|
|
6814
|
+
const annotation = node.id.type === import_utils49.AST_NODE_TYPES.Identifier ? node.id.typeAnnotation : void 0;
|
|
6815
|
+
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6816
|
+
return true;
|
|
6817
|
+
}
|
|
6818
|
+
return node.init?.type === import_utils49.AST_NODE_TYPES.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6819
|
+
}
|
|
6820
|
+
function referenceMutates(identifier) {
|
|
6821
|
+
let member = identifier.parent;
|
|
6822
|
+
if (member?.type !== import_utils49.AST_NODE_TYPES.MemberExpression || member.object !== identifier) {
|
|
6823
|
+
return member?.type === import_utils49.AST_NODE_TYPES.CallExpression && member.arguments[0] === identifier && member.callee.type === import_utils49.AST_NODE_TYPES.MemberExpression && !member.callee.computed && member.callee.object.type === import_utils49.AST_NODE_TYPES.Identifier && member.callee.object.name === "Object" && member.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && member.callee.property.name === "assign";
|
|
6824
|
+
}
|
|
6825
|
+
while (member.parent.type === import_utils49.AST_NODE_TYPES.MemberExpression && member.parent.object === member) {
|
|
6826
|
+
member = member.parent;
|
|
6827
|
+
}
|
|
6828
|
+
const parent = member.parent;
|
|
6829
|
+
if (parent?.type === import_utils49.AST_NODE_TYPES.AssignmentExpression && parent.left === member) {
|
|
6830
|
+
return true;
|
|
6831
|
+
}
|
|
6832
|
+
if (parent?.type === import_utils49.AST_NODE_TYPES.UpdateExpression && parent.argument === member) {
|
|
6833
|
+
return true;
|
|
6834
|
+
}
|
|
6835
|
+
if (parent?.type === import_utils49.AST_NODE_TYPES.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6836
|
+
return true;
|
|
6837
|
+
}
|
|
6838
|
+
return parent?.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.callee === member && member.property.type === import_utils49.AST_NODE_TYPES.Identifier && MUTATING_METHODS.has(member.property.name);
|
|
6839
|
+
}
|
|
6840
|
+
var prefer_immutable_module_constant_default = createRule({
|
|
6841
|
+
name: "prefer-immutable-module-constant",
|
|
6842
|
+
meta: {
|
|
6843
|
+
type: "suggestion",
|
|
6844
|
+
docs: {
|
|
6845
|
+
description: "Require module-level constant collections to expose readonly state."
|
|
6846
|
+
},
|
|
6847
|
+
schema: [],
|
|
6848
|
+
messages: {
|
|
6849
|
+
preferAsConst: "Module constant `{{name}}` is a mutable literal. Add `as const` or use `Object.freeze` so consumers cannot mutate shared state.",
|
|
6850
|
+
preferReadonlyCollection: "Module constant `{{name}}` is a mutable {{kind}}. Expose it as `Readonly{{kind}}` or an immutable collection."
|
|
6851
|
+
}
|
|
6852
|
+
},
|
|
6853
|
+
defaultOptions: [],
|
|
6854
|
+
create(context) {
|
|
6855
|
+
const sourceCode = context.sourceCode;
|
|
6856
|
+
const isUnshadowedGlobal = (identifier) => {
|
|
6857
|
+
const variable = import_utils49.ASTUtils.findVariable(sourceCode.getScope(identifier), identifier.name);
|
|
6858
|
+
return variable === null || variable.defs.length === 0;
|
|
6859
|
+
};
|
|
6860
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
6861
|
+
return {};
|
|
6862
|
+
}
|
|
6863
|
+
return {
|
|
6864
|
+
VariableDeclarator(node) {
|
|
6865
|
+
const declaration = node.parent;
|
|
6866
|
+
if (declaration.type !== import_utils49.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || node.id.type !== import_utils49.AST_NODE_TYPES.Identifier || node.init === null || !CONSTANT_NAME.test(node.id.name)) {
|
|
6867
|
+
return;
|
|
6868
|
+
}
|
|
6869
|
+
const container = declaration.parent;
|
|
6870
|
+
if (container.type !== import_utils49.AST_NODE_TYPES.Program && !(container.type === import_utils49.AST_NODE_TYPES.ExportNamedDeclaration && container.parent.type === import_utils49.AST_NODE_TYPES.Program)) {
|
|
6871
|
+
return;
|
|
6872
|
+
}
|
|
6873
|
+
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init, isUnshadowedGlobal)) {
|
|
6874
|
+
return;
|
|
6875
|
+
}
|
|
6876
|
+
const kind = collectionKind(node.init, isUnshadowedGlobal);
|
|
6877
|
+
if (kind === null || declaredReadonlyType(node, kind)) {
|
|
6878
|
+
return;
|
|
6879
|
+
}
|
|
6880
|
+
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6881
|
+
if (variable?.references.some(
|
|
6882
|
+
(reference) => reference.identifier.type === import_utils49.AST_NODE_TYPES.Identifier && referenceMutates(reference.identifier)
|
|
6883
|
+
) === true) {
|
|
6884
|
+
return;
|
|
6885
|
+
}
|
|
6886
|
+
context.report({
|
|
6887
|
+
node: node.id,
|
|
6888
|
+
messageId: kind === "literal" ? "preferAsConst" : "preferReadonlyCollection",
|
|
6889
|
+
data: { name: node.id.name, kind }
|
|
6890
|
+
});
|
|
6891
|
+
}
|
|
6892
|
+
};
|
|
6893
|
+
}
|
|
6894
|
+
});
|
|
6895
|
+
|
|
6896
|
+
// src/rules/prefer-shadcn-primitives.ts
|
|
6897
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
6752
6898
|
var SHADCN_PRIMITIVES = {
|
|
6753
6899
|
button: "Button",
|
|
6754
6900
|
dialog: "Dialog or AlertDialog family",
|
|
@@ -6769,15 +6915,15 @@ var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
6769
6915
|
"textarea"
|
|
6770
6916
|
]);
|
|
6771
6917
|
function rawElementName(node) {
|
|
6772
|
-
if (node.name.type !==
|
|
6918
|
+
if (node.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier) return null;
|
|
6773
6919
|
const name = node.name.name;
|
|
6774
6920
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6775
6921
|
}
|
|
6776
6922
|
function staticExpressionString(expression) {
|
|
6777
|
-
if (expression.type ===
|
|
6923
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.Literal) {
|
|
6778
6924
|
return typeof expression.value === "string" ? expression.value : null;
|
|
6779
6925
|
}
|
|
6780
|
-
if (expression.type ===
|
|
6926
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.TemplateLiteral) {
|
|
6781
6927
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6782
6928
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6783
6929
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -6787,24 +6933,24 @@ function staticExpressionString(expression) {
|
|
|
6787
6933
|
}
|
|
6788
6934
|
return value;
|
|
6789
6935
|
}
|
|
6790
|
-
if (expression.type ===
|
|
6936
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils50.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils50.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils50.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6791
6937
|
return staticExpressionString(expression.expression);
|
|
6792
6938
|
}
|
|
6793
6939
|
return null;
|
|
6794
6940
|
}
|
|
6795
6941
|
function staticString(value) {
|
|
6796
|
-
if (value?.type ===
|
|
6942
|
+
if (value?.type === import_utils50.AST_NODE_TYPES.Literal) {
|
|
6797
6943
|
return typeof value.value === "string" ? value.value : null;
|
|
6798
6944
|
}
|
|
6799
|
-
if (value?.type !==
|
|
6945
|
+
if (value?.type !== import_utils50.AST_NODE_TYPES.JSXExpressionContainer) return null;
|
|
6800
6946
|
return staticExpressionString(value.expression);
|
|
6801
6947
|
}
|
|
6802
6948
|
function effectiveAttribute(node, attributeName) {
|
|
6803
6949
|
for (const attribute of node.attributes.toReversed()) {
|
|
6804
|
-
if (attribute.type ===
|
|
6950
|
+
if (attribute.type === import_utils50.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
6805
6951
|
return { kind: "unknown" };
|
|
6806
6952
|
}
|
|
6807
|
-
if (attribute.name.type !==
|
|
6953
|
+
if (attribute.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6808
6954
|
continue;
|
|
6809
6955
|
}
|
|
6810
6956
|
const value = staticString(attribute.value);
|
|
@@ -6813,7 +6959,7 @@ function effectiveAttribute(node, attributeName) {
|
|
|
6813
6959
|
return { kind: "missing" };
|
|
6814
6960
|
}
|
|
6815
6961
|
function isLabelableElement(node) {
|
|
6816
|
-
if (node.openingElement.name.type !==
|
|
6962
|
+
if (node.openingElement.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier) {
|
|
6817
6963
|
return false;
|
|
6818
6964
|
}
|
|
6819
6965
|
const name = node.openingElement.name.name;
|
|
@@ -6825,10 +6971,10 @@ function isLabelableElement(node) {
|
|
|
6825
6971
|
}
|
|
6826
6972
|
function containsLabelableElement(node) {
|
|
6827
6973
|
return node.children.some((child) => {
|
|
6828
|
-
if (child.type ===
|
|
6974
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXElement) {
|
|
6829
6975
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6830
6976
|
}
|
|
6831
|
-
if (child.type ===
|
|
6977
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXFragment) {
|
|
6832
6978
|
return containsLabelableElement(child);
|
|
6833
6979
|
}
|
|
6834
6980
|
return false;
|
|
@@ -6837,7 +6983,7 @@ function containsLabelableElement(node) {
|
|
|
6837
6983
|
function isStaticallyAssociatedLabel(node) {
|
|
6838
6984
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6839
6985
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6840
|
-
return node.parent.type ===
|
|
6986
|
+
return node.parent.type === import_utils50.AST_NODE_TYPES.JSXElement && containsLabelableElement(node.parent);
|
|
6841
6987
|
}
|
|
6842
6988
|
function replacementFor(node, element) {
|
|
6843
6989
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -6881,7 +7027,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
6881
7027
|
});
|
|
6882
7028
|
|
|
6883
7029
|
// src/rules/prefer-module-level-constant.ts
|
|
6884
|
-
var
|
|
7030
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
6885
7031
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6886
7032
|
var MAX_LITERAL_DEPTH = 4;
|
|
6887
7033
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6890,7 +7036,7 @@ var IGNORE_PATTERNS2 = [
|
|
|
6890
7036
|
/\.generated\.tsx?$/,
|
|
6891
7037
|
/\.d\.ts$/
|
|
6892
7038
|
];
|
|
6893
|
-
var
|
|
7039
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
6894
7040
|
// Array
|
|
6895
7041
|
"push",
|
|
6896
7042
|
"pop",
|
|
@@ -6910,9 +7056,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6910
7056
|
"assign"
|
|
6911
7057
|
]);
|
|
6912
7058
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
7059
|
+
import_utils51.AST_NODE_TYPES.FunctionDeclaration,
|
|
7060
|
+
import_utils51.AST_NODE_TYPES.FunctionExpression,
|
|
7061
|
+
import_utils51.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6916
7062
|
]);
|
|
6917
7063
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6918
7064
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6925,14 +7071,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6925
7071
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6926
7072
|
}
|
|
6927
7073
|
function unwrap3(node) {
|
|
6928
|
-
if (node.type ===
|
|
7074
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSAsExpression || node.type === import_utils51.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils51.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6929
7075
|
return unwrap3(node.expression);
|
|
6930
7076
|
}
|
|
6931
7077
|
return node;
|
|
6932
7078
|
}
|
|
6933
7079
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6934
7080
|
function isRegexLiteral(node) {
|
|
6935
|
-
return node.type ===
|
|
7081
|
+
return node.type === import_utils51.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6936
7082
|
}
|
|
6937
7083
|
function isLiteralOnly(node, depth) {
|
|
6938
7084
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6940,29 +7086,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6940
7086
|
}
|
|
6941
7087
|
const inner = unwrap3(node);
|
|
6942
7088
|
switch (inner.type) {
|
|
6943
|
-
case
|
|
7089
|
+
case import_utils51.AST_NODE_TYPES.Literal: {
|
|
6944
7090
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6945
7091
|
}
|
|
6946
|
-
case
|
|
7092
|
+
case import_utils51.AST_NODE_TYPES.TemplateLiteral: {
|
|
6947
7093
|
return inner.expressions.length === 0;
|
|
6948
7094
|
}
|
|
6949
|
-
case
|
|
6950
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
7095
|
+
case import_utils51.AST_NODE_TYPES.UnaryExpression: {
|
|
7096
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils51.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6951
7097
|
}
|
|
6952
|
-
case
|
|
7098
|
+
case import_utils51.AST_NODE_TYPES.ArrayExpression: {
|
|
6953
7099
|
return inner.elements.every(
|
|
6954
|
-
(el) => el !== null && el.type !==
|
|
7100
|
+
(el) => el !== null && el.type !== import_utils51.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6955
7101
|
);
|
|
6956
7102
|
}
|
|
6957
|
-
case
|
|
7103
|
+
case import_utils51.AST_NODE_TYPES.ObjectExpression: {
|
|
6958
7104
|
return inner.properties.every((prop) => {
|
|
6959
|
-
if (prop.type !==
|
|
7105
|
+
if (prop.type !== import_utils51.AST_NODE_TYPES.Property) {
|
|
6960
7106
|
return false;
|
|
6961
7107
|
}
|
|
6962
7108
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6963
7109
|
return false;
|
|
6964
7110
|
}
|
|
6965
|
-
if (prop.computed && prop.key.type !==
|
|
7111
|
+
if (prop.computed && prop.key.type !== import_utils51.AST_NODE_TYPES.Literal) {
|
|
6966
7112
|
return false;
|
|
6967
7113
|
}
|
|
6968
7114
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6975,7 +7121,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6975
7121
|
}
|
|
6976
7122
|
function unwrapObjectFreeze(node) {
|
|
6977
7123
|
const inner = unwrap3(node);
|
|
6978
|
-
if (inner.type ===
|
|
7124
|
+
if (inner.type === import_utils51.AST_NODE_TYPES.CallExpression && inner.callee.type === import_utils51.AST_NODE_TYPES.MemberExpression && !inner.callee.computed && inner.callee.object.type === import_utils51.AST_NODE_TYPES.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === import_utils51.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
6979
7125
|
return unwrap3(inner.arguments[0]);
|
|
6980
7126
|
}
|
|
6981
7127
|
return inner;
|
|
@@ -6991,19 +7137,19 @@ function classify(init, checkRegex) {
|
|
|
6991
7137
|
}
|
|
6992
7138
|
return { kind: "regex", size: 1 };
|
|
6993
7139
|
}
|
|
6994
|
-
if (node.type ===
|
|
7140
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ArrayExpression) {
|
|
6995
7141
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6996
7142
|
}
|
|
6997
|
-
if (node.type ===
|
|
7143
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ObjectExpression) {
|
|
6998
7144
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6999
7145
|
}
|
|
7000
|
-
if (node.type ===
|
|
7146
|
+
if (node.type === import_utils51.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils51.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
7001
7147
|
const arg = node.arguments[0];
|
|
7002
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
7148
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
7003
7149
|
return null;
|
|
7004
7150
|
}
|
|
7005
7151
|
const entries = unwrap3(arg);
|
|
7006
|
-
if (entries.type !==
|
|
7152
|
+
if (entries.type !== import_utils51.AST_NODE_TYPES.ArrayExpression) {
|
|
7007
7153
|
return null;
|
|
7008
7154
|
}
|
|
7009
7155
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -7032,10 +7178,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
7032
7178
|
);
|
|
7033
7179
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
7034
7180
|
const callee = node.callee;
|
|
7035
|
-
if (callee.type ===
|
|
7181
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
7036
7182
|
return true;
|
|
7037
7183
|
}
|
|
7038
|
-
if (callee.type !==
|
|
7184
|
+
if (callee.type !== import_utils51.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils51.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7039
7185
|
return false;
|
|
7040
7186
|
}
|
|
7041
7187
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -7049,38 +7195,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
7049
7195
|
}
|
|
7050
7196
|
function isSafeRead(identifier) {
|
|
7051
7197
|
const parent = identifier.parent;
|
|
7052
|
-
if (parent.type ===
|
|
7198
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
7053
7199
|
if (parent.object !== identifier) {
|
|
7054
7200
|
return true;
|
|
7055
7201
|
}
|
|
7056
7202
|
const grandparent = parent.parent;
|
|
7057
|
-
if (grandparent.type ===
|
|
7203
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
7058
7204
|
return false;
|
|
7059
7205
|
}
|
|
7060
|
-
if (grandparent.type ===
|
|
7206
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.UpdateExpression) {
|
|
7061
7207
|
return false;
|
|
7062
7208
|
}
|
|
7063
|
-
if (grandparent.type ===
|
|
7209
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
7064
7210
|
return false;
|
|
7065
7211
|
}
|
|
7066
|
-
if (!parent.computed && parent.property.type ===
|
|
7212
|
+
if (!parent.computed && parent.property.type === import_utils51.AST_NODE_TYPES.Identifier && MUTATING_METHODS2.has(parent.property.name) && grandparent.type === import_utils51.AST_NODE_TYPES.CallExpression && grandparent.callee === parent) {
|
|
7067
7213
|
return false;
|
|
7068
7214
|
}
|
|
7069
7215
|
return true;
|
|
7070
7216
|
}
|
|
7071
|
-
if (parent.type ===
|
|
7217
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
7072
7218
|
return true;
|
|
7073
7219
|
}
|
|
7074
|
-
if (parent.type ===
|
|
7220
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
7075
7221
|
return true;
|
|
7076
7222
|
}
|
|
7077
|
-
if (parent.type ===
|
|
7223
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.BinaryExpression) {
|
|
7078
7224
|
return true;
|
|
7079
7225
|
}
|
|
7080
|
-
if (parent.type ===
|
|
7226
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
7081
7227
|
return true;
|
|
7082
7228
|
}
|
|
7083
|
-
if (parent.type ===
|
|
7229
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
7084
7230
|
return true;
|
|
7085
7231
|
}
|
|
7086
7232
|
return false;
|
|
@@ -7104,7 +7250,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7104
7250
|
}
|
|
7105
7251
|
],
|
|
7106
7252
|
messages: {
|
|
7107
|
-
hoistCollection: "`{{name}}` is a literal-only {{kind}} rebuilt on every call. Hoist it to module scope so it is allocated once
|
|
7253
|
+
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.",
|
|
7108
7254
|
hoistRegex: "`{{name}}` is a constant regex recompiled on every call. Hoist it to module scope."
|
|
7109
7255
|
}
|
|
7110
7256
|
},
|
|
@@ -7135,7 +7281,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7135
7281
|
if (reference.isWrite()) {
|
|
7136
7282
|
return false;
|
|
7137
7283
|
}
|
|
7138
|
-
if (reference.identifier.type !==
|
|
7284
|
+
if (reference.identifier.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7139
7285
|
return false;
|
|
7140
7286
|
}
|
|
7141
7287
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7147,10 +7293,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7147
7293
|
return {
|
|
7148
7294
|
VariableDeclarator(node) {
|
|
7149
7295
|
const declaration = node.parent;
|
|
7150
|
-
if (declaration.type !==
|
|
7296
|
+
if (declaration.type !== import_utils51.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7151
7297
|
return;
|
|
7152
7298
|
}
|
|
7153
|
-
if (node.id.type !==
|
|
7299
|
+
if (node.id.type !== import_utils51.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
7154
7300
|
return;
|
|
7155
7301
|
}
|
|
7156
7302
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7177,7 +7323,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7177
7323
|
});
|
|
7178
7324
|
|
|
7179
7325
|
// src/rules/prefer-module-level-schema.ts
|
|
7180
|
-
var
|
|
7326
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7181
7327
|
|
|
7182
7328
|
// src/rules/_zod.ts
|
|
7183
7329
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7243,9 +7389,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7243
7389
|
"intl"
|
|
7244
7390
|
]);
|
|
7245
7391
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7392
|
+
import_utils52.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
7393
|
+
import_utils52.AST_NODE_TYPES.FunctionDeclaration,
|
|
7394
|
+
import_utils52.AST_NODE_TYPES.FunctionExpression
|
|
7249
7395
|
]);
|
|
7250
7396
|
function schemaExpression(node) {
|
|
7251
7397
|
let current = node;
|
|
@@ -7254,10 +7400,10 @@ function schemaExpression(node) {
|
|
|
7254
7400
|
if (parent === void 0) {
|
|
7255
7401
|
return current;
|
|
7256
7402
|
}
|
|
7257
|
-
if (parent.type ===
|
|
7403
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.computed && parent.property.type === import_utils52.AST_NODE_TYPES.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
7258
7404
|
return current;
|
|
7259
7405
|
}
|
|
7260
|
-
if (parent.type ===
|
|
7406
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.MemberExpression && parent.object === current || parent.type === import_utils52.AST_NODE_TYPES.CallExpression && parent.callee === current || parent.type === import_utils52.AST_NODE_TYPES.TSAsExpression && parent.expression === current || parent.type === import_utils52.AST_NODE_TYPES.TSNonNullExpression && parent.expression === current) {
|
|
7261
7407
|
current = parent;
|
|
7262
7408
|
continue;
|
|
7263
7409
|
}
|
|
@@ -7308,22 +7454,22 @@ function subtreeSome(root, predicate) {
|
|
|
7308
7454
|
function readsReceiver(node) {
|
|
7309
7455
|
return subtreeSome(
|
|
7310
7456
|
node,
|
|
7311
|
-
(inner) => inner.type ===
|
|
7457
|
+
(inner) => inner.type === import_utils52.AST_NODE_TYPES.ThisExpression || inner.type === import_utils52.AST_NODE_TYPES.Super || inner.type === import_utils52.AST_NODE_TYPES.Identifier && inner.name === "arguments"
|
|
7312
7458
|
);
|
|
7313
7459
|
}
|
|
7314
7460
|
function buildsLocalizedText(node) {
|
|
7315
7461
|
return subtreeSome(node, (inner) => {
|
|
7316
|
-
if (inner.type ===
|
|
7462
|
+
if (inner.type === import_utils52.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
7317
7463
|
return true;
|
|
7318
7464
|
}
|
|
7319
|
-
if (inner.type !==
|
|
7465
|
+
if (inner.type !== import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7320
7466
|
return false;
|
|
7321
7467
|
}
|
|
7322
7468
|
const { callee } = inner;
|
|
7323
|
-
if (callee.type ===
|
|
7469
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7324
7470
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7325
7471
|
}
|
|
7326
|
-
return callee.type ===
|
|
7472
|
+
return callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils52.AST_NODE_TYPES.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7327
7473
|
});
|
|
7328
7474
|
}
|
|
7329
7475
|
function collectReferences(scope, out) {
|
|
@@ -7380,15 +7526,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7380
7526
|
}
|
|
7381
7527
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7382
7528
|
function isZodCall(node) {
|
|
7383
|
-
return node.type ===
|
|
7529
|
+
return node.type === import_utils52.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && !node.callee.computed && node.callee.object.type === import_utils52.AST_NODE_TYPES.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7384
7530
|
}
|
|
7385
7531
|
function isCovered(node) {
|
|
7386
7532
|
let current = node.parent ?? void 0;
|
|
7387
7533
|
while (current !== void 0) {
|
|
7388
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7534
|
+
if (current !== node && isZodCall(current) && current.callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && current.callee.property.type === import_utils52.AST_NODE_TYPES.Identifier && factories.has(current.callee.property.name)) {
|
|
7389
7535
|
return true;
|
|
7390
7536
|
}
|
|
7391
|
-
if (current.type ===
|
|
7537
|
+
if (current.type === import_utils52.AST_NODE_TYPES.CallExpression && (current.callee.type === import_utils52.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && !current.callee.computed && current.callee.property.type === import_utils52.AST_NODE_TYPES.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7392
7538
|
return true;
|
|
7393
7539
|
}
|
|
7394
7540
|
current = current.parent ?? void 0;
|
|
@@ -7403,11 +7549,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7403
7549
|
if (parent === void 0) {
|
|
7404
7550
|
return confirmed;
|
|
7405
7551
|
}
|
|
7406
|
-
if (parent.type ===
|
|
7552
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.Property && parent.value === current || parent.type === import_utils52.AST_NODE_TYPES.ObjectExpression || parent.type === import_utils52.AST_NODE_TYPES.ArrayExpression) {
|
|
7407
7553
|
current = parent;
|
|
7408
7554
|
continue;
|
|
7409
7555
|
}
|
|
7410
|
-
if (parent.type ===
|
|
7556
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7411
7557
|
current = schemaExpression(parent);
|
|
7412
7558
|
confirmed = current;
|
|
7413
7559
|
continue;
|
|
@@ -7417,7 +7563,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7417
7563
|
}
|
|
7418
7564
|
function isSchemaComposition(node) {
|
|
7419
7565
|
const { callee } = node;
|
|
7420
|
-
const isCombinator = callee.type ===
|
|
7566
|
+
const isCombinator = callee.type === import_utils52.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils52.AST_NODE_TYPES.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7421
7567
|
return isCombinator || isZodCall(node);
|
|
7422
7568
|
}
|
|
7423
7569
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7451,13 +7597,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7451
7597
|
}
|
|
7452
7598
|
function ownerName(enclosing) {
|
|
7453
7599
|
const parent = enclosing.parent ?? void 0;
|
|
7454
|
-
if (enclosing.type ===
|
|
7600
|
+
if (enclosing.type === import_utils52.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7455
7601
|
return enclosing.id.name;
|
|
7456
7602
|
}
|
|
7457
|
-
if (parent !== void 0 && parent.type ===
|
|
7603
|
+
if (parent !== void 0 && parent.type === import_utils52.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7458
7604
|
return parent.id.name;
|
|
7459
7605
|
}
|
|
7460
|
-
if (parent !== void 0 && (parent.type ===
|
|
7606
|
+
if (parent !== void 0 && (parent.type === import_utils52.AST_NODE_TYPES.MethodDefinition || parent.type === import_utils52.AST_NODE_TYPES.Property) && parent.key.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7461
7607
|
return parent.key.name;
|
|
7462
7608
|
}
|
|
7463
7609
|
return "this function";
|
|
@@ -7468,7 +7614,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7468
7614
|
return;
|
|
7469
7615
|
}
|
|
7470
7616
|
for (const specifier of node.specifiers) {
|
|
7471
|
-
if (specifier.type ===
|
|
7617
|
+
if (specifier.type === import_utils52.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils52.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils52.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils52.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
7472
7618
|
zodNamespaces.add(specifier.local.name);
|
|
7473
7619
|
}
|
|
7474
7620
|
}
|
|
@@ -7478,7 +7624,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7478
7624
|
return;
|
|
7479
7625
|
}
|
|
7480
7626
|
const callee = node.callee;
|
|
7481
|
-
if (callee.property.type !==
|
|
7627
|
+
if (callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7482
7628
|
return;
|
|
7483
7629
|
}
|
|
7484
7630
|
const factory = callee.property.name;
|
|
@@ -7493,7 +7639,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7493
7639
|
return;
|
|
7494
7640
|
}
|
|
7495
7641
|
const shape = node.arguments[0];
|
|
7496
|
-
if (shape !== void 0 && shape.type ===
|
|
7642
|
+
if (shape !== void 0 && shape.type === import_utils52.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7497
7643
|
return;
|
|
7498
7644
|
}
|
|
7499
7645
|
const expression = schemaExpression(node);
|
|
@@ -7521,9 +7667,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7521
7667
|
});
|
|
7522
7668
|
|
|
7523
7669
|
// src/rules/prefer-native-random-uuid.ts
|
|
7524
|
-
var
|
|
7670
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7525
7671
|
function requireUuid(node) {
|
|
7526
|
-
return node?.type ===
|
|
7672
|
+
return node?.type === import_utils53.AST_NODE_TYPES.CallExpression && node.callee.type === import_utils53.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === import_utils53.AST_NODE_TYPES.Literal && node.arguments[0].value === "uuid";
|
|
7527
7673
|
}
|
|
7528
7674
|
var prefer_native_random_uuid_default = createRule({
|
|
7529
7675
|
name: "prefer-native-random-uuid",
|
|
@@ -7544,7 +7690,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7544
7690
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7545
7691
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7546
7692
|
function resolve(identifier) {
|
|
7547
|
-
return
|
|
7693
|
+
return import_utils53.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7548
7694
|
}
|
|
7549
7695
|
function record(identifier, destination) {
|
|
7550
7696
|
const variable = resolve(identifier);
|
|
@@ -7566,37 +7712,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7566
7712
|
ImportDeclaration(node) {
|
|
7567
7713
|
if (node.source.value !== "uuid") return;
|
|
7568
7714
|
for (const specifier of node.specifiers) {
|
|
7569
|
-
if (specifier.type ===
|
|
7715
|
+
if (specifier.type === import_utils53.AST_NODE_TYPES.ImportSpecifier && (specifier.imported.type === import_utils53.AST_NODE_TYPES.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7570
7716
|
record(specifier.local, directBindings);
|
|
7571
|
-
} else if (specifier.type ===
|
|
7717
|
+
} else if (specifier.type === import_utils53.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7572
7718
|
record(specifier.local, namespaceBindings);
|
|
7573
7719
|
}
|
|
7574
7720
|
}
|
|
7575
7721
|
},
|
|
7576
7722
|
VariableDeclarator(node) {
|
|
7577
7723
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7578
|
-
if (node.init?.type !==
|
|
7724
|
+
if (node.init?.type !== import_utils53.AST_NODE_TYPES.CallExpression || node.init.callee.type !== import_utils53.AST_NODE_TYPES.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7579
7725
|
return;
|
|
7580
7726
|
}
|
|
7581
|
-
if (node.id.type ===
|
|
7727
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7582
7728
|
record(node.id, namespaceBindings);
|
|
7583
7729
|
return;
|
|
7584
7730
|
}
|
|
7585
|
-
if (node.id.type !==
|
|
7731
|
+
if (node.id.type !== import_utils53.AST_NODE_TYPES.ObjectPattern) return;
|
|
7586
7732
|
for (const property of node.id.properties) {
|
|
7587
|
-
if (property.type ===
|
|
7733
|
+
if (property.type === import_utils53.AST_NODE_TYPES.Property && !property.computed && (property.key.type === import_utils53.AST_NODE_TYPES.Identifier && property.key.name === "v4" || property.key.type === import_utils53.AST_NODE_TYPES.Literal && property.key.value === "v4") && property.value.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7588
7734
|
record(property.value, directBindings);
|
|
7589
7735
|
}
|
|
7590
7736
|
}
|
|
7591
7737
|
},
|
|
7592
7738
|
"CallExpression:exit"(node) {
|
|
7593
7739
|
if (node.arguments.length !== 0) return;
|
|
7594
|
-
if (node.callee.type ===
|
|
7740
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7595
7741
|
const variable2 = resolve(node.callee);
|
|
7596
7742
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7597
7743
|
return;
|
|
7598
7744
|
}
|
|
7599
|
-
if (node.callee.type !==
|
|
7745
|
+
if (node.callee.type !== import_utils53.AST_NODE_TYPES.MemberExpression || node.callee.computed || node.callee.object.type !== import_utils53.AST_NODE_TYPES.Identifier || node.callee.property.type !== import_utils53.AST_NODE_TYPES.Identifier || node.callee.property.name !== "v4") {
|
|
7600
7746
|
return;
|
|
7601
7747
|
}
|
|
7602
7748
|
const variable = resolve(node.callee.object);
|
|
@@ -7607,20 +7753,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7607
7753
|
});
|
|
7608
7754
|
|
|
7609
7755
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7610
|
-
var
|
|
7756
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7611
7757
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7612
7758
|
function propertyName(node) {
|
|
7613
7759
|
const key = node.key;
|
|
7614
|
-
if (key.type ===
|
|
7615
|
-
if (key.type ===
|
|
7760
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Identifier) return key.name;
|
|
7761
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7616
7762
|
return "collection";
|
|
7617
7763
|
}
|
|
7618
7764
|
function isArrayType(node) {
|
|
7619
|
-
if (node.type ===
|
|
7620
|
-
return node.type ===
|
|
7765
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSArrayType) return true;
|
|
7766
|
+
return node.type === import_utils54.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils54.AST_NODE_TYPES.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7621
7767
|
}
|
|
7622
7768
|
function isNullishType(node) {
|
|
7623
|
-
return node.type ===
|
|
7769
|
+
return node.type === import_utils54.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils54.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7624
7770
|
}
|
|
7625
7771
|
function isNullableArrayOnly(node) {
|
|
7626
7772
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7648,7 +7794,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7648
7794
|
if (node.optional) return;
|
|
7649
7795
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7650
7796
|
if (annotation === void 0) return;
|
|
7651
|
-
if (annotation.type !==
|
|
7797
|
+
if (annotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7652
7798
|
return;
|
|
7653
7799
|
}
|
|
7654
7800
|
context.report({
|
|
@@ -7661,7 +7807,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7661
7807
|
TSPropertySignature: checkOptionalProperty,
|
|
7662
7808
|
PropertyDefinition: checkOptionalProperty,
|
|
7663
7809
|
TSTypeAliasDeclaration(node) {
|
|
7664
|
-
if (node.typeAnnotation.type !==
|
|
7810
|
+
if (node.typeAnnotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType) return;
|
|
7665
7811
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7666
7812
|
context.report({
|
|
7667
7813
|
node,
|
|
@@ -7674,13 +7820,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7674
7820
|
});
|
|
7675
7821
|
|
|
7676
7822
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7677
|
-
var
|
|
7823
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
7678
7824
|
var unwrap4 = (node) => {
|
|
7679
7825
|
let current = node;
|
|
7680
7826
|
while (current !== null && current !== void 0) {
|
|
7681
|
-
if (current.type ===
|
|
7827
|
+
if (current.type === import_utils55.AST_NODE_TYPES.TSAsExpression || current.type === import_utils55.AST_NODE_TYPES.TSTypeAssertion || current.type === import_utils55.AST_NODE_TYPES.TSNonNullExpression || current.type === import_utils55.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
7682
7828
|
current = current.expression;
|
|
7683
|
-
} else if (current.type ===
|
|
7829
|
+
} else if (current.type === import_utils55.AST_NODE_TYPES.ChainExpression) {
|
|
7684
7830
|
current = current.expression;
|
|
7685
7831
|
} else {
|
|
7686
7832
|
break;
|
|
@@ -7695,23 +7841,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7695
7841
|
]);
|
|
7696
7842
|
var isSchemaParseReference = (node) => {
|
|
7697
7843
|
const inner = unwrap4(node);
|
|
7698
|
-
return inner !== null && inner.type ===
|
|
7844
|
+
return inner !== null && inner.type === import_utils55.AST_NODE_TYPES.MemberExpression && !inner.computed && inner.property.type === import_utils55.AST_NODE_TYPES.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7699
7845
|
};
|
|
7700
7846
|
var isRawPayloadSource = (node) => {
|
|
7701
7847
|
let current = unwrap4(node);
|
|
7702
7848
|
if (current === null) return false;
|
|
7703
|
-
if (current.type ===
|
|
7849
|
+
if (current.type === import_utils55.AST_NODE_TYPES.AwaitExpression) {
|
|
7704
7850
|
current = unwrap4(current.argument);
|
|
7705
7851
|
}
|
|
7706
|
-
if (current === null || current.type !==
|
|
7852
|
+
if (current === null || current.type !== import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7707
7853
|
return false;
|
|
7708
7854
|
}
|
|
7709
7855
|
const callee = unwrap4(current.callee);
|
|
7710
|
-
if (callee === null || callee.type !==
|
|
7856
|
+
if (callee === null || callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression) {
|
|
7711
7857
|
return false;
|
|
7712
7858
|
}
|
|
7713
7859
|
const property = unwrap4(callee.property);
|
|
7714
|
-
if (property === null || property.type !==
|
|
7860
|
+
if (property === null || property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7715
7861
|
return false;
|
|
7716
7862
|
}
|
|
7717
7863
|
if (property.name === "json") {
|
|
@@ -7721,16 +7867,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7721
7867
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7722
7868
|
}
|
|
7723
7869
|
const object = unwrap4(callee.object);
|
|
7724
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7870
|
+
return property.name === "parse" && object !== null && object.type === import_utils55.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7725
7871
|
};
|
|
7726
7872
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7727
7873
|
var isLocalFileRead = (node) => {
|
|
7728
7874
|
let found = false;
|
|
7729
7875
|
const visit = (current) => {
|
|
7730
7876
|
if (found || current === null || current === void 0) return;
|
|
7731
|
-
if (current.type ===
|
|
7877
|
+
if (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7732
7878
|
const callee = unwrap4(current.callee);
|
|
7733
|
-
const name = callee?.type ===
|
|
7879
|
+
const name = callee?.type === import_utils55.AST_NODE_TYPES.Identifier ? callee.name : callee?.type === import_utils55.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils55.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
7734
7880
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7735
7881
|
found = true;
|
|
7736
7882
|
return;
|
|
@@ -7752,15 +7898,15 @@ var isLocalFileRead = (node) => {
|
|
|
7752
7898
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7753
7899
|
var isInsideAssertion = (node) => {
|
|
7754
7900
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7755
|
-
if (current.type !==
|
|
7901
|
+
if (current.type !== import_utils55.AST_NODE_TYPES.CallExpression) continue;
|
|
7756
7902
|
let callee = current.callee;
|
|
7757
|
-
while (callee.type ===
|
|
7903
|
+
while (callee.type === import_utils55.AST_NODE_TYPES.MemberExpression) {
|
|
7758
7904
|
callee = callee.object;
|
|
7759
7905
|
}
|
|
7760
|
-
if (callee.type ===
|
|
7906
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7761
7907
|
callee = callee.callee;
|
|
7762
7908
|
}
|
|
7763
|
-
if (callee.type ===
|
|
7909
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7764
7910
|
return true;
|
|
7765
7911
|
}
|
|
7766
7912
|
}
|
|
@@ -7779,39 +7925,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7779
7925
|
var isValidationRead = (node) => {
|
|
7780
7926
|
let current = node;
|
|
7781
7927
|
let parent = current.parent;
|
|
7782
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7928
|
+
while (parent !== null && parent !== void 0 && (parent.type === import_utils55.AST_NODE_TYPES.TSAsExpression || parent.type === import_utils55.AST_NODE_TYPES.TSTypeAssertion || parent.type === import_utils55.AST_NODE_TYPES.TSNonNullExpression || parent.type === import_utils55.AST_NODE_TYPES.TSSatisfiesExpression || parent.type === import_utils55.AST_NODE_TYPES.ChainExpression)) {
|
|
7783
7929
|
current = parent;
|
|
7784
7930
|
parent = parent.parent;
|
|
7785
7931
|
}
|
|
7786
7932
|
if (parent === null || parent === void 0) return false;
|
|
7787
|
-
if (parent.type ===
|
|
7933
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7788
7934
|
return true;
|
|
7789
7935
|
}
|
|
7790
|
-
if (parent.type !==
|
|
7936
|
+
if (parent.type !== import_utils55.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7791
7937
|
return false;
|
|
7792
7938
|
}
|
|
7793
7939
|
const callee = parent.callee;
|
|
7794
|
-
if (callee.type ===
|
|
7940
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.object.type === import_utils55.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils55.AST_NODE_TYPES.Identifier && callee.property.name === "isArray") {
|
|
7795
7941
|
return parent.arguments.length === 1;
|
|
7796
7942
|
}
|
|
7797
|
-
return callee.type ===
|
|
7943
|
+
return callee.type === import_utils55.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7798
7944
|
};
|
|
7799
7945
|
var isGuardTestPosition = (node) => {
|
|
7800
7946
|
let current = node;
|
|
7801
7947
|
let parent = current.parent;
|
|
7802
7948
|
while (parent !== void 0 && parent !== null) {
|
|
7803
7949
|
switch (parent.type) {
|
|
7804
|
-
case
|
|
7805
|
-
case
|
|
7806
|
-
case
|
|
7950
|
+
case import_utils55.AST_NODE_TYPES.UnaryExpression:
|
|
7951
|
+
case import_utils55.AST_NODE_TYPES.LogicalExpression:
|
|
7952
|
+
case import_utils55.AST_NODE_TYPES.ChainExpression:
|
|
7807
7953
|
current = parent;
|
|
7808
7954
|
parent = parent.parent;
|
|
7809
7955
|
continue;
|
|
7810
|
-
case
|
|
7811
|
-
case
|
|
7812
|
-
case
|
|
7813
|
-
case
|
|
7814
|
-
case
|
|
7956
|
+
case import_utils55.AST_NODE_TYPES.IfStatement:
|
|
7957
|
+
case import_utils55.AST_NODE_TYPES.ConditionalExpression:
|
|
7958
|
+
case import_utils55.AST_NODE_TYPES.WhileStatement:
|
|
7959
|
+
case import_utils55.AST_NODE_TYPES.DoWhileStatement:
|
|
7960
|
+
case import_utils55.AST_NODE_TYPES.ForStatement:
|
|
7815
7961
|
return parent.test === current;
|
|
7816
7962
|
default:
|
|
7817
7963
|
return false;
|
|
@@ -7821,7 +7967,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7821
7967
|
};
|
|
7822
7968
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7823
7969
|
const unwrapped = unwrap4(node);
|
|
7824
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7970
|
+
if (unwrapped === null || unwrapped.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7825
7971
|
return false;
|
|
7826
7972
|
}
|
|
7827
7973
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7864,11 +8010,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7864
8010
|
return {
|
|
7865
8011
|
VariableDeclarator(node) {
|
|
7866
8012
|
const scope = context.sourceCode.getScope(node);
|
|
7867
|
-
if (node.id.type ===
|
|
8013
|
+
if (node.id.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7868
8014
|
trackInitializer(node);
|
|
7869
8015
|
return;
|
|
7870
8016
|
}
|
|
7871
|
-
if (node.id.type ===
|
|
8017
|
+
if (node.id.type === import_utils55.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils55.AST_NODE_TYPES.ArrayPattern) {
|
|
7872
8018
|
if (isRawPayloadSource(node.init)) {
|
|
7873
8019
|
if (!isFullyNarrowedPattern(node)) {
|
|
7874
8020
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7882,7 +8028,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7882
8028
|
},
|
|
7883
8029
|
AssignmentExpression(node) {
|
|
7884
8030
|
const scope = context.sourceCode.getScope(node);
|
|
7885
|
-
if (node.left.type ===
|
|
8031
|
+
if (node.left.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7886
8032
|
const variable = findVariable2(scope, node.left.name);
|
|
7887
8033
|
if (variable === null) return;
|
|
7888
8034
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7892,7 +8038,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7892
8038
|
}
|
|
7893
8039
|
return;
|
|
7894
8040
|
}
|
|
7895
|
-
if (node.left.type ===
|
|
8041
|
+
if (node.left.type === import_utils55.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils55.AST_NODE_TYPES.ArrayPattern) {
|
|
7896
8042
|
if (isRawPayloadSource(node.right)) {
|
|
7897
8043
|
context.report({
|
|
7898
8044
|
node: node.left,
|
|
@@ -7909,15 +8055,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7909
8055
|
}
|
|
7910
8056
|
},
|
|
7911
8057
|
CallExpression(node) {
|
|
7912
|
-
if (node.callee.type !==
|
|
8058
|
+
if (node.callee.type !== import_utils55.AST_NODE_TYPES.Identifier) return;
|
|
7913
8059
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7914
8060
|
return;
|
|
7915
8061
|
}
|
|
7916
8062
|
const scope = context.sourceCode.getScope(node);
|
|
7917
8063
|
for (const arg of node.arguments) {
|
|
7918
|
-
if (arg.type ===
|
|
8064
|
+
if (arg.type === import_utils55.AST_NODE_TYPES.SpreadElement) continue;
|
|
7919
8065
|
const unwrapped = unwrap4(arg);
|
|
7920
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8066
|
+
if (unwrapped === null || unwrapped.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7921
8067
|
continue;
|
|
7922
8068
|
}
|
|
7923
8069
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7931,13 +8077,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7931
8077
|
const obj = unwrap4(node.object);
|
|
7932
8078
|
if (isRawPayloadSource(obj)) {
|
|
7933
8079
|
const parent = node.parent;
|
|
7934
|
-
if (parent.type ===
|
|
8080
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.CallExpression && parent.callee === node && node.property.type === import_utils55.AST_NODE_TYPES.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7935
8081
|
return;
|
|
7936
8082
|
}
|
|
7937
8083
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7938
8084
|
return;
|
|
7939
8085
|
}
|
|
7940
|
-
if (obj !== null && obj.type ===
|
|
8086
|
+
if (obj !== null && obj.type === import_utils55.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7941
8087
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7942
8088
|
const variable = findVariable2(scope, obj.name);
|
|
7943
8089
|
if (variable !== null) {
|
|
@@ -7950,7 +8096,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7950
8096
|
});
|
|
7951
8097
|
|
|
7952
8098
|
// src/rules/prefer-semantic-colors.ts
|
|
7953
|
-
var
|
|
8099
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
7954
8100
|
var import_fs = require("fs");
|
|
7955
8101
|
var import_path = require("path");
|
|
7956
8102
|
|
|
@@ -8050,8 +8196,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
8050
8196
|
]);
|
|
8051
8197
|
function jsxElementName(node) {
|
|
8052
8198
|
const name = node.openingElement.name;
|
|
8053
|
-
if (name.type ===
|
|
8054
|
-
if (name.type ===
|
|
8199
|
+
if (name.type === import_utils56.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
8200
|
+
if (name.type === import_utils56.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils56.AST_NODE_TYPES.JSXIdentifier) {
|
|
8055
8201
|
return name.property.name;
|
|
8056
8202
|
}
|
|
8057
8203
|
return null;
|
|
@@ -8077,7 +8223,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
8077
8223
|
var isInsideSvg = (node) => {
|
|
8078
8224
|
let current = node.parent;
|
|
8079
8225
|
while (current !== void 0 && current !== null) {
|
|
8080
|
-
if (current.type ===
|
|
8226
|
+
if (current.type === import_utils56.AST_NODE_TYPES.JSXElement) {
|
|
8081
8227
|
const name = jsxElementName(current);
|
|
8082
8228
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
8083
8229
|
}
|
|
@@ -8088,7 +8234,7 @@ var isInsideSvg = (node) => {
|
|
|
8088
8234
|
var isInsideIconFactoryPath = (node) => {
|
|
8089
8235
|
let current = node.parent;
|
|
8090
8236
|
while (current !== void 0 && current !== null) {
|
|
8091
|
-
if (current.type ===
|
|
8237
|
+
if (current.type === import_utils56.AST_NODE_TYPES.Property && propName(current.key) === "path" && current.parent.type === import_utils56.AST_NODE_TYPES.ObjectExpression && current.parent.parent.type === import_utils56.AST_NODE_TYPES.CallExpression && current.parent.parent.callee.type === import_utils56.AST_NODE_TYPES.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
8092
8238
|
return true;
|
|
8093
8239
|
}
|
|
8094
8240
|
current = current.parent;
|
|
@@ -8225,12 +8371,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8225
8371
|
return root !== null && workspaceHasMarker(root);
|
|
8226
8372
|
};
|
|
8227
8373
|
var propName = (key) => {
|
|
8228
|
-
if (key.type ===
|
|
8229
|
-
if (key.type ===
|
|
8374
|
+
if (key.type === import_utils56.AST_NODE_TYPES.Identifier) return key.name;
|
|
8375
|
+
if (key.type === import_utils56.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
8230
8376
|
return null;
|
|
8231
8377
|
};
|
|
8232
8378
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8233
|
-
if (statement.type !==
|
|
8379
|
+
if (statement.type !== import_utils56.AST_NODE_TYPES.ImportDeclaration && statement.type !== import_utils56.AST_NODE_TYPES.ExportNamedDeclaration && statement.type !== import_utils56.AST_NODE_TYPES.ExportAllDeclaration) {
|
|
8234
8380
|
return false;
|
|
8235
8381
|
}
|
|
8236
8382
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8282,27 +8428,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8282
8428
|
const checkClassNode = (node) => {
|
|
8283
8429
|
if (node === null) return;
|
|
8284
8430
|
switch (node.type) {
|
|
8285
|
-
case
|
|
8431
|
+
case import_utils56.AST_NODE_TYPES.Literal:
|
|
8286
8432
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8287
8433
|
break;
|
|
8288
|
-
case
|
|
8434
|
+
case import_utils56.AST_NODE_TYPES.TemplateLiteral:
|
|
8289
8435
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8290
8436
|
break;
|
|
8291
|
-
case
|
|
8437
|
+
case import_utils56.AST_NODE_TYPES.ArrayExpression:
|
|
8292
8438
|
for (const element of node.elements) {
|
|
8293
|
-
if (element !== null && element.type !==
|
|
8439
|
+
if (element !== null && element.type !== import_utils56.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
8294
8440
|
}
|
|
8295
8441
|
break;
|
|
8296
|
-
case
|
|
8442
|
+
case import_utils56.AST_NODE_TYPES.ObjectExpression:
|
|
8297
8443
|
for (const property of node.properties) {
|
|
8298
|
-
if (property.type ===
|
|
8444
|
+
if (property.type === import_utils56.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
8299
8445
|
}
|
|
8300
8446
|
break;
|
|
8301
|
-
case
|
|
8447
|
+
case import_utils56.AST_NODE_TYPES.ConditionalExpression:
|
|
8302
8448
|
checkClassNode(node.consequent);
|
|
8303
8449
|
checkClassNode(node.alternate);
|
|
8304
8450
|
break;
|
|
8305
|
-
case
|
|
8451
|
+
case import_utils56.AST_NODE_TYPES.LogicalExpression:
|
|
8306
8452
|
checkClassNode(node.right);
|
|
8307
8453
|
break;
|
|
8308
8454
|
default:
|
|
@@ -8310,32 +8456,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8310
8456
|
}
|
|
8311
8457
|
};
|
|
8312
8458
|
const checkColorValueNode = (node) => {
|
|
8313
|
-
if (node.type ===
|
|
8459
|
+
if (node.type === import_utils56.AST_NODE_TYPES.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
8314
8460
|
report(node, "inlineColor", { value: node.value });
|
|
8315
8461
|
}
|
|
8316
8462
|
};
|
|
8317
8463
|
return {
|
|
8318
8464
|
"JSXAttribute[name.name='className']"(node) {
|
|
8319
8465
|
if (node.value === null) return;
|
|
8320
|
-
if (node.value.type ===
|
|
8321
|
-
else if (node.value.type ===
|
|
8322
|
-
if (node.value.expression.type !==
|
|
8466
|
+
if (node.value.type === import_utils56.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
8467
|
+
else if (node.value.type === import_utils56.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
8468
|
+
if (node.value.expression.type !== import_utils56.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
8323
8469
|
checkClassNode(node.value.expression);
|
|
8324
8470
|
}
|
|
8325
8471
|
}
|
|
8326
8472
|
},
|
|
8327
8473
|
CallExpression(node) {
|
|
8328
|
-
if (node.callee.type ===
|
|
8474
|
+
if (node.callee.type === import_utils56.AST_NODE_TYPES.Identifier && node.callee.name === "require" && node.arguments[0]?.type === import_utils56.AST_NODE_TYPES.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
8329
8475
|
importsEmailOrPdfRenderer = true;
|
|
8330
8476
|
}
|
|
8331
|
-
if (node.callee.type ===
|
|
8477
|
+
if (node.callee.type === import_utils56.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8332
8478
|
for (const arg of node.arguments) {
|
|
8333
|
-
if (arg.type !==
|
|
8479
|
+
if (arg.type !== import_utils56.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
8334
8480
|
}
|
|
8335
8481
|
}
|
|
8336
8482
|
},
|
|
8337
8483
|
VariableDeclarator(node) {
|
|
8338
|
-
if (node.id.type ===
|
|
8484
|
+
if (node.id.type === import_utils56.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8339
8485
|
checkClassNode(node.init);
|
|
8340
8486
|
}
|
|
8341
8487
|
},
|
|
@@ -8345,9 +8491,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8345
8491
|
},
|
|
8346
8492
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8347
8493
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8348
|
-
if (node.value?.type !==
|
|
8494
|
+
if (node.value?.type !== import_utils56.AST_NODE_TYPES.Literal) return;
|
|
8349
8495
|
const owner = node.parent.name;
|
|
8350
|
-
if (owner.type ===
|
|
8496
|
+
if (owner.type === import_utils56.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8351
8497
|
return;
|
|
8352
8498
|
}
|
|
8353
8499
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8361,7 +8507,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8361
8507
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8362
8508
|
},
|
|
8363
8509
|
ImportExpression(node) {
|
|
8364
|
-
if (node.source.type ===
|
|
8510
|
+
if (node.source.type === import_utils56.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8365
8511
|
importsEmailOrPdfRenderer = true;
|
|
8366
8512
|
}
|
|
8367
8513
|
},
|
|
@@ -8374,7 +8520,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8374
8520
|
});
|
|
8375
8521
|
|
|
8376
8522
|
// src/rules/prefer-server-actions.ts
|
|
8377
|
-
var
|
|
8523
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8378
8524
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
8379
8525
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
8380
8526
|
var SKIP_FILE_REGEX = /(?:\.test\.[jt]sx?$|\.spec\.[jt]sx?$|-(?:test|spec)\.[jt]sx?$|\/tests?\/|\/__tests__\/|\/__testfixtures__\/|\/scripts?\/|\/app\/api\/.*\/route\.[jt]sx?$|\/pages\/api\/)/;
|
|
@@ -8565,7 +8711,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8565
8711
|
});
|
|
8566
8712
|
|
|
8567
8713
|
// src/rules/prefer-string-literal-union.ts
|
|
8568
|
-
var
|
|
8714
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8569
8715
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8570
8716
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8571
8717
|
"status",
|
|
@@ -8608,19 +8754,19 @@ function isChoiceLikeName(name) {
|
|
|
8608
8754
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8609
8755
|
}
|
|
8610
8756
|
function keyName(key) {
|
|
8611
|
-
if (key.type ===
|
|
8757
|
+
if (key.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8612
8758
|
return key.name;
|
|
8613
8759
|
}
|
|
8614
|
-
if (key.type ===
|
|
8760
|
+
if (key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8615
8761
|
return key.value;
|
|
8616
8762
|
}
|
|
8617
8763
|
return null;
|
|
8618
8764
|
}
|
|
8619
8765
|
function isStringLiteralMember(t) {
|
|
8620
|
-
return t.type ===
|
|
8766
|
+
return t.type === import_utils58.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils58.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
8621
8767
|
}
|
|
8622
8768
|
function isStringLiteralUnion(node) {
|
|
8623
|
-
if (node?.type !==
|
|
8769
|
+
if (node?.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
8624
8770
|
return false;
|
|
8625
8771
|
}
|
|
8626
8772
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8649,12 +8795,12 @@ function bindingSourceExpression(decl) {
|
|
|
8649
8795
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8650
8796
|
}
|
|
8651
8797
|
function refKey(node) {
|
|
8652
|
-
if (node.type ===
|
|
8798
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8653
8799
|
return node.name;
|
|
8654
8800
|
}
|
|
8655
|
-
if (node.type ===
|
|
8801
|
+
if (node.type === import_utils58.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8656
8802
|
const inner = refKey(node.object);
|
|
8657
|
-
if (inner === null || node.property.type !==
|
|
8803
|
+
if (inner === null || node.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8658
8804
|
return null;
|
|
8659
8805
|
}
|
|
8660
8806
|
return `${inner}.${node.property.name}`;
|
|
@@ -8662,7 +8808,7 @@ function refKey(node) {
|
|
|
8662
8808
|
return null;
|
|
8663
8809
|
}
|
|
8664
8810
|
function strLiteral(node) {
|
|
8665
|
-
if (node.type ===
|
|
8811
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8666
8812
|
return node.value;
|
|
8667
8813
|
}
|
|
8668
8814
|
return null;
|
|
@@ -8703,7 +8849,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8703
8849
|
);
|
|
8704
8850
|
let services;
|
|
8705
8851
|
try {
|
|
8706
|
-
services =
|
|
8852
|
+
services = import_utils58.ESLintUtils.getParserServices(context);
|
|
8707
8853
|
} catch {
|
|
8708
8854
|
services = null;
|
|
8709
8855
|
}
|
|
@@ -8815,7 +8961,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8815
8961
|
containersWithUnion.add(container);
|
|
8816
8962
|
return;
|
|
8817
8963
|
}
|
|
8818
|
-
if (typeNode?.type !==
|
|
8964
|
+
if (typeNode?.type !== import_utils58.AST_NODE_TYPES.TSStringKeyword) {
|
|
8819
8965
|
return;
|
|
8820
8966
|
}
|
|
8821
8967
|
const name = keyName(key);
|
|
@@ -8903,10 +9049,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8903
9049
|
}
|
|
8904
9050
|
};
|
|
8905
9051
|
function refKeyText(node) {
|
|
8906
|
-
if (node.type ===
|
|
9052
|
+
if (node.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
8907
9053
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8908
9054
|
}
|
|
8909
|
-
if (node.type ===
|
|
9055
|
+
if (node.type === import_utils58.AST_NODE_TYPES.SwitchStatement) {
|
|
8910
9056
|
return refKey(node.discriminant) ?? "value";
|
|
8911
9057
|
}
|
|
8912
9058
|
return "value";
|
|
@@ -8915,7 +9061,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8915
9061
|
});
|
|
8916
9062
|
|
|
8917
9063
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8918
|
-
var
|
|
9064
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
8919
9065
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8920
9066
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8921
9067
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8924,11 +9070,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8924
9070
|
var MIN_RUN_LENGTH = 2;
|
|
8925
9071
|
function literalText(node, getText) {
|
|
8926
9072
|
switch (node.type) {
|
|
8927
|
-
case
|
|
9073
|
+
case import_utils59.AST_NODE_TYPES.Literal:
|
|
8928
9074
|
return "regex" in node ? null : getText(node);
|
|
8929
|
-
case
|
|
9075
|
+
case import_utils59.AST_NODE_TYPES.TemplateLiteral:
|
|
8930
9076
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8931
|
-
case
|
|
9077
|
+
case import_utils59.AST_NODE_TYPES.UnaryExpression:
|
|
8932
9078
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8933
9079
|
default:
|
|
8934
9080
|
return null;
|
|
@@ -8936,15 +9082,15 @@ function literalText(node, getText) {
|
|
|
8936
9082
|
}
|
|
8937
9083
|
function isPureReceiver(node) {
|
|
8938
9084
|
switch (node.type) {
|
|
8939
|
-
case
|
|
8940
|
-
case
|
|
9085
|
+
case import_utils59.AST_NODE_TYPES.Identifier:
|
|
9086
|
+
case import_utils59.AST_NODE_TYPES.ThisExpression:
|
|
8941
9087
|
return true;
|
|
8942
|
-
case
|
|
9088
|
+
case import_utils59.AST_NODE_TYPES.MemberExpression:
|
|
8943
9089
|
if (node.optional) {
|
|
8944
9090
|
return false;
|
|
8945
9091
|
}
|
|
8946
9092
|
if (node.computed) {
|
|
8947
|
-
return node.property.type ===
|
|
9093
|
+
return node.property.type === import_utils59.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8948
9094
|
}
|
|
8949
9095
|
return isPureReceiver(node.object);
|
|
8950
9096
|
default:
|
|
@@ -8952,7 +9098,7 @@ function isPureReceiver(node) {
|
|
|
8952
9098
|
}
|
|
8953
9099
|
}
|
|
8954
9100
|
function literalIndex(node) {
|
|
8955
|
-
if (node.type !==
|
|
9101
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8956
9102
|
return null;
|
|
8957
9103
|
}
|
|
8958
9104
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8978,24 +9124,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8978
9124
|
}
|
|
8979
9125
|
const { sourceCode } = context;
|
|
8980
9126
|
function parseAssertion(statement) {
|
|
8981
|
-
if (statement.type !==
|
|
9127
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExpressionStatement) {
|
|
8982
9128
|
return null;
|
|
8983
9129
|
}
|
|
8984
9130
|
const call = statement.expression;
|
|
8985
|
-
if (call.type !==
|
|
9131
|
+
if (call.type !== import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
8986
9132
|
return null;
|
|
8987
9133
|
}
|
|
8988
9134
|
const callee = call.callee;
|
|
8989
|
-
if (callee.type !==
|
|
9135
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
8990
9136
|
return null;
|
|
8991
9137
|
}
|
|
8992
9138
|
const matcher = callee.property.name;
|
|
8993
9139
|
const expectCall = callee.object;
|
|
8994
|
-
if (expectCall.type !==
|
|
9140
|
+
if (expectCall.type !== import_utils59.AST_NODE_TYPES.CallExpression || expectCall.callee.type !== import_utils59.AST_NODE_TYPES.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8995
9141
|
return null;
|
|
8996
9142
|
}
|
|
8997
9143
|
const actual = expectCall.arguments[0];
|
|
8998
|
-
if (actual === void 0 || actual.type !==
|
|
9144
|
+
if (actual === void 0 || actual.type !== import_utils59.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8999
9145
|
return null;
|
|
9000
9146
|
}
|
|
9001
9147
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -9009,7 +9155,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9009
9155
|
}
|
|
9010
9156
|
key = { kind: "index", index };
|
|
9011
9157
|
} else {
|
|
9012
|
-
if (actual.property.type !==
|
|
9158
|
+
if (actual.property.type !== import_utils59.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
9013
9159
|
return null;
|
|
9014
9160
|
}
|
|
9015
9161
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -9021,7 +9167,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9021
9167
|
return null;
|
|
9022
9168
|
}
|
|
9023
9169
|
const expected = call.arguments[0];
|
|
9024
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
9170
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils59.AST_NODE_TYPES.SpreadElement) {
|
|
9025
9171
|
return null;
|
|
9026
9172
|
}
|
|
9027
9173
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9136,7 +9282,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9136
9282
|
});
|
|
9137
9283
|
|
|
9138
9284
|
// src/rules/prefer-zod-enum.ts
|
|
9139
|
-
var
|
|
9285
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9140
9286
|
var prefer_zod_enum_default = createRule({
|
|
9141
9287
|
name: "prefer-zod-enum",
|
|
9142
9288
|
meta: {
|
|
@@ -9156,25 +9302,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9156
9302
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9157
9303
|
function enumValues(node) {
|
|
9158
9304
|
const callee = node.callee;
|
|
9159
|
-
if (callee.type !==
|
|
9305
|
+
if (callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || callee.computed || callee.object.type !== import_utils60.AST_NODE_TYPES.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== import_utils60.AST_NODE_TYPES.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
9160
9306
|
return null;
|
|
9161
9307
|
}
|
|
9162
9308
|
const argument = node.arguments[0];
|
|
9163
|
-
if (argument === void 0 || argument.type !==
|
|
9309
|
+
if (argument === void 0 || argument.type !== import_utils60.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
9164
9310
|
return null;
|
|
9165
9311
|
}
|
|
9166
9312
|
const values = [];
|
|
9167
9313
|
let canFix = true;
|
|
9168
9314
|
for (const element of argument.elements) {
|
|
9169
|
-
if (element?.type ===
|
|
9315
|
+
if (element?.type === import_utils60.AST_NODE_TYPES.SpreadElement) {
|
|
9170
9316
|
canFix = false;
|
|
9171
9317
|
continue;
|
|
9172
9318
|
}
|
|
9173
|
-
if (element === null || element.type !==
|
|
9319
|
+
if (element === null || element.type !== import_utils60.AST_NODE_TYPES.CallExpression || element.callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || element.callee.computed || element.callee.object.type !== import_utils60.AST_NODE_TYPES.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== import_utils60.AST_NODE_TYPES.Identifier || element.callee.property.name !== "literal") {
|
|
9174
9320
|
return null;
|
|
9175
9321
|
}
|
|
9176
9322
|
const value = element.arguments[0];
|
|
9177
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9323
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils60.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
9178
9324
|
canFix = false;
|
|
9179
9325
|
continue;
|
|
9180
9326
|
}
|
|
@@ -9184,11 +9330,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9184
9330
|
}
|
|
9185
9331
|
function buildFix(node, values) {
|
|
9186
9332
|
const argument = node.arguments[0];
|
|
9187
|
-
if (argument === void 0 || argument.type !==
|
|
9333
|
+
if (argument === void 0 || argument.type !== import_utils60.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9188
9334
|
return void 0;
|
|
9189
9335
|
}
|
|
9190
9336
|
const callee = node.callee;
|
|
9191
|
-
if (callee.type !==
|
|
9337
|
+
if (callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9192
9338
|
return void 0;
|
|
9193
9339
|
}
|
|
9194
9340
|
return (fixer) => [
|
|
@@ -9205,7 +9351,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9205
9351
|
return;
|
|
9206
9352
|
}
|
|
9207
9353
|
for (const specifier of node.specifiers) {
|
|
9208
|
-
if (specifier.type ===
|
|
9354
|
+
if (specifier.type === import_utils60.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils60.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils60.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils60.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
9209
9355
|
zodNamespaces.add(specifier.local.name);
|
|
9210
9356
|
}
|
|
9211
9357
|
}
|
|
@@ -9227,7 +9373,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9227
9373
|
});
|
|
9228
9374
|
|
|
9229
9375
|
// src/rules/prefer-zod-infer.ts
|
|
9230
|
-
var
|
|
9376
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9231
9377
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9232
9378
|
"describe",
|
|
9233
9379
|
"refine",
|
|
@@ -9264,44 +9410,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9264
9410
|
"Schema"
|
|
9265
9411
|
]);
|
|
9266
9412
|
var LEAF_NODE_TYPES = {
|
|
9267
|
-
string: [
|
|
9268
|
-
email: [
|
|
9269
|
-
url: [
|
|
9270
|
-
uuid: [
|
|
9271
|
-
ulid: [
|
|
9272
|
-
cuid: [
|
|
9273
|
-
cuid2: [
|
|
9274
|
-
nanoid: [
|
|
9275
|
-
iso: [
|
|
9276
|
-
number: [
|
|
9277
|
-
int: [
|
|
9278
|
-
float32: [
|
|
9279
|
-
float64: [
|
|
9280
|
-
boolean: [
|
|
9281
|
-
bigint: [
|
|
9282
|
-
symbol: [
|
|
9283
|
-
any: [
|
|
9284
|
-
unknown: [
|
|
9285
|
-
never: [
|
|
9286
|
-
void: [
|
|
9287
|
-
null: [
|
|
9288
|
-
undefined: [
|
|
9289
|
-
literal: [
|
|
9290
|
-
date: [
|
|
9291
|
-
array: [
|
|
9292
|
-
tuple: [
|
|
9293
|
-
object: [
|
|
9294
|
-
strictObject: [
|
|
9295
|
-
looseObject: [
|
|
9296
|
-
record: [
|
|
9297
|
-
map: [
|
|
9298
|
-
set: [
|
|
9299
|
-
promise: [
|
|
9300
|
-
enum: [
|
|
9301
|
-
nativeEnum: [
|
|
9302
|
-
union: [
|
|
9303
|
-
discriminatedUnion: [
|
|
9304
|
-
intersection: [
|
|
9413
|
+
string: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9414
|
+
email: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9415
|
+
url: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9416
|
+
uuid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9417
|
+
ulid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9418
|
+
cuid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9419
|
+
cuid2: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9420
|
+
nanoid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9421
|
+
iso: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9422
|
+
number: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9423
|
+
int: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9424
|
+
float32: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9425
|
+
float64: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9426
|
+
boolean: [import_utils61.AST_NODE_TYPES.TSBooleanKeyword],
|
|
9427
|
+
bigint: [import_utils61.AST_NODE_TYPES.TSBigIntKeyword],
|
|
9428
|
+
symbol: [import_utils61.AST_NODE_TYPES.TSSymbolKeyword],
|
|
9429
|
+
any: [import_utils61.AST_NODE_TYPES.TSAnyKeyword],
|
|
9430
|
+
unknown: [import_utils61.AST_NODE_TYPES.TSUnknownKeyword],
|
|
9431
|
+
never: [import_utils61.AST_NODE_TYPES.TSNeverKeyword],
|
|
9432
|
+
void: [import_utils61.AST_NODE_TYPES.TSVoidKeyword],
|
|
9433
|
+
null: [import_utils61.AST_NODE_TYPES.TSNullKeyword],
|
|
9434
|
+
undefined: [import_utils61.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
9435
|
+
literal: [import_utils61.AST_NODE_TYPES.TSLiteralType],
|
|
9436
|
+
date: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9437
|
+
array: [import_utils61.AST_NODE_TYPES.TSArrayType, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9438
|
+
tuple: [import_utils61.AST_NODE_TYPES.TSTupleType],
|
|
9439
|
+
object: [import_utils61.AST_NODE_TYPES.TSTypeLiteral, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9440
|
+
strictObject: [import_utils61.AST_NODE_TYPES.TSTypeLiteral, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9441
|
+
looseObject: [import_utils61.AST_NODE_TYPES.TSTypeLiteral, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9442
|
+
record: [import_utils61.AST_NODE_TYPES.TSTypeReference, import_utils61.AST_NODE_TYPES.TSTypeLiteral],
|
|
9443
|
+
map: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9444
|
+
set: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9445
|
+
promise: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9446
|
+
enum: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference, import_utils61.AST_NODE_TYPES.TSLiteralType],
|
|
9447
|
+
nativeEnum: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference, import_utils61.AST_NODE_TYPES.TSLiteralType],
|
|
9448
|
+
union: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9449
|
+
discriminatedUnion: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9450
|
+
intersection: [import_utils61.AST_NODE_TYPES.TSIntersectionType, import_utils61.AST_NODE_TYPES.TSTypeReference]
|
|
9305
9451
|
};
|
|
9306
9452
|
function normalizeSchemaName(name) {
|
|
9307
9453
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9310,20 +9456,20 @@ function normalizeTypeName(name) {
|
|
|
9310
9456
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9311
9457
|
}
|
|
9312
9458
|
function unwrapNullish(annotation) {
|
|
9313
|
-
if (annotation.type !==
|
|
9459
|
+
if (annotation.type !== import_utils61.AST_NODE_TYPES.TSUnionType) {
|
|
9314
9460
|
return {
|
|
9315
9461
|
core: annotation,
|
|
9316
|
-
nullable: annotation.type ===
|
|
9462
|
+
nullable: annotation.type === import_utils61.AST_NODE_TYPES.TSNullKeyword
|
|
9317
9463
|
};
|
|
9318
9464
|
}
|
|
9319
9465
|
const rest = [];
|
|
9320
9466
|
let nullable = false;
|
|
9321
9467
|
for (const member of annotation.types) {
|
|
9322
|
-
if (member.type ===
|
|
9468
|
+
if (member.type === import_utils61.AST_NODE_TYPES.TSNullKeyword) {
|
|
9323
9469
|
nullable = true;
|
|
9324
9470
|
continue;
|
|
9325
9471
|
}
|
|
9326
|
-
if (member.type ===
|
|
9472
|
+
if (member.type === import_utils61.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
9327
9473
|
continue;
|
|
9328
9474
|
}
|
|
9329
9475
|
rest.push(member);
|
|
@@ -9388,14 +9534,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9388
9534
|
function zodCallChain(node) {
|
|
9389
9535
|
const chain = [];
|
|
9390
9536
|
let current = node;
|
|
9391
|
-
while (current.type ===
|
|
9537
|
+
while (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9392
9538
|
const callee = current.callee;
|
|
9393
|
-
if (callee.type !==
|
|
9539
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9394
9540
|
return null;
|
|
9395
9541
|
}
|
|
9396
9542
|
chain.push(current);
|
|
9397
9543
|
const receiver = callee.object;
|
|
9398
|
-
if (receiver.type ===
|
|
9544
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9399
9545
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9400
9546
|
}
|
|
9401
9547
|
current = receiver;
|
|
@@ -9404,19 +9550,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9404
9550
|
}
|
|
9405
9551
|
function methodName(call) {
|
|
9406
9552
|
const callee = call.callee;
|
|
9407
|
-
return callee.type ===
|
|
9553
|
+
return callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
9408
9554
|
}
|
|
9409
9555
|
function schemaField(node) {
|
|
9410
9556
|
const modifiers = [];
|
|
9411
9557
|
let current = node;
|
|
9412
9558
|
let leaf = null;
|
|
9413
|
-
while (current.type ===
|
|
9559
|
+
while (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9414
9560
|
const callee = current.callee;
|
|
9415
|
-
if (callee.type !==
|
|
9561
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9416
9562
|
break;
|
|
9417
9563
|
}
|
|
9418
9564
|
const receiver = callee.object;
|
|
9419
|
-
if (receiver.type ===
|
|
9565
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9420
9566
|
leaf = callee.property.name;
|
|
9421
9567
|
break;
|
|
9422
9568
|
}
|
|
@@ -9447,16 +9593,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9447
9593
|
return null;
|
|
9448
9594
|
}
|
|
9449
9595
|
const shape = base.arguments[0];
|
|
9450
|
-
if (shape === void 0 || shape.type !==
|
|
9596
|
+
if (shape === void 0 || shape.type !== import_utils61.AST_NODE_TYPES.ObjectExpression) {
|
|
9451
9597
|
return null;
|
|
9452
9598
|
}
|
|
9453
9599
|
const fields = /* @__PURE__ */ new Map();
|
|
9454
9600
|
for (const property of shape.properties) {
|
|
9455
|
-
if (property.type !==
|
|
9601
|
+
if (property.type !== import_utils61.AST_NODE_TYPES.Property || property.computed) {
|
|
9456
9602
|
return null;
|
|
9457
9603
|
}
|
|
9458
9604
|
const { key } = property;
|
|
9459
|
-
const name = key.type ===
|
|
9605
|
+
const name = key.type === import_utils61.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils61.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
9460
9606
|
if (name === null) {
|
|
9461
9607
|
return null;
|
|
9462
9608
|
}
|
|
@@ -9467,11 +9613,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9467
9613
|
function typeMembers(members) {
|
|
9468
9614
|
const result = /* @__PURE__ */ new Map();
|
|
9469
9615
|
for (const member of members) {
|
|
9470
|
-
if (member.type !==
|
|
9616
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
9471
9617
|
return null;
|
|
9472
9618
|
}
|
|
9473
9619
|
const { key } = member;
|
|
9474
|
-
const name = key.type ===
|
|
9620
|
+
const name = key.type === import_utils61.AST_NODE_TYPES.Identifier ? key.name : key.type === import_utils61.AST_NODE_TYPES.Literal && typeof key.value === "string" ? key.value : null;
|
|
9475
9621
|
if (name === null) {
|
|
9476
9622
|
return null;
|
|
9477
9623
|
}
|
|
@@ -9485,8 +9631,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9485
9631
|
return result.size === 0 ? null : result;
|
|
9486
9632
|
}
|
|
9487
9633
|
function collectConstrainedNames(node) {
|
|
9488
|
-
if (node.type ===
|
|
9489
|
-
if (node.typeName.type ===
|
|
9634
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSTypeReference) {
|
|
9635
|
+
if (node.typeName.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9490
9636
|
constrainedTypeNames.add(node.typeName.name);
|
|
9491
9637
|
}
|
|
9492
9638
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9494,11 +9640,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9494
9640
|
}
|
|
9495
9641
|
return;
|
|
9496
9642
|
}
|
|
9497
|
-
if (node.type ===
|
|
9643
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSArrayType) {
|
|
9498
9644
|
collectConstrainedNames(node.elementType);
|
|
9499
9645
|
return;
|
|
9500
9646
|
}
|
|
9501
|
-
if (node.type ===
|
|
9647
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSUnionType || node.type === import_utils61.AST_NODE_TYPES.TSIntersectionType) {
|
|
9502
9648
|
for (const member of node.types) {
|
|
9503
9649
|
collectConstrainedNames(member);
|
|
9504
9650
|
}
|
|
@@ -9542,13 +9688,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9542
9688
|
return;
|
|
9543
9689
|
}
|
|
9544
9690
|
for (const specifier of node.specifiers) {
|
|
9545
|
-
if (specifier.type ===
|
|
9691
|
+
if (specifier.type === import_utils61.AST_NODE_TYPES.ImportNamespaceSpecifier || specifier.type === import_utils61.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === import_utils61.AST_NODE_TYPES.ImportSpecifier && specifier.imported.type === import_utils61.AST_NODE_TYPES.Identifier && specifier.imported.name === "z") {
|
|
9546
9692
|
zodNamespaces.add(specifier.local.name);
|
|
9547
9693
|
}
|
|
9548
9694
|
}
|
|
9549
9695
|
},
|
|
9550
9696
|
VariableDeclarator(node) {
|
|
9551
|
-
if (node.id.type !==
|
|
9697
|
+
if (node.id.type !== import_utils61.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9552
9698
|
return;
|
|
9553
9699
|
}
|
|
9554
9700
|
const fields = schemaFields(node.init);
|
|
@@ -9558,14 +9704,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9558
9704
|
},
|
|
9559
9705
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9560
9706
|
"MemberExpression[computed=false]"(node) {
|
|
9561
|
-
if (node.object.type ===
|
|
9707
|
+
if (node.object.type === import_utils61.AST_NODE_TYPES.Identifier && node.property.type === import_utils61.AST_NODE_TYPES.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9562
9708
|
reshapedSchemaNames.add(node.object.name);
|
|
9563
9709
|
}
|
|
9564
9710
|
},
|
|
9565
9711
|
/** Records every type argument carried by a Zod constraint. */
|
|
9566
9712
|
TSTypeReference(node) {
|
|
9567
9713
|
const { typeName } = node;
|
|
9568
|
-
const referenced = typeName.type ===
|
|
9714
|
+
const referenced = typeName.type === import_utils61.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils61.AST_NODE_TYPES.TSQualifiedName && typeName.right.type === import_utils61.AST_NODE_TYPES.Identifier ? typeName.right.name : null;
|
|
9569
9715
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9570
9716
|
return;
|
|
9571
9717
|
}
|
|
@@ -9583,7 +9729,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9583
9729
|
}
|
|
9584
9730
|
},
|
|
9585
9731
|
TSTypeAliasDeclaration(node) {
|
|
9586
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9732
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9587
9733
|
return;
|
|
9588
9734
|
}
|
|
9589
9735
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9628,10 +9774,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9628
9774
|
});
|
|
9629
9775
|
|
|
9630
9776
|
// src/rules/require-assert-never.ts
|
|
9631
|
-
var
|
|
9777
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9632
9778
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9633
|
-
if (statement.type ===
|
|
9634
|
-
if (statement.type ===
|
|
9779
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9780
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.BlockStatement) {
|
|
9635
9781
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9636
9782
|
}
|
|
9637
9783
|
return true;
|
|
@@ -9647,7 +9793,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9647
9793
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9648
9794
|
}
|
|
9649
9795
|
const only = defaultCase.consequent[0];
|
|
9650
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9796
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils62.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
9651
9797
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9652
9798
|
}
|
|
9653
9799
|
return false;
|
|
@@ -9687,7 +9833,7 @@ var require_assert_never_default = createRule({
|
|
|
9687
9833
|
});
|
|
9688
9834
|
|
|
9689
9835
|
// src/rules/require-fetch-timeout.ts
|
|
9690
|
-
var
|
|
9836
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9691
9837
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9692
9838
|
"globalThis",
|
|
9693
9839
|
"window",
|
|
@@ -9703,14 +9849,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9703
9849
|
return false;
|
|
9704
9850
|
}
|
|
9705
9851
|
function initProvablyLacksSignal(init) {
|
|
9706
|
-
if (init.type !==
|
|
9852
|
+
if (init.type !== import_utils63.AST_NODE_TYPES.ObjectExpression) {
|
|
9707
9853
|
return false;
|
|
9708
9854
|
}
|
|
9709
9855
|
for (const prop of init.properties) {
|
|
9710
|
-
if (prop.type ===
|
|
9856
|
+
if (prop.type === import_utils63.AST_NODE_TYPES.SpreadElement) {
|
|
9711
9857
|
return false;
|
|
9712
9858
|
}
|
|
9713
|
-
if (prop.key.type ===
|
|
9859
|
+
if (prop.key.type === import_utils63.AST_NODE_TYPES.Identifier && prop.key.name === "signal" || prop.key.type === import_utils63.AST_NODE_TYPES.Literal && prop.key.value === "signal") {
|
|
9714
9860
|
return false;
|
|
9715
9861
|
}
|
|
9716
9862
|
if (prop.computed) {
|
|
@@ -9720,7 +9866,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9720
9866
|
return true;
|
|
9721
9867
|
}
|
|
9722
9868
|
function isStringish(node) {
|
|
9723
|
-
return node.type ===
|
|
9869
|
+
return node.type === import_utils63.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils63.AST_NODE_TYPES.TemplateLiteral;
|
|
9724
9870
|
}
|
|
9725
9871
|
var require_fetch_timeout_default = createRule({
|
|
9726
9872
|
name: "require-fetch-timeout",
|
|
@@ -9757,14 +9903,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9757
9903
|
}
|
|
9758
9904
|
function resolvesToGlobal(identifier) {
|
|
9759
9905
|
const scope = context.sourceCode.getScope(identifier);
|
|
9760
|
-
const variable =
|
|
9906
|
+
const variable = import_utils63.ASTUtils.findVariable(scope, identifier.name);
|
|
9761
9907
|
return variable === null || variable.defs.length === 0;
|
|
9762
9908
|
}
|
|
9763
9909
|
function isGlobalFetchCall2(callee) {
|
|
9764
|
-
if (callee.type ===
|
|
9910
|
+
if (callee.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9765
9911
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9766
9912
|
}
|
|
9767
|
-
return callee.type ===
|
|
9913
|
+
return callee.type === import_utils63.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils63.AST_NODE_TYPES.Identifier && callee.property.name === "fetch" && callee.object.type === import_utils63.AST_NODE_TYPES.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9768
9914
|
}
|
|
9769
9915
|
return {
|
|
9770
9916
|
CallExpression(node) {
|
|
@@ -9784,7 +9930,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9784
9930
|
});
|
|
9785
9931
|
|
|
9786
9932
|
// src/rules/require-interface-for-injected-service.ts
|
|
9787
|
-
var
|
|
9933
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
9788
9934
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9789
9935
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9790
9936
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9792,20 +9938,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9792
9938
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9793
9939
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9794
9940
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9795
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9796
|
-
var qualifiedName = (name) => name.type ===
|
|
9941
|
+
var isExportedClass = (node) => node.parent.type === import_utils64.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils64.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9942
|
+
var qualifiedName = (name) => name.type === import_utils64.AST_NODE_TYPES.Identifier ? name.name : name.type === import_utils64.AST_NODE_TYPES.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9797
9943
|
var readTypeReference = (annotation) => {
|
|
9798
|
-
if (annotation === void 0 || annotation.type !==
|
|
9944
|
+
if (annotation === void 0 || annotation.type !== import_utils64.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9799
9945
|
const { typeName } = annotation;
|
|
9800
|
-
const rightmost = typeName.type ===
|
|
9946
|
+
const rightmost = typeName.type === import_utils64.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils64.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9801
9947
|
if (rightmost === null) return null;
|
|
9802
9948
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9803
9949
|
};
|
|
9804
9950
|
var namedParameterCollaborator = (annotated) => {
|
|
9805
9951
|
let target = annotated;
|
|
9806
|
-
if (target.type ===
|
|
9807
|
-
if (target.type ===
|
|
9808
|
-
if (target.type !==
|
|
9952
|
+
if (target.type === import_utils64.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9953
|
+
if (target.type === import_utils64.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9954
|
+
if (target.type !== import_utils64.AST_NODE_TYPES.Identifier) return null;
|
|
9809
9955
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9810
9956
|
if (reference === null) return null;
|
|
9811
9957
|
return { name: target.name, ...reference };
|
|
@@ -9813,8 +9959,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9813
9959
|
var propertySignatureTypes = (members) => {
|
|
9814
9960
|
const types = /* @__PURE__ */ new Map();
|
|
9815
9961
|
for (const member of members) {
|
|
9816
|
-
if (member.type !==
|
|
9817
|
-
if (member.computed || member.key.type !==
|
|
9962
|
+
if (member.type !== import_utils64.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9963
|
+
if (member.computed || member.key.type !== import_utils64.AST_NODE_TYPES.Identifier) continue;
|
|
9818
9964
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9819
9965
|
if (reference === null) continue;
|
|
9820
9966
|
types.set(member.key.name, reference);
|
|
@@ -9825,18 +9971,18 @@ var fileTypeIndex = (program) => {
|
|
|
9825
9971
|
const objects = /* @__PURE__ */ new Map();
|
|
9826
9972
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9827
9973
|
for (const statement of program.body) {
|
|
9828
|
-
const declaration = statement.type ===
|
|
9829
|
-
if (declaration?.type ===
|
|
9974
|
+
const declaration = statement.type === import_utils64.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9975
|
+
if (declaration?.type === import_utils64.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9830
9976
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9831
9977
|
continue;
|
|
9832
9978
|
}
|
|
9833
|
-
if (declaration?.type !==
|
|
9979
|
+
if (declaration?.type !== import_utils64.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9834
9980
|
const aliased = declaration.typeAnnotation;
|
|
9835
|
-
if (aliased.type ===
|
|
9981
|
+
if (aliased.type === import_utils64.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils64.AST_NODE_TYPES.TSConstructorType) {
|
|
9836
9982
|
functionAliases.add(declaration.id.name);
|
|
9837
9983
|
continue;
|
|
9838
9984
|
}
|
|
9839
|
-
const literals = aliased.type ===
|
|
9985
|
+
const literals = aliased.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral ? [aliased] : aliased.type === import_utils64.AST_NODE_TYPES.TSIntersectionType ? aliased.types.filter((part) => part.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral) : [];
|
|
9840
9986
|
if (literals.length === 0) continue;
|
|
9841
9987
|
const merged = /* @__PURE__ */ new Map();
|
|
9842
9988
|
for (const literal of literals) {
|
|
@@ -9849,10 +9995,10 @@ var fileTypeIndex = (program) => {
|
|
|
9849
9995
|
return { objects, functionAliases };
|
|
9850
9996
|
};
|
|
9851
9997
|
var bagMemberTypes = (annotation, declared) => {
|
|
9852
|
-
if (annotation.type ===
|
|
9998
|
+
if (annotation.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9853
9999
|
return propertySignatureTypes(annotation.members);
|
|
9854
10000
|
}
|
|
9855
|
-
if (annotation.type !==
|
|
10001
|
+
if (annotation.type !== import_utils64.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9856
10002
|
return null;
|
|
9857
10003
|
}
|
|
9858
10004
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9864,11 +10010,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9864
10010
|
if (members === null) return [];
|
|
9865
10011
|
const collaborators = [];
|
|
9866
10012
|
for (const property of pattern.properties) {
|
|
9867
|
-
if (property.type !==
|
|
9868
|
-
if (property.key.type !==
|
|
10013
|
+
if (property.type !== import_utils64.AST_NODE_TYPES.Property || property.computed) continue;
|
|
10014
|
+
if (property.key.type !== import_utils64.AST_NODE_TYPES.Identifier) continue;
|
|
9869
10015
|
const key = property.key.name;
|
|
9870
|
-
const bound = property.value.type ===
|
|
9871
|
-
if (bound.type !==
|
|
10016
|
+
const bound = property.value.type === import_utils64.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
10017
|
+
if (bound.type !== import_utils64.AST_NODE_TYPES.Identifier) continue;
|
|
9872
10018
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9873
10019
|
const reference = members.get(key);
|
|
9874
10020
|
if (reference === void 0) continue;
|
|
@@ -9878,8 +10024,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9878
10024
|
};
|
|
9879
10025
|
var parameterCollaborators = (parameter, declared) => {
|
|
9880
10026
|
let target = parameter;
|
|
9881
|
-
if (target.type ===
|
|
9882
|
-
if (target.type ===
|
|
10027
|
+
if (target.type === import_utils64.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
10028
|
+
if (target.type === import_utils64.AST_NODE_TYPES.ObjectPattern) {
|
|
9883
10029
|
return objectPatternCollaborators(target, declared);
|
|
9884
10030
|
}
|
|
9885
10031
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9898,17 +10044,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9898
10044
|
let constructedFields = 0;
|
|
9899
10045
|
if (body2 !== null && body2 !== void 0) {
|
|
9900
10046
|
for (const statement of body2.body) {
|
|
9901
|
-
if (statement.type !==
|
|
10047
|
+
if (statement.type !== import_utils64.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9902
10048
|
const expression = statement.expression;
|
|
9903
|
-
if (expression.type !==
|
|
10049
|
+
if (expression.type !== import_utils64.AST_NODE_TYPES.AssignmentExpression || expression.operator !== "=" || expression.left.type !== import_utils64.AST_NODE_TYPES.MemberExpression || expression.left.object.type !== import_utils64.AST_NODE_TYPES.ThisExpression) {
|
|
9904
10050
|
continue;
|
|
9905
10051
|
}
|
|
9906
10052
|
const source = expression.right;
|
|
9907
|
-
if (source.type ===
|
|
10053
|
+
if (source.type === import_utils64.AST_NODE_TYPES.NewExpression) {
|
|
9908
10054
|
constructedFields += 1;
|
|
9909
|
-
} else if (source.type ===
|
|
10055
|
+
} else if (source.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9910
10056
|
storedFrom.add(source.name);
|
|
9911
|
-
} else if (source.type ===
|
|
10057
|
+
} else if (source.type === import_utils64.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9912
10058
|
storedFrom.add(source.object.name);
|
|
9913
10059
|
}
|
|
9914
10060
|
}
|
|
@@ -9916,7 +10062,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9916
10062
|
const collaborators = [];
|
|
9917
10063
|
for (const parameter of ctor.value.params) {
|
|
9918
10064
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9919
|
-
const stored = parameter.type ===
|
|
10065
|
+
const stored = parameter.type === import_utils64.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9920
10066
|
if (!stored) continue;
|
|
9921
10067
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9922
10068
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9950,19 +10096,19 @@ var subtreeHas = (root, found) => {
|
|
|
9950
10096
|
return hit;
|
|
9951
10097
|
};
|
|
9952
10098
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9953
|
-
if (node.type ===
|
|
10099
|
+
if (node.type === import_utils64.AST_NODE_TYPES.CallExpression) {
|
|
9954
10100
|
const { callee } = node;
|
|
9955
|
-
if (callee.type ===
|
|
9956
|
-
return callee.type ===
|
|
10101
|
+
if (callee.type === import_utils64.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
10102
|
+
return callee.type === import_utils64.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils64.AST_NODE_TYPES.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9957
10103
|
}
|
|
9958
|
-
return node.type ===
|
|
10104
|
+
return node.type === import_utils64.AST_NODE_TYPES.TSTypeReference && node.typeName.type === import_utils64.AST_NODE_TYPES.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9959
10105
|
});
|
|
9960
10106
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9961
10107
|
var fileInterfaceNames = (program) => {
|
|
9962
10108
|
const names = [];
|
|
9963
10109
|
for (const statement of program.body) {
|
|
9964
|
-
const declaration = statement.type ===
|
|
9965
|
-
if (declaration?.type ===
|
|
10110
|
+
const declaration = statement.type === import_utils64.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10111
|
+
if (declaration?.type === import_utils64.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9966
10112
|
}
|
|
9967
10113
|
return names;
|
|
9968
10114
|
};
|
|
@@ -9980,11 +10126,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9980
10126
|
var publicMethodNames = (body2) => {
|
|
9981
10127
|
const names = [];
|
|
9982
10128
|
for (const member of body2.body) {
|
|
9983
|
-
if (member.type !==
|
|
10129
|
+
if (member.type !== import_utils64.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9984
10130
|
if (member.kind !== "method" || member.static) continue;
|
|
9985
10131
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9986
|
-
if (member.key.type ===
|
|
9987
|
-
if (member.key.type ===
|
|
10132
|
+
if (member.key.type === import_utils64.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
10133
|
+
if (member.key.type === import_utils64.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9988
10134
|
else names.push("\u2026");
|
|
9989
10135
|
}
|
|
9990
10136
|
return names;
|
|
@@ -10017,7 +10163,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10017
10163
|
if (node.implements.length > 0) return;
|
|
10018
10164
|
if (node.decorators.length > 0) return;
|
|
10019
10165
|
const ctor = node.body.body.find(
|
|
10020
|
-
(member) => member.type ===
|
|
10166
|
+
(member) => member.type === import_utils64.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
10021
10167
|
);
|
|
10022
10168
|
if (ctor === void 0) return;
|
|
10023
10169
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -10046,37 +10192,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10046
10192
|
});
|
|
10047
10193
|
|
|
10048
10194
|
// src/rules/require-static-next-matcher.ts
|
|
10049
|
-
var
|
|
10195
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
10050
10196
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
10051
|
-
function
|
|
10052
|
-
if (node.type ===
|
|
10053
|
-
return
|
|
10197
|
+
function unwrapExpression2(node) {
|
|
10198
|
+
if (node.type === import_utils65.AST_NODE_TYPES.TSAsExpression || node.type === import_utils65.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils65.AST_NODE_TYPES.TSNonNullExpression || node.type === import_utils65.AST_NODE_TYPES.TSTypeAssertion) {
|
|
10199
|
+
return unwrapExpression2(node.expression);
|
|
10054
10200
|
}
|
|
10055
10201
|
return node;
|
|
10056
10202
|
}
|
|
10057
10203
|
function isStaticValue(node) {
|
|
10058
|
-
const value =
|
|
10059
|
-
if (value.type ===
|
|
10204
|
+
const value = unwrapExpression2(node);
|
|
10205
|
+
if (value.type === import_utils65.AST_NODE_TYPES.Literal) {
|
|
10060
10206
|
return true;
|
|
10061
10207
|
}
|
|
10062
|
-
if (value.type ===
|
|
10208
|
+
if (value.type === import_utils65.AST_NODE_TYPES.TemplateLiteral) {
|
|
10063
10209
|
return value.expressions.length === 0;
|
|
10064
10210
|
}
|
|
10065
|
-
if (value.type ===
|
|
10211
|
+
if (value.type === import_utils65.AST_NODE_TYPES.ArrayExpression) {
|
|
10066
10212
|
return value.elements.every(
|
|
10067
|
-
(element) => element !== null && element.type !==
|
|
10213
|
+
(element) => element !== null && element.type !== import_utils65.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
10068
10214
|
);
|
|
10069
10215
|
}
|
|
10070
|
-
if (value.type ===
|
|
10216
|
+
if (value.type === import_utils65.AST_NODE_TYPES.ObjectExpression) {
|
|
10071
10217
|
return value.properties.every(
|
|
10072
|
-
(property) => property.type ===
|
|
10218
|
+
(property) => property.type === import_utils65.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed && property.value.type !== import_utils65.AST_NODE_TYPES.AssignmentPattern && isStaticValue(property.value)
|
|
10073
10219
|
);
|
|
10074
10220
|
}
|
|
10075
10221
|
return false;
|
|
10076
10222
|
}
|
|
10077
10223
|
function propertyName2(property) {
|
|
10078
10224
|
if (property.computed) return null;
|
|
10079
|
-
if (property.key.type ===
|
|
10225
|
+
if (property.key.type === import_utils65.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
10080
10226
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
10081
10227
|
}
|
|
10082
10228
|
var require_static_next_matcher_default = createRule({
|
|
@@ -10098,19 +10244,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
10098
10244
|
}
|
|
10099
10245
|
return {
|
|
10100
10246
|
ExportNamedDeclaration(node) {
|
|
10101
|
-
if (node.declaration?.type !==
|
|
10247
|
+
if (node.declaration?.type !== import_utils65.AST_NODE_TYPES.VariableDeclaration) {
|
|
10102
10248
|
return;
|
|
10103
10249
|
}
|
|
10104
10250
|
for (const declaration of node.declaration.declarations) {
|
|
10105
|
-
if (declaration.id.type !==
|
|
10251
|
+
if (declaration.id.type !== import_utils65.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
10106
10252
|
continue;
|
|
10107
10253
|
}
|
|
10108
|
-
const config =
|
|
10109
|
-
if (config.type !==
|
|
10254
|
+
const config = unwrapExpression2(declaration.init);
|
|
10255
|
+
if (config.type !== import_utils65.AST_NODE_TYPES.ObjectExpression) {
|
|
10110
10256
|
continue;
|
|
10111
10257
|
}
|
|
10112
10258
|
for (const property of config.properties) {
|
|
10113
|
-
if (property.type !==
|
|
10259
|
+
if (property.type !== import_utils65.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) {
|
|
10114
10260
|
continue;
|
|
10115
10261
|
}
|
|
10116
10262
|
if (!isStaticValue(property.value)) {
|
|
@@ -10124,18 +10270,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
10124
10270
|
});
|
|
10125
10271
|
|
|
10126
10272
|
// src/rules/require-zod-form-validation.ts
|
|
10127
|
-
var
|
|
10273
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
10128
10274
|
var looksLikeZodSchema = (node) => {
|
|
10129
10275
|
let current = node;
|
|
10130
10276
|
while (true) {
|
|
10131
|
-
if (current.type ===
|
|
10277
|
+
if (current.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
10132
10278
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10133
10279
|
}
|
|
10134
|
-
if (current.type ===
|
|
10280
|
+
if (current.type === import_utils66.AST_NODE_TYPES.CallExpression) {
|
|
10135
10281
|
current = current.callee;
|
|
10136
10282
|
continue;
|
|
10137
10283
|
}
|
|
10138
|
-
if (current.type ===
|
|
10284
|
+
if (current.type === import_utils66.AST_NODE_TYPES.MemberExpression) {
|
|
10139
10285
|
current = current.object;
|
|
10140
10286
|
continue;
|
|
10141
10287
|
}
|
|
@@ -10143,23 +10289,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10143
10289
|
}
|
|
10144
10290
|
};
|
|
10145
10291
|
var isZodParseCall = (node) => {
|
|
10146
|
-
if (node.type !==
|
|
10292
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.CallExpression) return false;
|
|
10147
10293
|
const callee = node.callee;
|
|
10148
|
-
if (callee.type !==
|
|
10294
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression) return false;
|
|
10149
10295
|
if (callee.computed) return false;
|
|
10150
|
-
if (callee.property.type !==
|
|
10296
|
+
if (callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier) return false;
|
|
10151
10297
|
const method = callee.property.name;
|
|
10152
10298
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10153
10299
|
return looksLikeZodSchema(callee.object);
|
|
10154
10300
|
};
|
|
10155
10301
|
var isFormDataMethodCall = (node) => {
|
|
10156
10302
|
let current = node;
|
|
10157
|
-
if (current.type ===
|
|
10303
|
+
if (current.type === import_utils66.AST_NODE_TYPES.AwaitExpression) {
|
|
10158
10304
|
current = current.argument;
|
|
10159
10305
|
}
|
|
10160
|
-
if (current.type !==
|
|
10306
|
+
if (current.type !== import_utils66.AST_NODE_TYPES.CallExpression) return false;
|
|
10161
10307
|
const callee = current.callee;
|
|
10162
|
-
return callee.type ===
|
|
10308
|
+
return callee.type === import_utils66.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils66.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
10163
10309
|
};
|
|
10164
10310
|
var require_zod_form_validation_default = createRule({
|
|
10165
10311
|
name: "require-zod-form-validation",
|
|
@@ -10179,14 +10325,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10179
10325
|
return {};
|
|
10180
10326
|
}
|
|
10181
10327
|
const isFormSourceIdentifier = (node) => {
|
|
10182
|
-
if (node.type !==
|
|
10328
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.Identifier) return false;
|
|
10183
10329
|
if (/formdata/i.test(node.name)) return true;
|
|
10184
10330
|
let scope = context.sourceCode.getScope(node);
|
|
10185
10331
|
while (scope !== null) {
|
|
10186
10332
|
const variable = scope.set.get(node.name);
|
|
10187
10333
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10188
10334
|
const def = variable.defs[0];
|
|
10189
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10335
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils66.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
10190
10336
|
return isFormDataMethodCall(def.node.init);
|
|
10191
10337
|
}
|
|
10192
10338
|
return false;
|
|
@@ -10197,8 +10343,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10197
10343
|
};
|
|
10198
10344
|
const isFormDataGetCall = (node) => {
|
|
10199
10345
|
const callee = node.callee;
|
|
10200
|
-
if (callee.type !==
|
|
10201
|
-
if (callee.property.type !==
|
|
10346
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression) return false;
|
|
10347
|
+
if (callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
10202
10348
|
return false;
|
|
10203
10349
|
}
|
|
10204
10350
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10213,11 +10359,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10213
10359
|
};
|
|
10214
10360
|
const isInstanceofNarrowing = (node) => {
|
|
10215
10361
|
const parent = node.parent;
|
|
10216
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10362
|
+
return parent !== null && parent !== void 0 && parent.type === import_utils66.AST_NODE_TYPES.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === import_utils66.AST_NODE_TYPES.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
10217
10363
|
};
|
|
10218
10364
|
const boundDeclarator = (node) => {
|
|
10219
10365
|
const parent = node.parent;
|
|
10220
|
-
if (parent.type ===
|
|
10366
|
+
if (parent.type === import_utils66.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
10221
10367
|
return parent;
|
|
10222
10368
|
}
|
|
10223
10369
|
return null;
|
|
@@ -10245,7 +10391,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
10245
10391
|
});
|
|
10246
10392
|
|
|
10247
10393
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
10248
|
-
var
|
|
10394
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
10249
10395
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
10250
10396
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
10251
10397
|
var INSERT_GATE = /insert/i;
|
|
@@ -10276,7 +10422,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10276
10422
|
});
|
|
10277
10423
|
|
|
10278
10424
|
// src/rules/zod-naming-convention.ts
|
|
10279
|
-
var
|
|
10425
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
10280
10426
|
var CONVENTIONS = {
|
|
10281
10427
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10282
10428
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10301,15 +10447,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10301
10447
|
"registry",
|
|
10302
10448
|
"implement"
|
|
10303
10449
|
]);
|
|
10304
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10450
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils68.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
10305
10451
|
var calleeChainStartsWithZ = (node) => {
|
|
10306
10452
|
let current = node;
|
|
10307
|
-
while (current.type ===
|
|
10453
|
+
while (current.type === import_utils68.AST_NODE_TYPES.MemberExpression) {
|
|
10308
10454
|
const receiver = current.object;
|
|
10309
|
-
if (receiver.type ===
|
|
10455
|
+
if (receiver.type === import_utils68.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
10310
10456
|
return true;
|
|
10311
10457
|
}
|
|
10312
|
-
if (receiver.type ===
|
|
10458
|
+
if (receiver.type === import_utils68.AST_NODE_TYPES.CallExpression) {
|
|
10313
10459
|
current = receiver.callee;
|
|
10314
10460
|
continue;
|
|
10315
10461
|
}
|
|
@@ -10354,13 +10500,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10354
10500
|
VariableDeclarator(node) {
|
|
10355
10501
|
const init = node.init;
|
|
10356
10502
|
if (init === null || init === void 0) return;
|
|
10357
|
-
if (init.type !==
|
|
10503
|
+
if (init.type !== import_utils68.AST_NODE_TYPES.CallExpression) return;
|
|
10358
10504
|
const callee = init.callee;
|
|
10359
|
-
if (callee.type !==
|
|
10505
|
+
if (callee.type !== import_utils68.AST_NODE_TYPES.MemberExpression) return;
|
|
10360
10506
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10361
10507
|
const terminal = terminalMethodName(callee);
|
|
10362
10508
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10363
|
-
if (node.id.type !==
|
|
10509
|
+
if (node.id.type !== import_utils68.AST_NODE_TYPES.Identifier) return;
|
|
10364
10510
|
if (test.test(node.id.name)) return;
|
|
10365
10511
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10366
10512
|
context.report({
|
|
@@ -10472,6 +10618,7 @@ var rules = {
|
|
|
10472
10618
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10473
10619
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10474
10620
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10621
|
+
"prefer-immutable-module-constant": prefer_immutable_module_constant_default,
|
|
10475
10622
|
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
10476
10623
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10477
10624
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
@@ -10495,7 +10642,7 @@ var rules = {
|
|
|
10495
10642
|
};
|
|
10496
10643
|
var meta = {
|
|
10497
10644
|
name: "@sarj/eslint-plugin",
|
|
10498
|
-
version: "9.
|
|
10645
|
+
version: "9.13.1"
|
|
10499
10646
|
};
|
|
10500
10647
|
var applicationOnlyRules = [
|
|
10501
10648
|
"no-restricted-library-load",
|
|
@@ -10540,6 +10687,7 @@ var recommendedRules = {
|
|
|
10540
10687
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10541
10688
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10542
10689
|
"@sarj/prefer-input-group-search": "error",
|
|
10690
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10543
10691
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10544
10692
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10545
10693
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10601,6 +10749,7 @@ var strictRules = {
|
|
|
10601
10749
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10602
10750
|
"@sarj/prefer-discriminated-union": "error",
|
|
10603
10751
|
"@sarj/prefer-input-group-search": "error",
|
|
10752
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10604
10753
|
"@sarj/prefer-module-level-constant": "error",
|
|
10605
10754
|
"@sarj/prefer-module-level-schema": "error",
|
|
10606
10755
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10651,4 +10800,3 @@ var index_default = plugin;
|
|
|
10651
10800
|
rules,
|
|
10652
10801
|
strictRules
|
|
10653
10802
|
});
|
|
10654
|
-
//# sourceMappingURL=index.cjs.map
|