@sarj/eslint-plugin 9.11.0 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.cjs +617 -345
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +612 -340
- package/package.json +10 -2
- 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,276 @@ var prefer_input_group_search_default = createRule({
|
|
|
6747
6747
|
}
|
|
6748
6748
|
});
|
|
6749
6749
|
|
|
6750
|
-
// src/rules/prefer-module-
|
|
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) {
|
|
6781
|
+
const inner = unwrapExpression(node);
|
|
6782
|
+
return 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" && inner.callee.property.type === import_utils49.AST_NODE_TYPES.Identifier && inner.callee.property.name === "freeze";
|
|
6783
|
+
}
|
|
6784
|
+
function collectionKind(node) {
|
|
6785
|
+
const inner = unwrapExpression(node);
|
|
6786
|
+
if (inner.type === import_utils49.AST_NODE_TYPES.ArrayExpression || inner.type === import_utils49.AST_NODE_TYPES.ObjectExpression) {
|
|
6787
|
+
return "literal";
|
|
6788
|
+
}
|
|
6789
|
+
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")) {
|
|
6790
|
+
return inner.callee.name;
|
|
6791
|
+
}
|
|
6792
|
+
return null;
|
|
6793
|
+
}
|
|
6794
|
+
function isReadonlyType(node, kind) {
|
|
6795
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSTypeOperator && node.operator === "readonly") {
|
|
6796
|
+
return true;
|
|
6797
|
+
}
|
|
6798
|
+
if (node.type !== import_utils49.AST_NODE_TYPES.TSTypeReference || node.typeName.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
6799
|
+
return false;
|
|
6800
|
+
}
|
|
6801
|
+
if (node.typeName.name === "Readonly") {
|
|
6802
|
+
return true;
|
|
6803
|
+
}
|
|
6804
|
+
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6805
|
+
}
|
|
6806
|
+
function declaredReadonlyType(node, kind) {
|
|
6807
|
+
const annotation = node.id.type === import_utils49.AST_NODE_TYPES.Identifier ? node.id.typeAnnotation : void 0;
|
|
6808
|
+
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6809
|
+
return true;
|
|
6810
|
+
}
|
|
6811
|
+
return node.init?.type === import_utils49.AST_NODE_TYPES.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6812
|
+
}
|
|
6813
|
+
function referenceMutates(identifier) {
|
|
6814
|
+
let member = identifier.parent;
|
|
6815
|
+
if (member?.type !== import_utils49.AST_NODE_TYPES.MemberExpression || member.object !== identifier) {
|
|
6816
|
+
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";
|
|
6817
|
+
}
|
|
6818
|
+
while (member.parent.type === import_utils49.AST_NODE_TYPES.MemberExpression && member.parent.object === member) {
|
|
6819
|
+
member = member.parent;
|
|
6820
|
+
}
|
|
6821
|
+
const parent = member.parent;
|
|
6822
|
+
if (parent?.type === import_utils49.AST_NODE_TYPES.AssignmentExpression && parent.left === member) {
|
|
6823
|
+
return true;
|
|
6824
|
+
}
|
|
6825
|
+
if (parent?.type === import_utils49.AST_NODE_TYPES.UpdateExpression && parent.argument === member) {
|
|
6826
|
+
return true;
|
|
6827
|
+
}
|
|
6828
|
+
if (parent?.type === import_utils49.AST_NODE_TYPES.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6829
|
+
return true;
|
|
6830
|
+
}
|
|
6831
|
+
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);
|
|
6832
|
+
}
|
|
6833
|
+
var prefer_immutable_module_constant_default = createRule({
|
|
6834
|
+
name: "prefer-immutable-module-constant",
|
|
6835
|
+
meta: {
|
|
6836
|
+
type: "suggestion",
|
|
6837
|
+
docs: {
|
|
6838
|
+
description: "Require module-level constant collections to expose readonly state."
|
|
6839
|
+
},
|
|
6840
|
+
schema: [],
|
|
6841
|
+
messages: {
|
|
6842
|
+
preferAsConst: "Module constant `{{name}}` is a mutable literal. Add `as const` or use `Object.freeze` so consumers cannot mutate shared state.",
|
|
6843
|
+
preferReadonlyCollection: "Module constant `{{name}}` is a mutable {{kind}}. Expose it as `Readonly{{kind}}` or an immutable collection."
|
|
6844
|
+
}
|
|
6845
|
+
},
|
|
6846
|
+
defaultOptions: [],
|
|
6847
|
+
create(context) {
|
|
6848
|
+
const sourceCode = context.sourceCode;
|
|
6849
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
6850
|
+
return {};
|
|
6851
|
+
}
|
|
6852
|
+
return {
|
|
6853
|
+
VariableDeclarator(node) {
|
|
6854
|
+
const declaration = node.parent;
|
|
6855
|
+
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)) {
|
|
6856
|
+
return;
|
|
6857
|
+
}
|
|
6858
|
+
const container = declaration.parent;
|
|
6859
|
+
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)) {
|
|
6860
|
+
return;
|
|
6861
|
+
}
|
|
6862
|
+
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init)) {
|
|
6863
|
+
return;
|
|
6864
|
+
}
|
|
6865
|
+
const kind = collectionKind(node.init);
|
|
6866
|
+
if (kind === null || declaredReadonlyType(node, kind)) {
|
|
6867
|
+
return;
|
|
6868
|
+
}
|
|
6869
|
+
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6870
|
+
if (variable?.references.some(
|
|
6871
|
+
(reference) => reference.identifier.type === import_utils49.AST_NODE_TYPES.Identifier && referenceMutates(reference.identifier)
|
|
6872
|
+
) === true) {
|
|
6873
|
+
return;
|
|
6874
|
+
}
|
|
6875
|
+
context.report({
|
|
6876
|
+
node: node.id,
|
|
6877
|
+
messageId: kind === "literal" ? "preferAsConst" : "preferReadonlyCollection",
|
|
6878
|
+
data: { name: node.id.name, kind }
|
|
6879
|
+
});
|
|
6880
|
+
}
|
|
6881
|
+
};
|
|
6882
|
+
}
|
|
6883
|
+
});
|
|
6884
|
+
|
|
6885
|
+
// src/rules/prefer-shadcn-primitives.ts
|
|
6886
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
6887
|
+
var SHADCN_PRIMITIVES = {
|
|
6888
|
+
button: "Button",
|
|
6889
|
+
dialog: "Dialog or AlertDialog family",
|
|
6890
|
+
input: "Input",
|
|
6891
|
+
label: "Label",
|
|
6892
|
+
progress: "Progress",
|
|
6893
|
+
select: "Select family",
|
|
6894
|
+
table: "Table family",
|
|
6895
|
+
textarea: "Textarea"
|
|
6896
|
+
};
|
|
6897
|
+
var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
6898
|
+
"button",
|
|
6899
|
+
"input",
|
|
6900
|
+
"meter",
|
|
6901
|
+
"output",
|
|
6902
|
+
"progress",
|
|
6903
|
+
"select",
|
|
6904
|
+
"textarea"
|
|
6905
|
+
]);
|
|
6906
|
+
function rawElementName(node) {
|
|
6907
|
+
if (node.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier) return null;
|
|
6908
|
+
const name = node.name.name;
|
|
6909
|
+
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6910
|
+
}
|
|
6911
|
+
function staticExpressionString(expression) {
|
|
6912
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.Literal) {
|
|
6913
|
+
return typeof expression.value === "string" ? expression.value : null;
|
|
6914
|
+
}
|
|
6915
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.TemplateLiteral) {
|
|
6916
|
+
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6917
|
+
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6918
|
+
const staticSubstitution = staticExpressionString(substitution);
|
|
6919
|
+
if (staticSubstitution === null) return null;
|
|
6920
|
+
value += staticSubstitution;
|
|
6921
|
+
value += expression.quasis[index + 1]?.value.cooked ?? "";
|
|
6922
|
+
}
|
|
6923
|
+
return value;
|
|
6924
|
+
}
|
|
6925
|
+
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) {
|
|
6926
|
+
return staticExpressionString(expression.expression);
|
|
6927
|
+
}
|
|
6928
|
+
return null;
|
|
6929
|
+
}
|
|
6930
|
+
function staticString(value) {
|
|
6931
|
+
if (value?.type === import_utils50.AST_NODE_TYPES.Literal) {
|
|
6932
|
+
return typeof value.value === "string" ? value.value : null;
|
|
6933
|
+
}
|
|
6934
|
+
if (value?.type !== import_utils50.AST_NODE_TYPES.JSXExpressionContainer) return null;
|
|
6935
|
+
return staticExpressionString(value.expression);
|
|
6936
|
+
}
|
|
6937
|
+
function effectiveAttribute(node, attributeName) {
|
|
6938
|
+
for (const attribute of node.attributes.toReversed()) {
|
|
6939
|
+
if (attribute.type === import_utils50.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
6940
|
+
return { kind: "unknown" };
|
|
6941
|
+
}
|
|
6942
|
+
if (attribute.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6943
|
+
continue;
|
|
6944
|
+
}
|
|
6945
|
+
const value = staticString(attribute.value);
|
|
6946
|
+
return value === null ? { kind: "unknown" } : { kind: "known", value };
|
|
6947
|
+
}
|
|
6948
|
+
return { kind: "missing" };
|
|
6949
|
+
}
|
|
6950
|
+
function isLabelableElement(node) {
|
|
6951
|
+
if (node.openingElement.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier) {
|
|
6952
|
+
return false;
|
|
6953
|
+
}
|
|
6954
|
+
const name = node.openingElement.name.name;
|
|
6955
|
+
if (!LABELABLE_ELEMENTS.has(name)) return false;
|
|
6956
|
+
if (name !== "input") return true;
|
|
6957
|
+
const typeAttribute = effectiveAttribute(node.openingElement, "type");
|
|
6958
|
+
if (typeAttribute.kind === "unknown") return false;
|
|
6959
|
+
return !(typeAttribute.kind === "known" && typeAttribute.value.toLowerCase() === "hidden");
|
|
6960
|
+
}
|
|
6961
|
+
function containsLabelableElement(node) {
|
|
6962
|
+
return node.children.some((child) => {
|
|
6963
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXElement) {
|
|
6964
|
+
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6965
|
+
}
|
|
6966
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXFragment) {
|
|
6967
|
+
return containsLabelableElement(child);
|
|
6968
|
+
}
|
|
6969
|
+
return false;
|
|
6970
|
+
});
|
|
6971
|
+
}
|
|
6972
|
+
function isStaticallyAssociatedLabel(node) {
|
|
6973
|
+
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6974
|
+
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6975
|
+
return node.parent.type === import_utils50.AST_NODE_TYPES.JSXElement && containsLabelableElement(node.parent);
|
|
6976
|
+
}
|
|
6977
|
+
function replacementFor(node, element) {
|
|
6978
|
+
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
6979
|
+
const typeAttribute = effectiveAttribute(node, "type");
|
|
6980
|
+
if (typeAttribute.kind === "unknown") return null;
|
|
6981
|
+
const inputType = typeAttribute.kind === "known" ? typeAttribute.value.toLowerCase() : "text";
|
|
6982
|
+
if (inputType === "hidden" || inputType === "file") return null;
|
|
6983
|
+
if (inputType === "checkbox") return "Checkbox";
|
|
6984
|
+
if (inputType === "radio") return "RadioGroup family";
|
|
6985
|
+
return "Input";
|
|
6986
|
+
}
|
|
6987
|
+
var prefer_shadcn_primitives_default = createRule({
|
|
6988
|
+
name: "prefer-shadcn-primitives",
|
|
6989
|
+
meta: {
|
|
6990
|
+
type: "suggestion",
|
|
6991
|
+
docs: {
|
|
6992
|
+
description: "Require visible raw JSX controls to use the corresponding shared shadcn primitive."
|
|
6993
|
+
},
|
|
6994
|
+
schema: [],
|
|
6995
|
+
messages: {
|
|
6996
|
+
preferShadcnPrimitive: "Use the shared {{ replacement }} shadcn primitive instead of raw <{{ element }}> markup."
|
|
6997
|
+
}
|
|
6998
|
+
},
|
|
6999
|
+
defaultOptions: [],
|
|
7000
|
+
create(context) {
|
|
7001
|
+
return {
|
|
7002
|
+
JSXOpeningElement(node) {
|
|
7003
|
+
const element = rawElementName(node);
|
|
7004
|
+
if (element === null) return;
|
|
7005
|
+
if (element === "label" && !isStaticallyAssociatedLabel(node)) return;
|
|
7006
|
+
const replacement = replacementFor(node, element);
|
|
7007
|
+
if (replacement === null) return;
|
|
7008
|
+
context.report({
|
|
7009
|
+
node,
|
|
7010
|
+
messageId: "preferShadcnPrimitive",
|
|
7011
|
+
data: { element, replacement }
|
|
7012
|
+
});
|
|
7013
|
+
}
|
|
7014
|
+
};
|
|
7015
|
+
}
|
|
7016
|
+
});
|
|
7017
|
+
|
|
7018
|
+
// src/rules/prefer-module-level-constant.ts
|
|
7019
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
6752
7020
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6753
7021
|
var MAX_LITERAL_DEPTH = 4;
|
|
6754
7022
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6757,7 +7025,7 @@ var IGNORE_PATTERNS2 = [
|
|
|
6757
7025
|
/\.generated\.tsx?$/,
|
|
6758
7026
|
/\.d\.ts$/
|
|
6759
7027
|
];
|
|
6760
|
-
var
|
|
7028
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
6761
7029
|
// Array
|
|
6762
7030
|
"push",
|
|
6763
7031
|
"pop",
|
|
@@ -6777,9 +7045,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6777
7045
|
"assign"
|
|
6778
7046
|
]);
|
|
6779
7047
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
7048
|
+
import_utils51.AST_NODE_TYPES.FunctionDeclaration,
|
|
7049
|
+
import_utils51.AST_NODE_TYPES.FunctionExpression,
|
|
7050
|
+
import_utils51.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6783
7051
|
]);
|
|
6784
7052
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6785
7053
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6792,14 +7060,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6792
7060
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6793
7061
|
}
|
|
6794
7062
|
function unwrap3(node) {
|
|
6795
|
-
if (node.type ===
|
|
7063
|
+
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) {
|
|
6796
7064
|
return unwrap3(node.expression);
|
|
6797
7065
|
}
|
|
6798
7066
|
return node;
|
|
6799
7067
|
}
|
|
6800
7068
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6801
7069
|
function isRegexLiteral(node) {
|
|
6802
|
-
return node.type ===
|
|
7070
|
+
return node.type === import_utils51.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6803
7071
|
}
|
|
6804
7072
|
function isLiteralOnly(node, depth) {
|
|
6805
7073
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6807,29 +7075,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6807
7075
|
}
|
|
6808
7076
|
const inner = unwrap3(node);
|
|
6809
7077
|
switch (inner.type) {
|
|
6810
|
-
case
|
|
7078
|
+
case import_utils51.AST_NODE_TYPES.Literal: {
|
|
6811
7079
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6812
7080
|
}
|
|
6813
|
-
case
|
|
7081
|
+
case import_utils51.AST_NODE_TYPES.TemplateLiteral: {
|
|
6814
7082
|
return inner.expressions.length === 0;
|
|
6815
7083
|
}
|
|
6816
|
-
case
|
|
6817
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
7084
|
+
case import_utils51.AST_NODE_TYPES.UnaryExpression: {
|
|
7085
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === import_utils51.AST_NODE_TYPES.Literal && typeof inner.argument.value === "number";
|
|
6818
7086
|
}
|
|
6819
|
-
case
|
|
7087
|
+
case import_utils51.AST_NODE_TYPES.ArrayExpression: {
|
|
6820
7088
|
return inner.elements.every(
|
|
6821
|
-
(el) => el !== null && el.type !==
|
|
7089
|
+
(el) => el !== null && el.type !== import_utils51.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6822
7090
|
);
|
|
6823
7091
|
}
|
|
6824
|
-
case
|
|
7092
|
+
case import_utils51.AST_NODE_TYPES.ObjectExpression: {
|
|
6825
7093
|
return inner.properties.every((prop) => {
|
|
6826
|
-
if (prop.type !==
|
|
7094
|
+
if (prop.type !== import_utils51.AST_NODE_TYPES.Property) {
|
|
6827
7095
|
return false;
|
|
6828
7096
|
}
|
|
6829
7097
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6830
7098
|
return false;
|
|
6831
7099
|
}
|
|
6832
|
-
if (prop.computed && prop.key.type !==
|
|
7100
|
+
if (prop.computed && prop.key.type !== import_utils51.AST_NODE_TYPES.Literal) {
|
|
6833
7101
|
return false;
|
|
6834
7102
|
}
|
|
6835
7103
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6842,7 +7110,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6842
7110
|
}
|
|
6843
7111
|
function unwrapObjectFreeze(node) {
|
|
6844
7112
|
const inner = unwrap3(node);
|
|
6845
|
-
if (inner.type ===
|
|
7113
|
+
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) {
|
|
6846
7114
|
return unwrap3(inner.arguments[0]);
|
|
6847
7115
|
}
|
|
6848
7116
|
return inner;
|
|
@@ -6858,19 +7126,19 @@ function classify(init, checkRegex) {
|
|
|
6858
7126
|
}
|
|
6859
7127
|
return { kind: "regex", size: 1 };
|
|
6860
7128
|
}
|
|
6861
|
-
if (node.type ===
|
|
7129
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ArrayExpression) {
|
|
6862
7130
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6863
7131
|
}
|
|
6864
|
-
if (node.type ===
|
|
7132
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ObjectExpression) {
|
|
6865
7133
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6866
7134
|
}
|
|
6867
|
-
if (node.type ===
|
|
7135
|
+
if (node.type === import_utils51.AST_NODE_TYPES.NewExpression && node.callee.type === import_utils51.AST_NODE_TYPES.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6868
7136
|
const arg = node.arguments[0];
|
|
6869
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
7137
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
6870
7138
|
return null;
|
|
6871
7139
|
}
|
|
6872
7140
|
const entries = unwrap3(arg);
|
|
6873
|
-
if (entries.type !==
|
|
7141
|
+
if (entries.type !== import_utils51.AST_NODE_TYPES.ArrayExpression) {
|
|
6874
7142
|
return null;
|
|
6875
7143
|
}
|
|
6876
7144
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6899,10 +7167,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6899
7167
|
);
|
|
6900
7168
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6901
7169
|
const callee = node.callee;
|
|
6902
|
-
if (callee.type ===
|
|
7170
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
6903
7171
|
return true;
|
|
6904
7172
|
}
|
|
6905
|
-
if (callee.type !==
|
|
7173
|
+
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) {
|
|
6906
7174
|
return false;
|
|
6907
7175
|
}
|
|
6908
7176
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6916,38 +7184,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6916
7184
|
}
|
|
6917
7185
|
function isSafeRead(identifier) {
|
|
6918
7186
|
const parent = identifier.parent;
|
|
6919
|
-
if (parent.type ===
|
|
7187
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
6920
7188
|
if (parent.object !== identifier) {
|
|
6921
7189
|
return true;
|
|
6922
7190
|
}
|
|
6923
7191
|
const grandparent = parent.parent;
|
|
6924
|
-
if (grandparent.type ===
|
|
7192
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
6925
7193
|
return false;
|
|
6926
7194
|
}
|
|
6927
|
-
if (grandparent.type ===
|
|
7195
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.UpdateExpression) {
|
|
6928
7196
|
return false;
|
|
6929
7197
|
}
|
|
6930
|
-
if (grandparent.type ===
|
|
7198
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
6931
7199
|
return false;
|
|
6932
7200
|
}
|
|
6933
|
-
if (!parent.computed && parent.property.type ===
|
|
7201
|
+
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) {
|
|
6934
7202
|
return false;
|
|
6935
7203
|
}
|
|
6936
7204
|
return true;
|
|
6937
7205
|
}
|
|
6938
|
-
if (parent.type ===
|
|
7206
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
6939
7207
|
return true;
|
|
6940
7208
|
}
|
|
6941
|
-
if (parent.type ===
|
|
7209
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
6942
7210
|
return true;
|
|
6943
7211
|
}
|
|
6944
|
-
if (parent.type ===
|
|
7212
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.BinaryExpression) {
|
|
6945
7213
|
return true;
|
|
6946
7214
|
}
|
|
6947
|
-
if (parent.type ===
|
|
7215
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6948
7216
|
return true;
|
|
6949
7217
|
}
|
|
6950
|
-
if (parent.type ===
|
|
7218
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
6951
7219
|
return true;
|
|
6952
7220
|
}
|
|
6953
7221
|
return false;
|
|
@@ -7002,7 +7270,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7002
7270
|
if (reference.isWrite()) {
|
|
7003
7271
|
return false;
|
|
7004
7272
|
}
|
|
7005
|
-
if (reference.identifier.type !==
|
|
7273
|
+
if (reference.identifier.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7006
7274
|
return false;
|
|
7007
7275
|
}
|
|
7008
7276
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7014,10 +7282,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7014
7282
|
return {
|
|
7015
7283
|
VariableDeclarator(node) {
|
|
7016
7284
|
const declaration = node.parent;
|
|
7017
|
-
if (declaration.type !==
|
|
7285
|
+
if (declaration.type !== import_utils51.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7018
7286
|
return;
|
|
7019
7287
|
}
|
|
7020
|
-
if (node.id.type !==
|
|
7288
|
+
if (node.id.type !== import_utils51.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
7021
7289
|
return;
|
|
7022
7290
|
}
|
|
7023
7291
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7044,7 +7312,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7044
7312
|
});
|
|
7045
7313
|
|
|
7046
7314
|
// src/rules/prefer-module-level-schema.ts
|
|
7047
|
-
var
|
|
7315
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7048
7316
|
|
|
7049
7317
|
// src/rules/_zod.ts
|
|
7050
7318
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7110,9 +7378,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7110
7378
|
"intl"
|
|
7111
7379
|
]);
|
|
7112
7380
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7381
|
+
import_utils52.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
7382
|
+
import_utils52.AST_NODE_TYPES.FunctionDeclaration,
|
|
7383
|
+
import_utils52.AST_NODE_TYPES.FunctionExpression
|
|
7116
7384
|
]);
|
|
7117
7385
|
function schemaExpression(node) {
|
|
7118
7386
|
let current = node;
|
|
@@ -7121,10 +7389,10 @@ function schemaExpression(node) {
|
|
|
7121
7389
|
if (parent === void 0) {
|
|
7122
7390
|
return current;
|
|
7123
7391
|
}
|
|
7124
|
-
if (parent.type ===
|
|
7392
|
+
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)) {
|
|
7125
7393
|
return current;
|
|
7126
7394
|
}
|
|
7127
|
-
if (parent.type ===
|
|
7395
|
+
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) {
|
|
7128
7396
|
current = parent;
|
|
7129
7397
|
continue;
|
|
7130
7398
|
}
|
|
@@ -7175,22 +7443,22 @@ function subtreeSome(root, predicate) {
|
|
|
7175
7443
|
function readsReceiver(node) {
|
|
7176
7444
|
return subtreeSome(
|
|
7177
7445
|
node,
|
|
7178
|
-
(inner) => inner.type ===
|
|
7446
|
+
(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"
|
|
7179
7447
|
);
|
|
7180
7448
|
}
|
|
7181
7449
|
function buildsLocalizedText(node) {
|
|
7182
7450
|
return subtreeSome(node, (inner) => {
|
|
7183
|
-
if (inner.type ===
|
|
7451
|
+
if (inner.type === import_utils52.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
7184
7452
|
return true;
|
|
7185
7453
|
}
|
|
7186
|
-
if (inner.type !==
|
|
7454
|
+
if (inner.type !== import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7187
7455
|
return false;
|
|
7188
7456
|
}
|
|
7189
7457
|
const { callee } = inner;
|
|
7190
|
-
if (callee.type ===
|
|
7458
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7191
7459
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7192
7460
|
}
|
|
7193
|
-
return callee.type ===
|
|
7461
|
+
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);
|
|
7194
7462
|
});
|
|
7195
7463
|
}
|
|
7196
7464
|
function collectReferences(scope, out) {
|
|
@@ -7247,15 +7515,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7247
7515
|
}
|
|
7248
7516
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7249
7517
|
function isZodCall(node) {
|
|
7250
|
-
return node.type ===
|
|
7518
|
+
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);
|
|
7251
7519
|
}
|
|
7252
7520
|
function isCovered(node) {
|
|
7253
7521
|
let current = node.parent ?? void 0;
|
|
7254
7522
|
while (current !== void 0) {
|
|
7255
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7523
|
+
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)) {
|
|
7256
7524
|
return true;
|
|
7257
7525
|
}
|
|
7258
|
-
if (current.type ===
|
|
7526
|
+
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))) {
|
|
7259
7527
|
return true;
|
|
7260
7528
|
}
|
|
7261
7529
|
current = current.parent ?? void 0;
|
|
@@ -7270,11 +7538,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7270
7538
|
if (parent === void 0) {
|
|
7271
7539
|
return confirmed;
|
|
7272
7540
|
}
|
|
7273
|
-
if (parent.type ===
|
|
7541
|
+
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) {
|
|
7274
7542
|
current = parent;
|
|
7275
7543
|
continue;
|
|
7276
7544
|
}
|
|
7277
|
-
if (parent.type ===
|
|
7545
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7278
7546
|
current = schemaExpression(parent);
|
|
7279
7547
|
confirmed = current;
|
|
7280
7548
|
continue;
|
|
@@ -7284,7 +7552,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7284
7552
|
}
|
|
7285
7553
|
function isSchemaComposition(node) {
|
|
7286
7554
|
const { callee } = node;
|
|
7287
|
-
const isCombinator = callee.type ===
|
|
7555
|
+
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);
|
|
7288
7556
|
return isCombinator || isZodCall(node);
|
|
7289
7557
|
}
|
|
7290
7558
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7318,13 +7586,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7318
7586
|
}
|
|
7319
7587
|
function ownerName(enclosing) {
|
|
7320
7588
|
const parent = enclosing.parent ?? void 0;
|
|
7321
|
-
if (enclosing.type ===
|
|
7589
|
+
if (enclosing.type === import_utils52.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7322
7590
|
return enclosing.id.name;
|
|
7323
7591
|
}
|
|
7324
|
-
if (parent !== void 0 && parent.type ===
|
|
7592
|
+
if (parent !== void 0 && parent.type === import_utils52.AST_NODE_TYPES.VariableDeclarator && parent.id.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7325
7593
|
return parent.id.name;
|
|
7326
7594
|
}
|
|
7327
|
-
if (parent !== void 0 && (parent.type ===
|
|
7595
|
+
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) {
|
|
7328
7596
|
return parent.key.name;
|
|
7329
7597
|
}
|
|
7330
7598
|
return "this function";
|
|
@@ -7335,7 +7603,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7335
7603
|
return;
|
|
7336
7604
|
}
|
|
7337
7605
|
for (const specifier of node.specifiers) {
|
|
7338
|
-
if (specifier.type ===
|
|
7606
|
+
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") {
|
|
7339
7607
|
zodNamespaces.add(specifier.local.name);
|
|
7340
7608
|
}
|
|
7341
7609
|
}
|
|
@@ -7345,7 +7613,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7345
7613
|
return;
|
|
7346
7614
|
}
|
|
7347
7615
|
const callee = node.callee;
|
|
7348
|
-
if (callee.property.type !==
|
|
7616
|
+
if (callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7349
7617
|
return;
|
|
7350
7618
|
}
|
|
7351
7619
|
const factory = callee.property.name;
|
|
@@ -7360,7 +7628,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7360
7628
|
return;
|
|
7361
7629
|
}
|
|
7362
7630
|
const shape = node.arguments[0];
|
|
7363
|
-
if (shape !== void 0 && shape.type ===
|
|
7631
|
+
if (shape !== void 0 && shape.type === import_utils52.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7364
7632
|
return;
|
|
7365
7633
|
}
|
|
7366
7634
|
const expression = schemaExpression(node);
|
|
@@ -7388,9 +7656,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7388
7656
|
});
|
|
7389
7657
|
|
|
7390
7658
|
// src/rules/prefer-native-random-uuid.ts
|
|
7391
|
-
var
|
|
7659
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7392
7660
|
function requireUuid(node) {
|
|
7393
|
-
return node?.type ===
|
|
7661
|
+
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";
|
|
7394
7662
|
}
|
|
7395
7663
|
var prefer_native_random_uuid_default = createRule({
|
|
7396
7664
|
name: "prefer-native-random-uuid",
|
|
@@ -7411,7 +7679,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7411
7679
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7412
7680
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7413
7681
|
function resolve(identifier) {
|
|
7414
|
-
return
|
|
7682
|
+
return import_utils53.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7415
7683
|
}
|
|
7416
7684
|
function record(identifier, destination) {
|
|
7417
7685
|
const variable = resolve(identifier);
|
|
@@ -7433,37 +7701,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7433
7701
|
ImportDeclaration(node) {
|
|
7434
7702
|
if (node.source.value !== "uuid") return;
|
|
7435
7703
|
for (const specifier of node.specifiers) {
|
|
7436
|
-
if (specifier.type ===
|
|
7704
|
+
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")) {
|
|
7437
7705
|
record(specifier.local, directBindings);
|
|
7438
|
-
} else if (specifier.type ===
|
|
7706
|
+
} else if (specifier.type === import_utils53.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7439
7707
|
record(specifier.local, namespaceBindings);
|
|
7440
7708
|
}
|
|
7441
7709
|
}
|
|
7442
7710
|
},
|
|
7443
7711
|
VariableDeclarator(node) {
|
|
7444
7712
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7445
|
-
if (node.init?.type !==
|
|
7713
|
+
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) {
|
|
7446
7714
|
return;
|
|
7447
7715
|
}
|
|
7448
|
-
if (node.id.type ===
|
|
7716
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7449
7717
|
record(node.id, namespaceBindings);
|
|
7450
7718
|
return;
|
|
7451
7719
|
}
|
|
7452
|
-
if (node.id.type !==
|
|
7720
|
+
if (node.id.type !== import_utils53.AST_NODE_TYPES.ObjectPattern) return;
|
|
7453
7721
|
for (const property of node.id.properties) {
|
|
7454
|
-
if (property.type ===
|
|
7722
|
+
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) {
|
|
7455
7723
|
record(property.value, directBindings);
|
|
7456
7724
|
}
|
|
7457
7725
|
}
|
|
7458
7726
|
},
|
|
7459
7727
|
"CallExpression:exit"(node) {
|
|
7460
7728
|
if (node.arguments.length !== 0) return;
|
|
7461
|
-
if (node.callee.type ===
|
|
7729
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7462
7730
|
const variable2 = resolve(node.callee);
|
|
7463
7731
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7464
7732
|
return;
|
|
7465
7733
|
}
|
|
7466
|
-
if (node.callee.type !==
|
|
7734
|
+
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") {
|
|
7467
7735
|
return;
|
|
7468
7736
|
}
|
|
7469
7737
|
const variable = resolve(node.callee.object);
|
|
@@ -7474,20 +7742,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7474
7742
|
});
|
|
7475
7743
|
|
|
7476
7744
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7477
|
-
var
|
|
7745
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7478
7746
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7479
7747
|
function propertyName(node) {
|
|
7480
7748
|
const key = node.key;
|
|
7481
|
-
if (key.type ===
|
|
7482
|
-
if (key.type ===
|
|
7749
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Identifier) return key.name;
|
|
7750
|
+
if (key.type === import_utils54.AST_NODE_TYPES.Literal) return String(key.value);
|
|
7483
7751
|
return "collection";
|
|
7484
7752
|
}
|
|
7485
7753
|
function isArrayType(node) {
|
|
7486
|
-
if (node.type ===
|
|
7487
|
-
return node.type ===
|
|
7754
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSArrayType) return true;
|
|
7755
|
+
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);
|
|
7488
7756
|
}
|
|
7489
7757
|
function isNullishType(node) {
|
|
7490
|
-
return node.type ===
|
|
7758
|
+
return node.type === import_utils54.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils54.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7491
7759
|
}
|
|
7492
7760
|
function isNullableArrayOnly(node) {
|
|
7493
7761
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7515,7 +7783,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7515
7783
|
if (node.optional) return;
|
|
7516
7784
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7517
7785
|
if (annotation === void 0) return;
|
|
7518
|
-
if (annotation.type !==
|
|
7786
|
+
if (annotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7519
7787
|
return;
|
|
7520
7788
|
}
|
|
7521
7789
|
context.report({
|
|
@@ -7528,7 +7796,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7528
7796
|
TSPropertySignature: checkOptionalProperty,
|
|
7529
7797
|
PropertyDefinition: checkOptionalProperty,
|
|
7530
7798
|
TSTypeAliasDeclaration(node) {
|
|
7531
|
-
if (node.typeAnnotation.type !==
|
|
7799
|
+
if (node.typeAnnotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType) return;
|
|
7532
7800
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7533
7801
|
context.report({
|
|
7534
7802
|
node,
|
|
@@ -7541,13 +7809,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7541
7809
|
});
|
|
7542
7810
|
|
|
7543
7811
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7544
|
-
var
|
|
7812
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
7545
7813
|
var unwrap4 = (node) => {
|
|
7546
7814
|
let current = node;
|
|
7547
7815
|
while (current !== null && current !== void 0) {
|
|
7548
|
-
if (current.type ===
|
|
7816
|
+
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) {
|
|
7549
7817
|
current = current.expression;
|
|
7550
|
-
} else if (current.type ===
|
|
7818
|
+
} else if (current.type === import_utils55.AST_NODE_TYPES.ChainExpression) {
|
|
7551
7819
|
current = current.expression;
|
|
7552
7820
|
} else {
|
|
7553
7821
|
break;
|
|
@@ -7562,23 +7830,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7562
7830
|
]);
|
|
7563
7831
|
var isSchemaParseReference = (node) => {
|
|
7564
7832
|
const inner = unwrap4(node);
|
|
7565
|
-
return inner !== null && inner.type ===
|
|
7833
|
+
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");
|
|
7566
7834
|
};
|
|
7567
7835
|
var isRawPayloadSource = (node) => {
|
|
7568
7836
|
let current = unwrap4(node);
|
|
7569
7837
|
if (current === null) return false;
|
|
7570
|
-
if (current.type ===
|
|
7838
|
+
if (current.type === import_utils55.AST_NODE_TYPES.AwaitExpression) {
|
|
7571
7839
|
current = unwrap4(current.argument);
|
|
7572
7840
|
}
|
|
7573
|
-
if (current === null || current.type !==
|
|
7841
|
+
if (current === null || current.type !== import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7574
7842
|
return false;
|
|
7575
7843
|
}
|
|
7576
7844
|
const callee = unwrap4(current.callee);
|
|
7577
|
-
if (callee === null || callee.type !==
|
|
7845
|
+
if (callee === null || callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression) {
|
|
7578
7846
|
return false;
|
|
7579
7847
|
}
|
|
7580
7848
|
const property = unwrap4(callee.property);
|
|
7581
|
-
if (property === null || property.type !==
|
|
7849
|
+
if (property === null || property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7582
7850
|
return false;
|
|
7583
7851
|
}
|
|
7584
7852
|
if (property.name === "json") {
|
|
@@ -7588,16 +7856,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7588
7856
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7589
7857
|
}
|
|
7590
7858
|
const object = unwrap4(callee.object);
|
|
7591
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7859
|
+
return property.name === "parse" && object !== null && object.type === import_utils55.AST_NODE_TYPES.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7592
7860
|
};
|
|
7593
7861
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7594
7862
|
var isLocalFileRead = (node) => {
|
|
7595
7863
|
let found = false;
|
|
7596
7864
|
const visit = (current) => {
|
|
7597
7865
|
if (found || current === null || current === void 0) return;
|
|
7598
|
-
if (current.type ===
|
|
7866
|
+
if (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7599
7867
|
const callee = unwrap4(current.callee);
|
|
7600
|
-
const name = callee?.type ===
|
|
7868
|
+
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;
|
|
7601
7869
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7602
7870
|
found = true;
|
|
7603
7871
|
return;
|
|
@@ -7619,15 +7887,15 @@ var isLocalFileRead = (node) => {
|
|
|
7619
7887
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7620
7888
|
var isInsideAssertion = (node) => {
|
|
7621
7889
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7622
|
-
if (current.type !==
|
|
7890
|
+
if (current.type !== import_utils55.AST_NODE_TYPES.CallExpression) continue;
|
|
7623
7891
|
let callee = current.callee;
|
|
7624
|
-
while (callee.type ===
|
|
7892
|
+
while (callee.type === import_utils55.AST_NODE_TYPES.MemberExpression) {
|
|
7625
7893
|
callee = callee.object;
|
|
7626
7894
|
}
|
|
7627
|
-
if (callee.type ===
|
|
7895
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7628
7896
|
callee = callee.callee;
|
|
7629
7897
|
}
|
|
7630
|
-
if (callee.type ===
|
|
7898
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7631
7899
|
return true;
|
|
7632
7900
|
}
|
|
7633
7901
|
}
|
|
@@ -7646,39 +7914,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7646
7914
|
var isValidationRead = (node) => {
|
|
7647
7915
|
let current = node;
|
|
7648
7916
|
let parent = current.parent;
|
|
7649
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7917
|
+
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)) {
|
|
7650
7918
|
current = parent;
|
|
7651
7919
|
parent = parent.parent;
|
|
7652
7920
|
}
|
|
7653
7921
|
if (parent === null || parent === void 0) return false;
|
|
7654
|
-
if (parent.type ===
|
|
7922
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7655
7923
|
return true;
|
|
7656
7924
|
}
|
|
7657
|
-
if (parent.type !==
|
|
7925
|
+
if (parent.type !== import_utils55.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7658
7926
|
return false;
|
|
7659
7927
|
}
|
|
7660
7928
|
const callee = parent.callee;
|
|
7661
|
-
if (callee.type ===
|
|
7929
|
+
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") {
|
|
7662
7930
|
return parent.arguments.length === 1;
|
|
7663
7931
|
}
|
|
7664
|
-
return callee.type ===
|
|
7932
|
+
return callee.type === import_utils55.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7665
7933
|
};
|
|
7666
7934
|
var isGuardTestPosition = (node) => {
|
|
7667
7935
|
let current = node;
|
|
7668
7936
|
let parent = current.parent;
|
|
7669
7937
|
while (parent !== void 0 && parent !== null) {
|
|
7670
7938
|
switch (parent.type) {
|
|
7671
|
-
case
|
|
7672
|
-
case
|
|
7673
|
-
case
|
|
7939
|
+
case import_utils55.AST_NODE_TYPES.UnaryExpression:
|
|
7940
|
+
case import_utils55.AST_NODE_TYPES.LogicalExpression:
|
|
7941
|
+
case import_utils55.AST_NODE_TYPES.ChainExpression:
|
|
7674
7942
|
current = parent;
|
|
7675
7943
|
parent = parent.parent;
|
|
7676
7944
|
continue;
|
|
7677
|
-
case
|
|
7678
|
-
case
|
|
7679
|
-
case
|
|
7680
|
-
case
|
|
7681
|
-
case
|
|
7945
|
+
case import_utils55.AST_NODE_TYPES.IfStatement:
|
|
7946
|
+
case import_utils55.AST_NODE_TYPES.ConditionalExpression:
|
|
7947
|
+
case import_utils55.AST_NODE_TYPES.WhileStatement:
|
|
7948
|
+
case import_utils55.AST_NODE_TYPES.DoWhileStatement:
|
|
7949
|
+
case import_utils55.AST_NODE_TYPES.ForStatement:
|
|
7682
7950
|
return parent.test === current;
|
|
7683
7951
|
default:
|
|
7684
7952
|
return false;
|
|
@@ -7688,7 +7956,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7688
7956
|
};
|
|
7689
7957
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7690
7958
|
const unwrapped = unwrap4(node);
|
|
7691
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7959
|
+
if (unwrapped === null || unwrapped.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7692
7960
|
return false;
|
|
7693
7961
|
}
|
|
7694
7962
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7731,11 +7999,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7731
7999
|
return {
|
|
7732
8000
|
VariableDeclarator(node) {
|
|
7733
8001
|
const scope = context.sourceCode.getScope(node);
|
|
7734
|
-
if (node.id.type ===
|
|
8002
|
+
if (node.id.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7735
8003
|
trackInitializer(node);
|
|
7736
8004
|
return;
|
|
7737
8005
|
}
|
|
7738
|
-
if (node.id.type ===
|
|
8006
|
+
if (node.id.type === import_utils55.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils55.AST_NODE_TYPES.ArrayPattern) {
|
|
7739
8007
|
if (isRawPayloadSource(node.init)) {
|
|
7740
8008
|
if (!isFullyNarrowedPattern(node)) {
|
|
7741
8009
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7749,7 +8017,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7749
8017
|
},
|
|
7750
8018
|
AssignmentExpression(node) {
|
|
7751
8019
|
const scope = context.sourceCode.getScope(node);
|
|
7752
|
-
if (node.left.type ===
|
|
8020
|
+
if (node.left.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7753
8021
|
const variable = findVariable2(scope, node.left.name);
|
|
7754
8022
|
if (variable === null) return;
|
|
7755
8023
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7759,7 +8027,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7759
8027
|
}
|
|
7760
8028
|
return;
|
|
7761
8029
|
}
|
|
7762
|
-
if (node.left.type ===
|
|
8030
|
+
if (node.left.type === import_utils55.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils55.AST_NODE_TYPES.ArrayPattern) {
|
|
7763
8031
|
if (isRawPayloadSource(node.right)) {
|
|
7764
8032
|
context.report({
|
|
7765
8033
|
node: node.left,
|
|
@@ -7776,15 +8044,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7776
8044
|
}
|
|
7777
8045
|
},
|
|
7778
8046
|
CallExpression(node) {
|
|
7779
|
-
if (node.callee.type !==
|
|
8047
|
+
if (node.callee.type !== import_utils55.AST_NODE_TYPES.Identifier) return;
|
|
7780
8048
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7781
8049
|
return;
|
|
7782
8050
|
}
|
|
7783
8051
|
const scope = context.sourceCode.getScope(node);
|
|
7784
8052
|
for (const arg of node.arguments) {
|
|
7785
|
-
if (arg.type ===
|
|
8053
|
+
if (arg.type === import_utils55.AST_NODE_TYPES.SpreadElement) continue;
|
|
7786
8054
|
const unwrapped = unwrap4(arg);
|
|
7787
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8055
|
+
if (unwrapped === null || unwrapped.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7788
8056
|
continue;
|
|
7789
8057
|
}
|
|
7790
8058
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7798,13 +8066,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7798
8066
|
const obj = unwrap4(node.object);
|
|
7799
8067
|
if (isRawPayloadSource(obj)) {
|
|
7800
8068
|
const parent = node.parent;
|
|
7801
|
-
if (parent.type ===
|
|
8069
|
+
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))) {
|
|
7802
8070
|
return;
|
|
7803
8071
|
}
|
|
7804
8072
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7805
8073
|
return;
|
|
7806
8074
|
}
|
|
7807
|
-
if (obj !== null && obj.type ===
|
|
8075
|
+
if (obj !== null && obj.type === import_utils55.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7808
8076
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7809
8077
|
const variable = findVariable2(scope, obj.name);
|
|
7810
8078
|
if (variable !== null) {
|
|
@@ -7817,7 +8085,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7817
8085
|
});
|
|
7818
8086
|
|
|
7819
8087
|
// src/rules/prefer-semantic-colors.ts
|
|
7820
|
-
var
|
|
8088
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
7821
8089
|
var import_fs = require("fs");
|
|
7822
8090
|
var import_path = require("path");
|
|
7823
8091
|
|
|
@@ -7917,8 +8185,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7917
8185
|
]);
|
|
7918
8186
|
function jsxElementName(node) {
|
|
7919
8187
|
const name = node.openingElement.name;
|
|
7920
|
-
if (name.type ===
|
|
7921
|
-
if (name.type ===
|
|
8188
|
+
if (name.type === import_utils56.AST_NODE_TYPES.JSXIdentifier) return name.name;
|
|
8189
|
+
if (name.type === import_utils56.AST_NODE_TYPES.JSXMemberExpression && name.property.type === import_utils56.AST_NODE_TYPES.JSXIdentifier) {
|
|
7922
8190
|
return name.property.name;
|
|
7923
8191
|
}
|
|
7924
8192
|
return null;
|
|
@@ -7944,7 +8212,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7944
8212
|
var isInsideSvg = (node) => {
|
|
7945
8213
|
let current = node.parent;
|
|
7946
8214
|
while (current !== void 0 && current !== null) {
|
|
7947
|
-
if (current.type ===
|
|
8215
|
+
if (current.type === import_utils56.AST_NODE_TYPES.JSXElement) {
|
|
7948
8216
|
const name = jsxElementName(current);
|
|
7949
8217
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7950
8218
|
}
|
|
@@ -7955,7 +8223,7 @@ var isInsideSvg = (node) => {
|
|
|
7955
8223
|
var isInsideIconFactoryPath = (node) => {
|
|
7956
8224
|
let current = node.parent;
|
|
7957
8225
|
while (current !== void 0 && current !== null) {
|
|
7958
|
-
if (current.type ===
|
|
8226
|
+
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") {
|
|
7959
8227
|
return true;
|
|
7960
8228
|
}
|
|
7961
8229
|
current = current.parent;
|
|
@@ -8092,12 +8360,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8092
8360
|
return root !== null && workspaceHasMarker(root);
|
|
8093
8361
|
};
|
|
8094
8362
|
var propName = (key) => {
|
|
8095
|
-
if (key.type ===
|
|
8096
|
-
if (key.type ===
|
|
8363
|
+
if (key.type === import_utils56.AST_NODE_TYPES.Identifier) return key.name;
|
|
8364
|
+
if (key.type === import_utils56.AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
8097
8365
|
return null;
|
|
8098
8366
|
};
|
|
8099
8367
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8100
|
-
if (statement.type !==
|
|
8368
|
+
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) {
|
|
8101
8369
|
return false;
|
|
8102
8370
|
}
|
|
8103
8371
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8149,27 +8417,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8149
8417
|
const checkClassNode = (node) => {
|
|
8150
8418
|
if (node === null) return;
|
|
8151
8419
|
switch (node.type) {
|
|
8152
|
-
case
|
|
8420
|
+
case import_utils56.AST_NODE_TYPES.Literal:
|
|
8153
8421
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8154
8422
|
break;
|
|
8155
|
-
case
|
|
8423
|
+
case import_utils56.AST_NODE_TYPES.TemplateLiteral:
|
|
8156
8424
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8157
8425
|
break;
|
|
8158
|
-
case
|
|
8426
|
+
case import_utils56.AST_NODE_TYPES.ArrayExpression:
|
|
8159
8427
|
for (const element of node.elements) {
|
|
8160
|
-
if (element !== null && element.type !==
|
|
8428
|
+
if (element !== null && element.type !== import_utils56.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
8161
8429
|
}
|
|
8162
8430
|
break;
|
|
8163
|
-
case
|
|
8431
|
+
case import_utils56.AST_NODE_TYPES.ObjectExpression:
|
|
8164
8432
|
for (const property of node.properties) {
|
|
8165
|
-
if (property.type ===
|
|
8433
|
+
if (property.type === import_utils56.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
8166
8434
|
}
|
|
8167
8435
|
break;
|
|
8168
|
-
case
|
|
8436
|
+
case import_utils56.AST_NODE_TYPES.ConditionalExpression:
|
|
8169
8437
|
checkClassNode(node.consequent);
|
|
8170
8438
|
checkClassNode(node.alternate);
|
|
8171
8439
|
break;
|
|
8172
|
-
case
|
|
8440
|
+
case import_utils56.AST_NODE_TYPES.LogicalExpression:
|
|
8173
8441
|
checkClassNode(node.right);
|
|
8174
8442
|
break;
|
|
8175
8443
|
default:
|
|
@@ -8177,32 +8445,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8177
8445
|
}
|
|
8178
8446
|
};
|
|
8179
8447
|
const checkColorValueNode = (node) => {
|
|
8180
|
-
if (node.type ===
|
|
8448
|
+
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)) {
|
|
8181
8449
|
report(node, "inlineColor", { value: node.value });
|
|
8182
8450
|
}
|
|
8183
8451
|
};
|
|
8184
8452
|
return {
|
|
8185
8453
|
"JSXAttribute[name.name='className']"(node) {
|
|
8186
8454
|
if (node.value === null) return;
|
|
8187
|
-
if (node.value.type ===
|
|
8188
|
-
else if (node.value.type ===
|
|
8189
|
-
if (node.value.expression.type !==
|
|
8455
|
+
if (node.value.type === import_utils56.AST_NODE_TYPES.Literal) checkClassNode(node.value);
|
|
8456
|
+
else if (node.value.type === import_utils56.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
8457
|
+
if (node.value.expression.type !== import_utils56.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
8190
8458
|
checkClassNode(node.value.expression);
|
|
8191
8459
|
}
|
|
8192
8460
|
}
|
|
8193
8461
|
},
|
|
8194
8462
|
CallExpression(node) {
|
|
8195
|
-
if (node.callee.type ===
|
|
8463
|
+
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)) {
|
|
8196
8464
|
importsEmailOrPdfRenderer = true;
|
|
8197
8465
|
}
|
|
8198
|
-
if (node.callee.type ===
|
|
8466
|
+
if (node.callee.type === import_utils56.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8199
8467
|
for (const arg of node.arguments) {
|
|
8200
|
-
if (arg.type !==
|
|
8468
|
+
if (arg.type !== import_utils56.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
8201
8469
|
}
|
|
8202
8470
|
}
|
|
8203
8471
|
},
|
|
8204
8472
|
VariableDeclarator(node) {
|
|
8205
|
-
if (node.id.type ===
|
|
8473
|
+
if (node.id.type === import_utils56.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8206
8474
|
checkClassNode(node.init);
|
|
8207
8475
|
}
|
|
8208
8476
|
},
|
|
@@ -8212,9 +8480,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8212
8480
|
},
|
|
8213
8481
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8214
8482
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8215
|
-
if (node.value?.type !==
|
|
8483
|
+
if (node.value?.type !== import_utils56.AST_NODE_TYPES.Literal) return;
|
|
8216
8484
|
const owner = node.parent.name;
|
|
8217
|
-
if (owner.type ===
|
|
8485
|
+
if (owner.type === import_utils56.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8218
8486
|
return;
|
|
8219
8487
|
}
|
|
8220
8488
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8228,7 +8496,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8228
8496
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8229
8497
|
},
|
|
8230
8498
|
ImportExpression(node) {
|
|
8231
|
-
if (node.source.type ===
|
|
8499
|
+
if (node.source.type === import_utils56.AST_NODE_TYPES.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8232
8500
|
importsEmailOrPdfRenderer = true;
|
|
8233
8501
|
}
|
|
8234
8502
|
},
|
|
@@ -8241,7 +8509,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8241
8509
|
});
|
|
8242
8510
|
|
|
8243
8511
|
// src/rules/prefer-server-actions.ts
|
|
8244
|
-
var
|
|
8512
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8245
8513
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
8246
8514
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
8247
8515
|
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\/)/;
|
|
@@ -8432,7 +8700,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8432
8700
|
});
|
|
8433
8701
|
|
|
8434
8702
|
// src/rules/prefer-string-literal-union.ts
|
|
8435
|
-
var
|
|
8703
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8436
8704
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8437
8705
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8438
8706
|
"status",
|
|
@@ -8475,19 +8743,19 @@ function isChoiceLikeName(name) {
|
|
|
8475
8743
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8476
8744
|
}
|
|
8477
8745
|
function keyName(key) {
|
|
8478
|
-
if (key.type ===
|
|
8746
|
+
if (key.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8479
8747
|
return key.name;
|
|
8480
8748
|
}
|
|
8481
|
-
if (key.type ===
|
|
8749
|
+
if (key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8482
8750
|
return key.value;
|
|
8483
8751
|
}
|
|
8484
8752
|
return null;
|
|
8485
8753
|
}
|
|
8486
8754
|
function isStringLiteralMember(t) {
|
|
8487
|
-
return t.type ===
|
|
8755
|
+
return t.type === import_utils58.AST_NODE_TYPES.TSLiteralType && t.literal.type === import_utils58.AST_NODE_TYPES.Literal && typeof t.literal.value === "string";
|
|
8488
8756
|
}
|
|
8489
8757
|
function isStringLiteralUnion(node) {
|
|
8490
|
-
if (node?.type !==
|
|
8758
|
+
if (node?.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
8491
8759
|
return false;
|
|
8492
8760
|
}
|
|
8493
8761
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8516,12 +8784,12 @@ function bindingSourceExpression(decl) {
|
|
|
8516
8784
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8517
8785
|
}
|
|
8518
8786
|
function refKey(node) {
|
|
8519
|
-
if (node.type ===
|
|
8787
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8520
8788
|
return node.name;
|
|
8521
8789
|
}
|
|
8522
|
-
if (node.type ===
|
|
8790
|
+
if (node.type === import_utils58.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8523
8791
|
const inner = refKey(node.object);
|
|
8524
|
-
if (inner === null || node.property.type !==
|
|
8792
|
+
if (inner === null || node.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8525
8793
|
return null;
|
|
8526
8794
|
}
|
|
8527
8795
|
return `${inner}.${node.property.name}`;
|
|
@@ -8529,7 +8797,7 @@ function refKey(node) {
|
|
|
8529
8797
|
return null;
|
|
8530
8798
|
}
|
|
8531
8799
|
function strLiteral(node) {
|
|
8532
|
-
if (node.type ===
|
|
8800
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8533
8801
|
return node.value;
|
|
8534
8802
|
}
|
|
8535
8803
|
return null;
|
|
@@ -8570,7 +8838,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8570
8838
|
);
|
|
8571
8839
|
let services;
|
|
8572
8840
|
try {
|
|
8573
|
-
services =
|
|
8841
|
+
services = import_utils58.ESLintUtils.getParserServices(context);
|
|
8574
8842
|
} catch {
|
|
8575
8843
|
services = null;
|
|
8576
8844
|
}
|
|
@@ -8682,7 +8950,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8682
8950
|
containersWithUnion.add(container);
|
|
8683
8951
|
return;
|
|
8684
8952
|
}
|
|
8685
|
-
if (typeNode?.type !==
|
|
8953
|
+
if (typeNode?.type !== import_utils58.AST_NODE_TYPES.TSStringKeyword) {
|
|
8686
8954
|
return;
|
|
8687
8955
|
}
|
|
8688
8956
|
const name = keyName(key);
|
|
@@ -8770,10 +9038,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8770
9038
|
}
|
|
8771
9039
|
};
|
|
8772
9040
|
function refKeyText(node) {
|
|
8773
|
-
if (node.type ===
|
|
9041
|
+
if (node.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
8774
9042
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8775
9043
|
}
|
|
8776
|
-
if (node.type ===
|
|
9044
|
+
if (node.type === import_utils58.AST_NODE_TYPES.SwitchStatement) {
|
|
8777
9045
|
return refKey(node.discriminant) ?? "value";
|
|
8778
9046
|
}
|
|
8779
9047
|
return "value";
|
|
@@ -8782,7 +9050,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8782
9050
|
});
|
|
8783
9051
|
|
|
8784
9052
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8785
|
-
var
|
|
9053
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
8786
9054
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8787
9055
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8788
9056
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8791,11 +9059,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8791
9059
|
var MIN_RUN_LENGTH = 2;
|
|
8792
9060
|
function literalText(node, getText) {
|
|
8793
9061
|
switch (node.type) {
|
|
8794
|
-
case
|
|
9062
|
+
case import_utils59.AST_NODE_TYPES.Literal:
|
|
8795
9063
|
return "regex" in node ? null : getText(node);
|
|
8796
|
-
case
|
|
9064
|
+
case import_utils59.AST_NODE_TYPES.TemplateLiteral:
|
|
8797
9065
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8798
|
-
case
|
|
9066
|
+
case import_utils59.AST_NODE_TYPES.UnaryExpression:
|
|
8799
9067
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8800
9068
|
default:
|
|
8801
9069
|
return null;
|
|
@@ -8803,15 +9071,15 @@ function literalText(node, getText) {
|
|
|
8803
9071
|
}
|
|
8804
9072
|
function isPureReceiver(node) {
|
|
8805
9073
|
switch (node.type) {
|
|
8806
|
-
case
|
|
8807
|
-
case
|
|
9074
|
+
case import_utils59.AST_NODE_TYPES.Identifier:
|
|
9075
|
+
case import_utils59.AST_NODE_TYPES.ThisExpression:
|
|
8808
9076
|
return true;
|
|
8809
|
-
case
|
|
9077
|
+
case import_utils59.AST_NODE_TYPES.MemberExpression:
|
|
8810
9078
|
if (node.optional) {
|
|
8811
9079
|
return false;
|
|
8812
9080
|
}
|
|
8813
9081
|
if (node.computed) {
|
|
8814
|
-
return node.property.type ===
|
|
9082
|
+
return node.property.type === import_utils59.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8815
9083
|
}
|
|
8816
9084
|
return isPureReceiver(node.object);
|
|
8817
9085
|
default:
|
|
@@ -8819,7 +9087,7 @@ function isPureReceiver(node) {
|
|
|
8819
9087
|
}
|
|
8820
9088
|
}
|
|
8821
9089
|
function literalIndex(node) {
|
|
8822
|
-
if (node.type !==
|
|
9090
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8823
9091
|
return null;
|
|
8824
9092
|
}
|
|
8825
9093
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8845,24 +9113,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8845
9113
|
}
|
|
8846
9114
|
const { sourceCode } = context;
|
|
8847
9115
|
function parseAssertion(statement) {
|
|
8848
|
-
if (statement.type !==
|
|
9116
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExpressionStatement) {
|
|
8849
9117
|
return null;
|
|
8850
9118
|
}
|
|
8851
9119
|
const call = statement.expression;
|
|
8852
|
-
if (call.type !==
|
|
9120
|
+
if (call.type !== import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
8853
9121
|
return null;
|
|
8854
9122
|
}
|
|
8855
9123
|
const callee = call.callee;
|
|
8856
|
-
if (callee.type !==
|
|
9124
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
8857
9125
|
return null;
|
|
8858
9126
|
}
|
|
8859
9127
|
const matcher = callee.property.name;
|
|
8860
9128
|
const expectCall = callee.object;
|
|
8861
|
-
if (expectCall.type !==
|
|
9129
|
+
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) {
|
|
8862
9130
|
return null;
|
|
8863
9131
|
}
|
|
8864
9132
|
const actual = expectCall.arguments[0];
|
|
8865
|
-
if (actual === void 0 || actual.type !==
|
|
9133
|
+
if (actual === void 0 || actual.type !== import_utils59.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8866
9134
|
return null;
|
|
8867
9135
|
}
|
|
8868
9136
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8876,7 +9144,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8876
9144
|
}
|
|
8877
9145
|
key = { kind: "index", index };
|
|
8878
9146
|
} else {
|
|
8879
|
-
if (actual.property.type !==
|
|
9147
|
+
if (actual.property.type !== import_utils59.AST_NODE_TYPES.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8880
9148
|
return null;
|
|
8881
9149
|
}
|
|
8882
9150
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8888,7 +9156,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8888
9156
|
return null;
|
|
8889
9157
|
}
|
|
8890
9158
|
const expected = call.arguments[0];
|
|
8891
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
9159
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === import_utils59.AST_NODE_TYPES.SpreadElement) {
|
|
8892
9160
|
return null;
|
|
8893
9161
|
}
|
|
8894
9162
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9003,7 +9271,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9003
9271
|
});
|
|
9004
9272
|
|
|
9005
9273
|
// src/rules/prefer-zod-enum.ts
|
|
9006
|
-
var
|
|
9274
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9007
9275
|
var prefer_zod_enum_default = createRule({
|
|
9008
9276
|
name: "prefer-zod-enum",
|
|
9009
9277
|
meta: {
|
|
@@ -9023,25 +9291,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9023
9291
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9024
9292
|
function enumValues(node) {
|
|
9025
9293
|
const callee = node.callee;
|
|
9026
|
-
if (callee.type !==
|
|
9294
|
+
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) {
|
|
9027
9295
|
return null;
|
|
9028
9296
|
}
|
|
9029
9297
|
const argument = node.arguments[0];
|
|
9030
|
-
if (argument === void 0 || argument.type !==
|
|
9298
|
+
if (argument === void 0 || argument.type !== import_utils60.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
9031
9299
|
return null;
|
|
9032
9300
|
}
|
|
9033
9301
|
const values = [];
|
|
9034
9302
|
let canFix = true;
|
|
9035
9303
|
for (const element of argument.elements) {
|
|
9036
|
-
if (element?.type ===
|
|
9304
|
+
if (element?.type === import_utils60.AST_NODE_TYPES.SpreadElement) {
|
|
9037
9305
|
canFix = false;
|
|
9038
9306
|
continue;
|
|
9039
9307
|
}
|
|
9040
|
-
if (element === null || element.type !==
|
|
9308
|
+
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") {
|
|
9041
9309
|
return null;
|
|
9042
9310
|
}
|
|
9043
9311
|
const value = element.arguments[0];
|
|
9044
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9312
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== import_utils60.AST_NODE_TYPES.Literal || typeof value.value !== "string") {
|
|
9045
9313
|
canFix = false;
|
|
9046
9314
|
continue;
|
|
9047
9315
|
}
|
|
@@ -9051,11 +9319,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9051
9319
|
}
|
|
9052
9320
|
function buildFix(node, values) {
|
|
9053
9321
|
const argument = node.arguments[0];
|
|
9054
|
-
if (argument === void 0 || argument.type !==
|
|
9322
|
+
if (argument === void 0 || argument.type !== import_utils60.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9055
9323
|
return void 0;
|
|
9056
9324
|
}
|
|
9057
9325
|
const callee = node.callee;
|
|
9058
|
-
if (callee.type !==
|
|
9326
|
+
if (callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9059
9327
|
return void 0;
|
|
9060
9328
|
}
|
|
9061
9329
|
return (fixer) => [
|
|
@@ -9072,7 +9340,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9072
9340
|
return;
|
|
9073
9341
|
}
|
|
9074
9342
|
for (const specifier of node.specifiers) {
|
|
9075
|
-
if (specifier.type ===
|
|
9343
|
+
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") {
|
|
9076
9344
|
zodNamespaces.add(specifier.local.name);
|
|
9077
9345
|
}
|
|
9078
9346
|
}
|
|
@@ -9094,7 +9362,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9094
9362
|
});
|
|
9095
9363
|
|
|
9096
9364
|
// src/rules/prefer-zod-infer.ts
|
|
9097
|
-
var
|
|
9365
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9098
9366
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9099
9367
|
"describe",
|
|
9100
9368
|
"refine",
|
|
@@ -9131,44 +9399,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9131
9399
|
"Schema"
|
|
9132
9400
|
]);
|
|
9133
9401
|
var LEAF_NODE_TYPES = {
|
|
9134
|
-
string: [
|
|
9135
|
-
email: [
|
|
9136
|
-
url: [
|
|
9137
|
-
uuid: [
|
|
9138
|
-
ulid: [
|
|
9139
|
-
cuid: [
|
|
9140
|
-
cuid2: [
|
|
9141
|
-
nanoid: [
|
|
9142
|
-
iso: [
|
|
9143
|
-
number: [
|
|
9144
|
-
int: [
|
|
9145
|
-
float32: [
|
|
9146
|
-
float64: [
|
|
9147
|
-
boolean: [
|
|
9148
|
-
bigint: [
|
|
9149
|
-
symbol: [
|
|
9150
|
-
any: [
|
|
9151
|
-
unknown: [
|
|
9152
|
-
never: [
|
|
9153
|
-
void: [
|
|
9154
|
-
null: [
|
|
9155
|
-
undefined: [
|
|
9156
|
-
literal: [
|
|
9157
|
-
date: [
|
|
9158
|
-
array: [
|
|
9159
|
-
tuple: [
|
|
9160
|
-
object: [
|
|
9161
|
-
strictObject: [
|
|
9162
|
-
looseObject: [
|
|
9163
|
-
record: [
|
|
9164
|
-
map: [
|
|
9165
|
-
set: [
|
|
9166
|
-
promise: [
|
|
9167
|
-
enum: [
|
|
9168
|
-
nativeEnum: [
|
|
9169
|
-
union: [
|
|
9170
|
-
discriminatedUnion: [
|
|
9171
|
-
intersection: [
|
|
9402
|
+
string: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9403
|
+
email: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9404
|
+
url: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9405
|
+
uuid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9406
|
+
ulid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9407
|
+
cuid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9408
|
+
cuid2: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9409
|
+
nanoid: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9410
|
+
iso: [import_utils61.AST_NODE_TYPES.TSStringKeyword],
|
|
9411
|
+
number: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9412
|
+
int: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9413
|
+
float32: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9414
|
+
float64: [import_utils61.AST_NODE_TYPES.TSNumberKeyword],
|
|
9415
|
+
boolean: [import_utils61.AST_NODE_TYPES.TSBooleanKeyword],
|
|
9416
|
+
bigint: [import_utils61.AST_NODE_TYPES.TSBigIntKeyword],
|
|
9417
|
+
symbol: [import_utils61.AST_NODE_TYPES.TSSymbolKeyword],
|
|
9418
|
+
any: [import_utils61.AST_NODE_TYPES.TSAnyKeyword],
|
|
9419
|
+
unknown: [import_utils61.AST_NODE_TYPES.TSUnknownKeyword],
|
|
9420
|
+
never: [import_utils61.AST_NODE_TYPES.TSNeverKeyword],
|
|
9421
|
+
void: [import_utils61.AST_NODE_TYPES.TSVoidKeyword],
|
|
9422
|
+
null: [import_utils61.AST_NODE_TYPES.TSNullKeyword],
|
|
9423
|
+
undefined: [import_utils61.AST_NODE_TYPES.TSUndefinedKeyword],
|
|
9424
|
+
literal: [import_utils61.AST_NODE_TYPES.TSLiteralType],
|
|
9425
|
+
date: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9426
|
+
array: [import_utils61.AST_NODE_TYPES.TSArrayType, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9427
|
+
tuple: [import_utils61.AST_NODE_TYPES.TSTupleType],
|
|
9428
|
+
object: [import_utils61.AST_NODE_TYPES.TSTypeLiteral, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9429
|
+
strictObject: [import_utils61.AST_NODE_TYPES.TSTypeLiteral, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9430
|
+
looseObject: [import_utils61.AST_NODE_TYPES.TSTypeLiteral, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9431
|
+
record: [import_utils61.AST_NODE_TYPES.TSTypeReference, import_utils61.AST_NODE_TYPES.TSTypeLiteral],
|
|
9432
|
+
map: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9433
|
+
set: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9434
|
+
promise: [import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9435
|
+
enum: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference, import_utils61.AST_NODE_TYPES.TSLiteralType],
|
|
9436
|
+
nativeEnum: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference, import_utils61.AST_NODE_TYPES.TSLiteralType],
|
|
9437
|
+
union: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9438
|
+
discriminatedUnion: [import_utils61.AST_NODE_TYPES.TSUnionType, import_utils61.AST_NODE_TYPES.TSTypeReference],
|
|
9439
|
+
intersection: [import_utils61.AST_NODE_TYPES.TSIntersectionType, import_utils61.AST_NODE_TYPES.TSTypeReference]
|
|
9172
9440
|
};
|
|
9173
9441
|
function normalizeSchemaName(name) {
|
|
9174
9442
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9177,20 +9445,20 @@ function normalizeTypeName(name) {
|
|
|
9177
9445
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9178
9446
|
}
|
|
9179
9447
|
function unwrapNullish(annotation) {
|
|
9180
|
-
if (annotation.type !==
|
|
9448
|
+
if (annotation.type !== import_utils61.AST_NODE_TYPES.TSUnionType) {
|
|
9181
9449
|
return {
|
|
9182
9450
|
core: annotation,
|
|
9183
|
-
nullable: annotation.type ===
|
|
9451
|
+
nullable: annotation.type === import_utils61.AST_NODE_TYPES.TSNullKeyword
|
|
9184
9452
|
};
|
|
9185
9453
|
}
|
|
9186
9454
|
const rest = [];
|
|
9187
9455
|
let nullable = false;
|
|
9188
9456
|
for (const member of annotation.types) {
|
|
9189
|
-
if (member.type ===
|
|
9457
|
+
if (member.type === import_utils61.AST_NODE_TYPES.TSNullKeyword) {
|
|
9190
9458
|
nullable = true;
|
|
9191
9459
|
continue;
|
|
9192
9460
|
}
|
|
9193
|
-
if (member.type ===
|
|
9461
|
+
if (member.type === import_utils61.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
9194
9462
|
continue;
|
|
9195
9463
|
}
|
|
9196
9464
|
rest.push(member);
|
|
@@ -9255,14 +9523,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9255
9523
|
function zodCallChain(node) {
|
|
9256
9524
|
const chain = [];
|
|
9257
9525
|
let current = node;
|
|
9258
|
-
while (current.type ===
|
|
9526
|
+
while (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9259
9527
|
const callee = current.callee;
|
|
9260
|
-
if (callee.type !==
|
|
9528
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9261
9529
|
return null;
|
|
9262
9530
|
}
|
|
9263
9531
|
chain.push(current);
|
|
9264
9532
|
const receiver = callee.object;
|
|
9265
|
-
if (receiver.type ===
|
|
9533
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9266
9534
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9267
9535
|
}
|
|
9268
9536
|
current = receiver;
|
|
@@ -9271,19 +9539,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9271
9539
|
}
|
|
9272
9540
|
function methodName(call) {
|
|
9273
9541
|
const callee = call.callee;
|
|
9274
|
-
return callee.type ===
|
|
9542
|
+
return callee.type === import_utils61.AST_NODE_TYPES.MemberExpression && callee.property.type === import_utils61.AST_NODE_TYPES.Identifier ? callee.property.name : "";
|
|
9275
9543
|
}
|
|
9276
9544
|
function schemaField(node) {
|
|
9277
9545
|
const modifiers = [];
|
|
9278
9546
|
let current = node;
|
|
9279
9547
|
let leaf = null;
|
|
9280
|
-
while (current.type ===
|
|
9548
|
+
while (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9281
9549
|
const callee = current.callee;
|
|
9282
|
-
if (callee.type !==
|
|
9550
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9283
9551
|
break;
|
|
9284
9552
|
}
|
|
9285
9553
|
const receiver = callee.object;
|
|
9286
|
-
if (receiver.type ===
|
|
9554
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9287
9555
|
leaf = callee.property.name;
|
|
9288
9556
|
break;
|
|
9289
9557
|
}
|
|
@@ -9314,16 +9582,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9314
9582
|
return null;
|
|
9315
9583
|
}
|
|
9316
9584
|
const shape = base.arguments[0];
|
|
9317
|
-
if (shape === void 0 || shape.type !==
|
|
9585
|
+
if (shape === void 0 || shape.type !== import_utils61.AST_NODE_TYPES.ObjectExpression) {
|
|
9318
9586
|
return null;
|
|
9319
9587
|
}
|
|
9320
9588
|
const fields = /* @__PURE__ */ new Map();
|
|
9321
9589
|
for (const property of shape.properties) {
|
|
9322
|
-
if (property.type !==
|
|
9590
|
+
if (property.type !== import_utils61.AST_NODE_TYPES.Property || property.computed) {
|
|
9323
9591
|
return null;
|
|
9324
9592
|
}
|
|
9325
9593
|
const { key } = property;
|
|
9326
|
-
const name = key.type ===
|
|
9594
|
+
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;
|
|
9327
9595
|
if (name === null) {
|
|
9328
9596
|
return null;
|
|
9329
9597
|
}
|
|
@@ -9334,11 +9602,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9334
9602
|
function typeMembers(members) {
|
|
9335
9603
|
const result = /* @__PURE__ */ new Map();
|
|
9336
9604
|
for (const member of members) {
|
|
9337
|
-
if (member.type !==
|
|
9605
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
9338
9606
|
return null;
|
|
9339
9607
|
}
|
|
9340
9608
|
const { key } = member;
|
|
9341
|
-
const name = key.type ===
|
|
9609
|
+
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;
|
|
9342
9610
|
if (name === null) {
|
|
9343
9611
|
return null;
|
|
9344
9612
|
}
|
|
@@ -9352,8 +9620,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9352
9620
|
return result.size === 0 ? null : result;
|
|
9353
9621
|
}
|
|
9354
9622
|
function collectConstrainedNames(node) {
|
|
9355
|
-
if (node.type ===
|
|
9356
|
-
if (node.typeName.type ===
|
|
9623
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSTypeReference) {
|
|
9624
|
+
if (node.typeName.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9357
9625
|
constrainedTypeNames.add(node.typeName.name);
|
|
9358
9626
|
}
|
|
9359
9627
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9361,11 +9629,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9361
9629
|
}
|
|
9362
9630
|
return;
|
|
9363
9631
|
}
|
|
9364
|
-
if (node.type ===
|
|
9632
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSArrayType) {
|
|
9365
9633
|
collectConstrainedNames(node.elementType);
|
|
9366
9634
|
return;
|
|
9367
9635
|
}
|
|
9368
|
-
if (node.type ===
|
|
9636
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSUnionType || node.type === import_utils61.AST_NODE_TYPES.TSIntersectionType) {
|
|
9369
9637
|
for (const member of node.types) {
|
|
9370
9638
|
collectConstrainedNames(member);
|
|
9371
9639
|
}
|
|
@@ -9409,13 +9677,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9409
9677
|
return;
|
|
9410
9678
|
}
|
|
9411
9679
|
for (const specifier of node.specifiers) {
|
|
9412
|
-
if (specifier.type ===
|
|
9680
|
+
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") {
|
|
9413
9681
|
zodNamespaces.add(specifier.local.name);
|
|
9414
9682
|
}
|
|
9415
9683
|
}
|
|
9416
9684
|
},
|
|
9417
9685
|
VariableDeclarator(node) {
|
|
9418
|
-
if (node.id.type !==
|
|
9686
|
+
if (node.id.type !== import_utils61.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9419
9687
|
return;
|
|
9420
9688
|
}
|
|
9421
9689
|
const fields = schemaFields(node.init);
|
|
@@ -9425,14 +9693,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9425
9693
|
},
|
|
9426
9694
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9427
9695
|
"MemberExpression[computed=false]"(node) {
|
|
9428
|
-
if (node.object.type ===
|
|
9696
|
+
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)) {
|
|
9429
9697
|
reshapedSchemaNames.add(node.object.name);
|
|
9430
9698
|
}
|
|
9431
9699
|
},
|
|
9432
9700
|
/** Records every type argument carried by a Zod constraint. */
|
|
9433
9701
|
TSTypeReference(node) {
|
|
9434
9702
|
const { typeName } = node;
|
|
9435
|
-
const referenced = typeName.type ===
|
|
9703
|
+
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;
|
|
9436
9704
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9437
9705
|
return;
|
|
9438
9706
|
}
|
|
@@ -9450,7 +9718,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9450
9718
|
}
|
|
9451
9719
|
},
|
|
9452
9720
|
TSTypeAliasDeclaration(node) {
|
|
9453
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9721
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9454
9722
|
return;
|
|
9455
9723
|
}
|
|
9456
9724
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9495,10 +9763,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9495
9763
|
});
|
|
9496
9764
|
|
|
9497
9765
|
// src/rules/require-assert-never.ts
|
|
9498
|
-
var
|
|
9766
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9499
9767
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9500
|
-
if (statement.type ===
|
|
9501
|
-
if (statement.type ===
|
|
9768
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.EmptyStatement) return false;
|
|
9769
|
+
if (statement.type === import_utils62.AST_NODE_TYPES.BlockStatement) {
|
|
9502
9770
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9503
9771
|
}
|
|
9504
9772
|
return true;
|
|
@@ -9514,7 +9782,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9514
9782
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9515
9783
|
}
|
|
9516
9784
|
const only = defaultCase.consequent[0];
|
|
9517
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9785
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === import_utils62.AST_NODE_TYPES.BlockStatement && only.body.length === 0) {
|
|
9518
9786
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9519
9787
|
}
|
|
9520
9788
|
return false;
|
|
@@ -9554,7 +9822,7 @@ var require_assert_never_default = createRule({
|
|
|
9554
9822
|
});
|
|
9555
9823
|
|
|
9556
9824
|
// src/rules/require-fetch-timeout.ts
|
|
9557
|
-
var
|
|
9825
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9558
9826
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9559
9827
|
"globalThis",
|
|
9560
9828
|
"window",
|
|
@@ -9570,14 +9838,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9570
9838
|
return false;
|
|
9571
9839
|
}
|
|
9572
9840
|
function initProvablyLacksSignal(init) {
|
|
9573
|
-
if (init.type !==
|
|
9841
|
+
if (init.type !== import_utils63.AST_NODE_TYPES.ObjectExpression) {
|
|
9574
9842
|
return false;
|
|
9575
9843
|
}
|
|
9576
9844
|
for (const prop of init.properties) {
|
|
9577
|
-
if (prop.type ===
|
|
9845
|
+
if (prop.type === import_utils63.AST_NODE_TYPES.SpreadElement) {
|
|
9578
9846
|
return false;
|
|
9579
9847
|
}
|
|
9580
|
-
if (prop.key.type ===
|
|
9848
|
+
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") {
|
|
9581
9849
|
return false;
|
|
9582
9850
|
}
|
|
9583
9851
|
if (prop.computed) {
|
|
@@ -9587,7 +9855,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9587
9855
|
return true;
|
|
9588
9856
|
}
|
|
9589
9857
|
function isStringish(node) {
|
|
9590
|
-
return node.type ===
|
|
9858
|
+
return node.type === import_utils63.AST_NODE_TYPES.Literal && typeof node.value === "string" || node.type === import_utils63.AST_NODE_TYPES.TemplateLiteral;
|
|
9591
9859
|
}
|
|
9592
9860
|
var require_fetch_timeout_default = createRule({
|
|
9593
9861
|
name: "require-fetch-timeout",
|
|
@@ -9624,14 +9892,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9624
9892
|
}
|
|
9625
9893
|
function resolvesToGlobal(identifier) {
|
|
9626
9894
|
const scope = context.sourceCode.getScope(identifier);
|
|
9627
|
-
const variable =
|
|
9895
|
+
const variable = import_utils63.ASTUtils.findVariable(scope, identifier.name);
|
|
9628
9896
|
return variable === null || variable.defs.length === 0;
|
|
9629
9897
|
}
|
|
9630
9898
|
function isGlobalFetchCall2(callee) {
|
|
9631
|
-
if (callee.type ===
|
|
9899
|
+
if (callee.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9632
9900
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9633
9901
|
}
|
|
9634
|
-
return callee.type ===
|
|
9902
|
+
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);
|
|
9635
9903
|
}
|
|
9636
9904
|
return {
|
|
9637
9905
|
CallExpression(node) {
|
|
@@ -9651,7 +9919,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9651
9919
|
});
|
|
9652
9920
|
|
|
9653
9921
|
// src/rules/require-interface-for-injected-service.ts
|
|
9654
|
-
var
|
|
9922
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
9655
9923
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9656
9924
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9657
9925
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9659,20 +9927,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9659
9927
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9660
9928
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9661
9929
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9662
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9663
|
-
var qualifiedName = (name) => name.type ===
|
|
9930
|
+
var isExportedClass = (node) => node.parent.type === import_utils64.AST_NODE_TYPES.ExportNamedDeclaration || node.parent.type === import_utils64.AST_NODE_TYPES.ExportDefaultDeclaration;
|
|
9931
|
+
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}` : "";
|
|
9664
9932
|
var readTypeReference = (annotation) => {
|
|
9665
|
-
if (annotation === void 0 || annotation.type !==
|
|
9933
|
+
if (annotation === void 0 || annotation.type !== import_utils64.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9666
9934
|
const { typeName } = annotation;
|
|
9667
|
-
const rightmost = typeName.type ===
|
|
9935
|
+
const rightmost = typeName.type === import_utils64.AST_NODE_TYPES.Identifier ? typeName.name : typeName.type === import_utils64.AST_NODE_TYPES.TSQualifiedName ? typeName.right.name : null;
|
|
9668
9936
|
if (rightmost === null) return null;
|
|
9669
9937
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9670
9938
|
};
|
|
9671
9939
|
var namedParameterCollaborator = (annotated) => {
|
|
9672
9940
|
let target = annotated;
|
|
9673
|
-
if (target.type ===
|
|
9674
|
-
if (target.type ===
|
|
9675
|
-
if (target.type !==
|
|
9941
|
+
if (target.type === import_utils64.AST_NODE_TYPES.TSParameterProperty) target = target.parameter;
|
|
9942
|
+
if (target.type === import_utils64.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
9943
|
+
if (target.type !== import_utils64.AST_NODE_TYPES.Identifier) return null;
|
|
9676
9944
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9677
9945
|
if (reference === null) return null;
|
|
9678
9946
|
return { name: target.name, ...reference };
|
|
@@ -9680,8 +9948,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9680
9948
|
var propertySignatureTypes = (members) => {
|
|
9681
9949
|
const types = /* @__PURE__ */ new Map();
|
|
9682
9950
|
for (const member of members) {
|
|
9683
|
-
if (member.type !==
|
|
9684
|
-
if (member.computed || member.key.type !==
|
|
9951
|
+
if (member.type !== import_utils64.AST_NODE_TYPES.TSPropertySignature) continue;
|
|
9952
|
+
if (member.computed || member.key.type !== import_utils64.AST_NODE_TYPES.Identifier) continue;
|
|
9685
9953
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9686
9954
|
if (reference === null) continue;
|
|
9687
9955
|
types.set(member.key.name, reference);
|
|
@@ -9692,18 +9960,18 @@ var fileTypeIndex = (program) => {
|
|
|
9692
9960
|
const objects = /* @__PURE__ */ new Map();
|
|
9693
9961
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9694
9962
|
for (const statement of program.body) {
|
|
9695
|
-
const declaration = statement.type ===
|
|
9696
|
-
if (declaration?.type ===
|
|
9963
|
+
const declaration = statement.type === import_utils64.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9964
|
+
if (declaration?.type === import_utils64.AST_NODE_TYPES.TSInterfaceDeclaration) {
|
|
9697
9965
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9698
9966
|
continue;
|
|
9699
9967
|
}
|
|
9700
|
-
if (declaration?.type !==
|
|
9968
|
+
if (declaration?.type !== import_utils64.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9701
9969
|
const aliased = declaration.typeAnnotation;
|
|
9702
|
-
if (aliased.type ===
|
|
9970
|
+
if (aliased.type === import_utils64.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils64.AST_NODE_TYPES.TSConstructorType) {
|
|
9703
9971
|
functionAliases.add(declaration.id.name);
|
|
9704
9972
|
continue;
|
|
9705
9973
|
}
|
|
9706
|
-
const literals = aliased.type ===
|
|
9974
|
+
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) : [];
|
|
9707
9975
|
if (literals.length === 0) continue;
|
|
9708
9976
|
const merged = /* @__PURE__ */ new Map();
|
|
9709
9977
|
for (const literal of literals) {
|
|
@@ -9716,10 +9984,10 @@ var fileTypeIndex = (program) => {
|
|
|
9716
9984
|
return { objects, functionAliases };
|
|
9717
9985
|
};
|
|
9718
9986
|
var bagMemberTypes = (annotation, declared) => {
|
|
9719
|
-
if (annotation.type ===
|
|
9987
|
+
if (annotation.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9720
9988
|
return propertySignatureTypes(annotation.members);
|
|
9721
9989
|
}
|
|
9722
|
-
if (annotation.type !==
|
|
9990
|
+
if (annotation.type !== import_utils64.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9723
9991
|
return null;
|
|
9724
9992
|
}
|
|
9725
9993
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9731,11 +9999,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9731
9999
|
if (members === null) return [];
|
|
9732
10000
|
const collaborators = [];
|
|
9733
10001
|
for (const property of pattern.properties) {
|
|
9734
|
-
if (property.type !==
|
|
9735
|
-
if (property.key.type !==
|
|
10002
|
+
if (property.type !== import_utils64.AST_NODE_TYPES.Property || property.computed) continue;
|
|
10003
|
+
if (property.key.type !== import_utils64.AST_NODE_TYPES.Identifier) continue;
|
|
9736
10004
|
const key = property.key.name;
|
|
9737
|
-
const bound = property.value.type ===
|
|
9738
|
-
if (bound.type !==
|
|
10005
|
+
const bound = property.value.type === import_utils64.AST_NODE_TYPES.AssignmentPattern ? property.value.left : property.value;
|
|
10006
|
+
if (bound.type !== import_utils64.AST_NODE_TYPES.Identifier) continue;
|
|
9739
10007
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9740
10008
|
const reference = members.get(key);
|
|
9741
10009
|
if (reference === void 0) continue;
|
|
@@ -9745,8 +10013,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9745
10013
|
};
|
|
9746
10014
|
var parameterCollaborators = (parameter, declared) => {
|
|
9747
10015
|
let target = parameter;
|
|
9748
|
-
if (target.type ===
|
|
9749
|
-
if (target.type ===
|
|
10016
|
+
if (target.type === import_utils64.AST_NODE_TYPES.AssignmentPattern) target = target.left;
|
|
10017
|
+
if (target.type === import_utils64.AST_NODE_TYPES.ObjectPattern) {
|
|
9750
10018
|
return objectPatternCollaborators(target, declared);
|
|
9751
10019
|
}
|
|
9752
10020
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9765,17 +10033,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9765
10033
|
let constructedFields = 0;
|
|
9766
10034
|
if (body2 !== null && body2 !== void 0) {
|
|
9767
10035
|
for (const statement of body2.body) {
|
|
9768
|
-
if (statement.type !==
|
|
10036
|
+
if (statement.type !== import_utils64.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9769
10037
|
const expression = statement.expression;
|
|
9770
|
-
if (expression.type !==
|
|
10038
|
+
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) {
|
|
9771
10039
|
continue;
|
|
9772
10040
|
}
|
|
9773
10041
|
const source = expression.right;
|
|
9774
|
-
if (source.type ===
|
|
10042
|
+
if (source.type === import_utils64.AST_NODE_TYPES.NewExpression) {
|
|
9775
10043
|
constructedFields += 1;
|
|
9776
|
-
} else if (source.type ===
|
|
10044
|
+
} else if (source.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9777
10045
|
storedFrom.add(source.name);
|
|
9778
|
-
} else if (source.type ===
|
|
10046
|
+
} else if (source.type === import_utils64.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9779
10047
|
storedFrom.add(source.object.name);
|
|
9780
10048
|
}
|
|
9781
10049
|
}
|
|
@@ -9783,7 +10051,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9783
10051
|
const collaborators = [];
|
|
9784
10052
|
for (const parameter of ctor.value.params) {
|
|
9785
10053
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9786
|
-
const stored = parameter.type ===
|
|
10054
|
+
const stored = parameter.type === import_utils64.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9787
10055
|
if (!stored) continue;
|
|
9788
10056
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9789
10057
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9817,19 +10085,19 @@ var subtreeHas = (root, found) => {
|
|
|
9817
10085
|
return hit;
|
|
9818
10086
|
};
|
|
9819
10087
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9820
|
-
if (node.type ===
|
|
10088
|
+
if (node.type === import_utils64.AST_NODE_TYPES.CallExpression) {
|
|
9821
10089
|
const { callee } = node;
|
|
9822
|
-
if (callee.type ===
|
|
9823
|
-
return callee.type ===
|
|
10090
|
+
if (callee.type === import_utils64.AST_NODE_TYPES.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
10091
|
+
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;
|
|
9824
10092
|
}
|
|
9825
|
-
return node.type ===
|
|
10093
|
+
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);
|
|
9826
10094
|
});
|
|
9827
10095
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9828
10096
|
var fileInterfaceNames = (program) => {
|
|
9829
10097
|
const names = [];
|
|
9830
10098
|
for (const statement of program.body) {
|
|
9831
|
-
const declaration = statement.type ===
|
|
9832
|
-
if (declaration?.type ===
|
|
10099
|
+
const declaration = statement.type === import_utils64.AST_NODE_TYPES.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10100
|
+
if (declaration?.type === import_utils64.AST_NODE_TYPES.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9833
10101
|
}
|
|
9834
10102
|
return names;
|
|
9835
10103
|
};
|
|
@@ -9847,11 +10115,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9847
10115
|
var publicMethodNames = (body2) => {
|
|
9848
10116
|
const names = [];
|
|
9849
10117
|
for (const member of body2.body) {
|
|
9850
|
-
if (member.type !==
|
|
10118
|
+
if (member.type !== import_utils64.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9851
10119
|
if (member.kind !== "method" || member.static) continue;
|
|
9852
10120
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9853
|
-
if (member.key.type ===
|
|
9854
|
-
if (member.key.type ===
|
|
10121
|
+
if (member.key.type === import_utils64.AST_NODE_TYPES.PrivateIdentifier) continue;
|
|
10122
|
+
if (member.key.type === import_utils64.AST_NODE_TYPES.Identifier) names.push(member.key.name);
|
|
9855
10123
|
else names.push("\u2026");
|
|
9856
10124
|
}
|
|
9857
10125
|
return names;
|
|
@@ -9884,7 +10152,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9884
10152
|
if (node.implements.length > 0) return;
|
|
9885
10153
|
if (node.decorators.length > 0) return;
|
|
9886
10154
|
const ctor = node.body.body.find(
|
|
9887
|
-
(member) => member.type ===
|
|
10155
|
+
(member) => member.type === import_utils64.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
9888
10156
|
);
|
|
9889
10157
|
if (ctor === void 0) return;
|
|
9890
10158
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9913,37 +10181,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9913
10181
|
});
|
|
9914
10182
|
|
|
9915
10183
|
// src/rules/require-static-next-matcher.ts
|
|
9916
|
-
var
|
|
10184
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
9917
10185
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9918
|
-
function
|
|
9919
|
-
if (node.type ===
|
|
9920
|
-
return
|
|
10186
|
+
function unwrapExpression2(node) {
|
|
10187
|
+
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) {
|
|
10188
|
+
return unwrapExpression2(node.expression);
|
|
9921
10189
|
}
|
|
9922
10190
|
return node;
|
|
9923
10191
|
}
|
|
9924
10192
|
function isStaticValue(node) {
|
|
9925
|
-
const value =
|
|
9926
|
-
if (value.type ===
|
|
10193
|
+
const value = unwrapExpression2(node);
|
|
10194
|
+
if (value.type === import_utils65.AST_NODE_TYPES.Literal) {
|
|
9927
10195
|
return true;
|
|
9928
10196
|
}
|
|
9929
|
-
if (value.type ===
|
|
10197
|
+
if (value.type === import_utils65.AST_NODE_TYPES.TemplateLiteral) {
|
|
9930
10198
|
return value.expressions.length === 0;
|
|
9931
10199
|
}
|
|
9932
|
-
if (value.type ===
|
|
10200
|
+
if (value.type === import_utils65.AST_NODE_TYPES.ArrayExpression) {
|
|
9933
10201
|
return value.elements.every(
|
|
9934
|
-
(element) => element !== null && element.type !==
|
|
10202
|
+
(element) => element !== null && element.type !== import_utils65.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
9935
10203
|
);
|
|
9936
10204
|
}
|
|
9937
|
-
if (value.type ===
|
|
10205
|
+
if (value.type === import_utils65.AST_NODE_TYPES.ObjectExpression) {
|
|
9938
10206
|
return value.properties.every(
|
|
9939
|
-
(property) => property.type ===
|
|
10207
|
+
(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)
|
|
9940
10208
|
);
|
|
9941
10209
|
}
|
|
9942
10210
|
return false;
|
|
9943
10211
|
}
|
|
9944
10212
|
function propertyName2(property) {
|
|
9945
10213
|
if (property.computed) return null;
|
|
9946
|
-
if (property.key.type ===
|
|
10214
|
+
if (property.key.type === import_utils65.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
9947
10215
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9948
10216
|
}
|
|
9949
10217
|
var require_static_next_matcher_default = createRule({
|
|
@@ -9965,19 +10233,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
9965
10233
|
}
|
|
9966
10234
|
return {
|
|
9967
10235
|
ExportNamedDeclaration(node) {
|
|
9968
|
-
if (node.declaration?.type !==
|
|
10236
|
+
if (node.declaration?.type !== import_utils65.AST_NODE_TYPES.VariableDeclaration) {
|
|
9969
10237
|
return;
|
|
9970
10238
|
}
|
|
9971
10239
|
for (const declaration of node.declaration.declarations) {
|
|
9972
|
-
if (declaration.id.type !==
|
|
10240
|
+
if (declaration.id.type !== import_utils65.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9973
10241
|
continue;
|
|
9974
10242
|
}
|
|
9975
|
-
const config =
|
|
9976
|
-
if (config.type !==
|
|
10243
|
+
const config = unwrapExpression2(declaration.init);
|
|
10244
|
+
if (config.type !== import_utils65.AST_NODE_TYPES.ObjectExpression) {
|
|
9977
10245
|
continue;
|
|
9978
10246
|
}
|
|
9979
10247
|
for (const property of config.properties) {
|
|
9980
|
-
if (property.type !==
|
|
10248
|
+
if (property.type !== import_utils65.AST_NODE_TYPES.Property || propertyName2(property) !== "matcher" || property.value.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) {
|
|
9981
10249
|
continue;
|
|
9982
10250
|
}
|
|
9983
10251
|
if (!isStaticValue(property.value)) {
|
|
@@ -9991,18 +10259,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
9991
10259
|
});
|
|
9992
10260
|
|
|
9993
10261
|
// src/rules/require-zod-form-validation.ts
|
|
9994
|
-
var
|
|
10262
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
9995
10263
|
var looksLikeZodSchema = (node) => {
|
|
9996
10264
|
let current = node;
|
|
9997
10265
|
while (true) {
|
|
9998
|
-
if (current.type ===
|
|
10266
|
+
if (current.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
9999
10267
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10000
10268
|
}
|
|
10001
|
-
if (current.type ===
|
|
10269
|
+
if (current.type === import_utils66.AST_NODE_TYPES.CallExpression) {
|
|
10002
10270
|
current = current.callee;
|
|
10003
10271
|
continue;
|
|
10004
10272
|
}
|
|
10005
|
-
if (current.type ===
|
|
10273
|
+
if (current.type === import_utils66.AST_NODE_TYPES.MemberExpression) {
|
|
10006
10274
|
current = current.object;
|
|
10007
10275
|
continue;
|
|
10008
10276
|
}
|
|
@@ -10010,23 +10278,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10010
10278
|
}
|
|
10011
10279
|
};
|
|
10012
10280
|
var isZodParseCall = (node) => {
|
|
10013
|
-
if (node.type !==
|
|
10281
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.CallExpression) return false;
|
|
10014
10282
|
const callee = node.callee;
|
|
10015
|
-
if (callee.type !==
|
|
10283
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression) return false;
|
|
10016
10284
|
if (callee.computed) return false;
|
|
10017
|
-
if (callee.property.type !==
|
|
10285
|
+
if (callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier) return false;
|
|
10018
10286
|
const method = callee.property.name;
|
|
10019
10287
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10020
10288
|
return looksLikeZodSchema(callee.object);
|
|
10021
10289
|
};
|
|
10022
10290
|
var isFormDataMethodCall = (node) => {
|
|
10023
10291
|
let current = node;
|
|
10024
|
-
if (current.type ===
|
|
10292
|
+
if (current.type === import_utils66.AST_NODE_TYPES.AwaitExpression) {
|
|
10025
10293
|
current = current.argument;
|
|
10026
10294
|
}
|
|
10027
|
-
if (current.type !==
|
|
10295
|
+
if (current.type !== import_utils66.AST_NODE_TYPES.CallExpression) return false;
|
|
10028
10296
|
const callee = current.callee;
|
|
10029
|
-
return callee.type ===
|
|
10297
|
+
return callee.type === import_utils66.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils66.AST_NODE_TYPES.Identifier && callee.property.name === "formData";
|
|
10030
10298
|
};
|
|
10031
10299
|
var require_zod_form_validation_default = createRule({
|
|
10032
10300
|
name: "require-zod-form-validation",
|
|
@@ -10046,14 +10314,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10046
10314
|
return {};
|
|
10047
10315
|
}
|
|
10048
10316
|
const isFormSourceIdentifier = (node) => {
|
|
10049
|
-
if (node.type !==
|
|
10317
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.Identifier) return false;
|
|
10050
10318
|
if (/formdata/i.test(node.name)) return true;
|
|
10051
10319
|
let scope = context.sourceCode.getScope(node);
|
|
10052
10320
|
while (scope !== null) {
|
|
10053
10321
|
const variable = scope.set.get(node.name);
|
|
10054
10322
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10055
10323
|
const def = variable.defs[0];
|
|
10056
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10324
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === import_utils66.AST_NODE_TYPES.VariableDeclarator && def.node.init !== null) {
|
|
10057
10325
|
return isFormDataMethodCall(def.node.init);
|
|
10058
10326
|
}
|
|
10059
10327
|
return false;
|
|
@@ -10064,8 +10332,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10064
10332
|
};
|
|
10065
10333
|
const isFormDataGetCall = (node) => {
|
|
10066
10334
|
const callee = node.callee;
|
|
10067
|
-
if (callee.type !==
|
|
10068
|
-
if (callee.property.type !==
|
|
10335
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression) return false;
|
|
10336
|
+
if (callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier || callee.property.name !== "get") {
|
|
10069
10337
|
return false;
|
|
10070
10338
|
}
|
|
10071
10339
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10080,11 +10348,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10080
10348
|
};
|
|
10081
10349
|
const isInstanceofNarrowing = (node) => {
|
|
10082
10350
|
const parent = node.parent;
|
|
10083
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10351
|
+
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");
|
|
10084
10352
|
};
|
|
10085
10353
|
const boundDeclarator = (node) => {
|
|
10086
10354
|
const parent = node.parent;
|
|
10087
|
-
if (parent.type ===
|
|
10355
|
+
if (parent.type === import_utils66.AST_NODE_TYPES.VariableDeclarator && parent.init === node && parent.id.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
10088
10356
|
return parent;
|
|
10089
10357
|
}
|
|
10090
10358
|
return null;
|
|
@@ -10112,7 +10380,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
10112
10380
|
});
|
|
10113
10381
|
|
|
10114
10382
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
10115
|
-
var
|
|
10383
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
10116
10384
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
10117
10385
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
10118
10386
|
var INSERT_GATE = /insert/i;
|
|
@@ -10143,7 +10411,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10143
10411
|
});
|
|
10144
10412
|
|
|
10145
10413
|
// src/rules/zod-naming-convention.ts
|
|
10146
|
-
var
|
|
10414
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
10147
10415
|
var CONVENTIONS = {
|
|
10148
10416
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10149
10417
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10168,15 +10436,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10168
10436
|
"registry",
|
|
10169
10437
|
"implement"
|
|
10170
10438
|
]);
|
|
10171
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10439
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === import_utils68.AST_NODE_TYPES.Identifier ? callee.property.name : null;
|
|
10172
10440
|
var calleeChainStartsWithZ = (node) => {
|
|
10173
10441
|
let current = node;
|
|
10174
|
-
while (current.type ===
|
|
10442
|
+
while (current.type === import_utils68.AST_NODE_TYPES.MemberExpression) {
|
|
10175
10443
|
const receiver = current.object;
|
|
10176
|
-
if (receiver.type ===
|
|
10444
|
+
if (receiver.type === import_utils68.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
10177
10445
|
return true;
|
|
10178
10446
|
}
|
|
10179
|
-
if (receiver.type ===
|
|
10447
|
+
if (receiver.type === import_utils68.AST_NODE_TYPES.CallExpression) {
|
|
10180
10448
|
current = receiver.callee;
|
|
10181
10449
|
continue;
|
|
10182
10450
|
}
|
|
@@ -10221,13 +10489,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10221
10489
|
VariableDeclarator(node) {
|
|
10222
10490
|
const init = node.init;
|
|
10223
10491
|
if (init === null || init === void 0) return;
|
|
10224
|
-
if (init.type !==
|
|
10492
|
+
if (init.type !== import_utils68.AST_NODE_TYPES.CallExpression) return;
|
|
10225
10493
|
const callee = init.callee;
|
|
10226
|
-
if (callee.type !==
|
|
10494
|
+
if (callee.type !== import_utils68.AST_NODE_TYPES.MemberExpression) return;
|
|
10227
10495
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10228
10496
|
const terminal = terminalMethodName(callee);
|
|
10229
10497
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10230
|
-
if (node.id.type !==
|
|
10498
|
+
if (node.id.type !== import_utils68.AST_NODE_TYPES.Identifier) return;
|
|
10231
10499
|
if (test.test(node.id.name)) return;
|
|
10232
10500
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10233
10501
|
context.report({
|
|
@@ -10275,7 +10543,7 @@ var retiredRules = {
|
|
|
10275
10543
|
},
|
|
10276
10544
|
"prefer-shadcn": {
|
|
10277
10545
|
removedIn: "3.0.0",
|
|
10278
|
-
reason: "Delete the entry;
|
|
10546
|
+
reason: "Delete the retired entry; application-profile consumers can separately adopt `@sarj/prefer-shadcn-primitives`."
|
|
10279
10547
|
},
|
|
10280
10548
|
"primary-export-file-name": {
|
|
10281
10549
|
removedIn: "4.0.0",
|
|
@@ -10339,6 +10607,8 @@ var rules = {
|
|
|
10339
10607
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10340
10608
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10341
10609
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10610
|
+
"prefer-immutable-module-constant": prefer_immutable_module_constant_default,
|
|
10611
|
+
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
10342
10612
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10343
10613
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
10344
10614
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
@@ -10361,11 +10631,12 @@ var rules = {
|
|
|
10361
10631
|
};
|
|
10362
10632
|
var meta = {
|
|
10363
10633
|
name: "@sarj/eslint-plugin",
|
|
10364
|
-
version: "9.
|
|
10634
|
+
version: "9.13.0"
|
|
10365
10635
|
};
|
|
10366
10636
|
var applicationOnlyRules = [
|
|
10367
10637
|
"no-restricted-library-load",
|
|
10368
|
-
"prefer-native-random-uuid"
|
|
10638
|
+
"prefer-native-random-uuid",
|
|
10639
|
+
"prefer-shadcn-primitives"
|
|
10369
10640
|
];
|
|
10370
10641
|
var recommendedRules = {
|
|
10371
10642
|
"@sarj/enforce-file-structure": "warn",
|
|
@@ -10405,6 +10676,7 @@ var recommendedRules = {
|
|
|
10405
10676
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10406
10677
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10407
10678
|
"@sarj/prefer-input-group-search": "error",
|
|
10679
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10408
10680
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10409
10681
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10410
10682
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10466,6 +10738,7 @@ var strictRules = {
|
|
|
10466
10738
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10467
10739
|
"@sarj/prefer-discriminated-union": "error",
|
|
10468
10740
|
"@sarj/prefer-input-group-search": "error",
|
|
10741
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10469
10742
|
"@sarj/prefer-module-level-constant": "error",
|
|
10470
10743
|
"@sarj/prefer-module-level-schema": "error",
|
|
10471
10744
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10516,4 +10789,3 @@ var index_default = plugin;
|
|
|
10516
10789
|
rules,
|
|
10517
10790
|
strictRules
|
|
10518
10791
|
});
|
|
10519
|
-
//# sourceMappingURL=index.cjs.map
|