@sarj/eslint-plugin 9.12.1 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +493 -356
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +488 -351
- package/package.json +2 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.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,143 @@ var prefer_input_group_search_default = createRule({
|
|
|
6747
6747
|
}
|
|
6748
6748
|
});
|
|
6749
6749
|
|
|
6750
|
-
// src/rules/prefer-
|
|
6750
|
+
// src/rules/prefer-immutable-module-constant.ts
|
|
6751
6751
|
var import_utils49 = require("@typescript-eslint/utils");
|
|
6752
|
+
var CONSTANT_NAME = /^_?[A-Z][A-Z0-9_]*$/;
|
|
6753
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
6754
|
+
"add",
|
|
6755
|
+
"clear",
|
|
6756
|
+
"copyWithin",
|
|
6757
|
+
"delete",
|
|
6758
|
+
"fill",
|
|
6759
|
+
"pop",
|
|
6760
|
+
"push",
|
|
6761
|
+
"reverse",
|
|
6762
|
+
"set",
|
|
6763
|
+
"shift",
|
|
6764
|
+
"sort",
|
|
6765
|
+
"splice",
|
|
6766
|
+
"unshift"
|
|
6767
|
+
]);
|
|
6768
|
+
function isAsConst(node, sourceText) {
|
|
6769
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
6770
|
+
return isAsConst(node.expression, sourceText);
|
|
6771
|
+
}
|
|
6772
|
+
return node.type === import_utils49.AST_NODE_TYPES.TSAsExpression && sourceText(node.typeAnnotation).trim() === "const";
|
|
6773
|
+
}
|
|
6774
|
+
function unwrapExpression(node) {
|
|
6775
|
+
if (node.type === import_utils49.AST_NODE_TYPES.TSAsExpression || node.type === import_utils49.AST_NODE_TYPES.TSSatisfiesExpression || node.type === import_utils49.AST_NODE_TYPES.TSNonNullExpression) {
|
|
6776
|
+
return unwrapExpression(node.expression);
|
|
6777
|
+
}
|
|
6778
|
+
return node;
|
|
6779
|
+
}
|
|
6780
|
+
function isObjectFreeze(node) {
|
|
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");
|
|
6752
6887
|
var SHADCN_PRIMITIVES = {
|
|
6753
6888
|
button: "Button",
|
|
6754
6889
|
dialog: "Dialog or AlertDialog family",
|
|
@@ -6769,15 +6904,15 @@ var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
6769
6904
|
"textarea"
|
|
6770
6905
|
]);
|
|
6771
6906
|
function rawElementName(node) {
|
|
6772
|
-
if (node.name.type !==
|
|
6907
|
+
if (node.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier) return null;
|
|
6773
6908
|
const name = node.name.name;
|
|
6774
6909
|
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6775
6910
|
}
|
|
6776
6911
|
function staticExpressionString(expression) {
|
|
6777
|
-
if (expression.type ===
|
|
6912
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.Literal) {
|
|
6778
6913
|
return typeof expression.value === "string" ? expression.value : null;
|
|
6779
6914
|
}
|
|
6780
|
-
if (expression.type ===
|
|
6915
|
+
if (expression.type === import_utils50.AST_NODE_TYPES.TemplateLiteral) {
|
|
6781
6916
|
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6782
6917
|
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6783
6918
|
const staticSubstitution = staticExpressionString(substitution);
|
|
@@ -6787,24 +6922,24 @@ function staticExpressionString(expression) {
|
|
|
6787
6922
|
}
|
|
6788
6923
|
return value;
|
|
6789
6924
|
}
|
|
6790
|
-
if (expression.type ===
|
|
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) {
|
|
6791
6926
|
return staticExpressionString(expression.expression);
|
|
6792
6927
|
}
|
|
6793
6928
|
return null;
|
|
6794
6929
|
}
|
|
6795
6930
|
function staticString(value) {
|
|
6796
|
-
if (value?.type ===
|
|
6931
|
+
if (value?.type === import_utils50.AST_NODE_TYPES.Literal) {
|
|
6797
6932
|
return typeof value.value === "string" ? value.value : null;
|
|
6798
6933
|
}
|
|
6799
|
-
if (value?.type !==
|
|
6934
|
+
if (value?.type !== import_utils50.AST_NODE_TYPES.JSXExpressionContainer) return null;
|
|
6800
6935
|
return staticExpressionString(value.expression);
|
|
6801
6936
|
}
|
|
6802
6937
|
function effectiveAttribute(node, attributeName) {
|
|
6803
6938
|
for (const attribute of node.attributes.toReversed()) {
|
|
6804
|
-
if (attribute.type ===
|
|
6939
|
+
if (attribute.type === import_utils50.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
6805
6940
|
return { kind: "unknown" };
|
|
6806
6941
|
}
|
|
6807
|
-
if (attribute.name.type !==
|
|
6942
|
+
if (attribute.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6808
6943
|
continue;
|
|
6809
6944
|
}
|
|
6810
6945
|
const value = staticString(attribute.value);
|
|
@@ -6813,7 +6948,7 @@ function effectiveAttribute(node, attributeName) {
|
|
|
6813
6948
|
return { kind: "missing" };
|
|
6814
6949
|
}
|
|
6815
6950
|
function isLabelableElement(node) {
|
|
6816
|
-
if (node.openingElement.name.type !==
|
|
6951
|
+
if (node.openingElement.name.type !== import_utils50.AST_NODE_TYPES.JSXIdentifier) {
|
|
6817
6952
|
return false;
|
|
6818
6953
|
}
|
|
6819
6954
|
const name = node.openingElement.name.name;
|
|
@@ -6825,10 +6960,10 @@ function isLabelableElement(node) {
|
|
|
6825
6960
|
}
|
|
6826
6961
|
function containsLabelableElement(node) {
|
|
6827
6962
|
return node.children.some((child) => {
|
|
6828
|
-
if (child.type ===
|
|
6963
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXElement) {
|
|
6829
6964
|
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6830
6965
|
}
|
|
6831
|
-
if (child.type ===
|
|
6966
|
+
if (child.type === import_utils50.AST_NODE_TYPES.JSXFragment) {
|
|
6832
6967
|
return containsLabelableElement(child);
|
|
6833
6968
|
}
|
|
6834
6969
|
return false;
|
|
@@ -6837,7 +6972,7 @@ function containsLabelableElement(node) {
|
|
|
6837
6972
|
function isStaticallyAssociatedLabel(node) {
|
|
6838
6973
|
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6839
6974
|
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6840
|
-
return node.parent.type ===
|
|
6975
|
+
return node.parent.type === import_utils50.AST_NODE_TYPES.JSXElement && containsLabelableElement(node.parent);
|
|
6841
6976
|
}
|
|
6842
6977
|
function replacementFor(node, element) {
|
|
6843
6978
|
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
@@ -6881,7 +7016,7 @@ var prefer_shadcn_primitives_default = createRule({
|
|
|
6881
7016
|
});
|
|
6882
7017
|
|
|
6883
7018
|
// src/rules/prefer-module-level-constant.ts
|
|
6884
|
-
var
|
|
7019
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
6885
7020
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6886
7021
|
var MAX_LITERAL_DEPTH = 4;
|
|
6887
7022
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6890,7 +7025,7 @@ var IGNORE_PATTERNS2 = [
|
|
|
6890
7025
|
/\.generated\.tsx?$/,
|
|
6891
7026
|
/\.d\.ts$/
|
|
6892
7027
|
];
|
|
6893
|
-
var
|
|
7028
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
6894
7029
|
// Array
|
|
6895
7030
|
"push",
|
|
6896
7031
|
"pop",
|
|
@@ -6910,9 +7045,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6910
7045
|
"assign"
|
|
6911
7046
|
]);
|
|
6912
7047
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
7048
|
+
import_utils51.AST_NODE_TYPES.FunctionDeclaration,
|
|
7049
|
+
import_utils51.AST_NODE_TYPES.FunctionExpression,
|
|
7050
|
+
import_utils51.AST_NODE_TYPES.ArrowFunctionExpression
|
|
6916
7051
|
]);
|
|
6917
7052
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6918
7053
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6925,14 +7060,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6925
7060
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6926
7061
|
}
|
|
6927
7062
|
function unwrap3(node) {
|
|
6928
|
-
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) {
|
|
6929
7064
|
return unwrap3(node.expression);
|
|
6930
7065
|
}
|
|
6931
7066
|
return node;
|
|
6932
7067
|
}
|
|
6933
7068
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6934
7069
|
function isRegexLiteral(node) {
|
|
6935
|
-
return node.type ===
|
|
7070
|
+
return node.type === import_utils51.AST_NODE_TYPES.Literal && "regex" in node && node.regex !== void 0;
|
|
6936
7071
|
}
|
|
6937
7072
|
function isLiteralOnly(node, depth) {
|
|
6938
7073
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6940,29 +7075,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6940
7075
|
}
|
|
6941
7076
|
const inner = unwrap3(node);
|
|
6942
7077
|
switch (inner.type) {
|
|
6943
|
-
case
|
|
7078
|
+
case import_utils51.AST_NODE_TYPES.Literal: {
|
|
6944
7079
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6945
7080
|
}
|
|
6946
|
-
case
|
|
7081
|
+
case import_utils51.AST_NODE_TYPES.TemplateLiteral: {
|
|
6947
7082
|
return inner.expressions.length === 0;
|
|
6948
7083
|
}
|
|
6949
|
-
case
|
|
6950
|
-
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";
|
|
6951
7086
|
}
|
|
6952
|
-
case
|
|
7087
|
+
case import_utils51.AST_NODE_TYPES.ArrayExpression: {
|
|
6953
7088
|
return inner.elements.every(
|
|
6954
|
-
(el) => el !== null && el.type !==
|
|
7089
|
+
(el) => el !== null && el.type !== import_utils51.AST_NODE_TYPES.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6955
7090
|
);
|
|
6956
7091
|
}
|
|
6957
|
-
case
|
|
7092
|
+
case import_utils51.AST_NODE_TYPES.ObjectExpression: {
|
|
6958
7093
|
return inner.properties.every((prop) => {
|
|
6959
|
-
if (prop.type !==
|
|
7094
|
+
if (prop.type !== import_utils51.AST_NODE_TYPES.Property) {
|
|
6960
7095
|
return false;
|
|
6961
7096
|
}
|
|
6962
7097
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6963
7098
|
return false;
|
|
6964
7099
|
}
|
|
6965
|
-
if (prop.computed && prop.key.type !==
|
|
7100
|
+
if (prop.computed && prop.key.type !== import_utils51.AST_NODE_TYPES.Literal) {
|
|
6966
7101
|
return false;
|
|
6967
7102
|
}
|
|
6968
7103
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6975,7 +7110,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6975
7110
|
}
|
|
6976
7111
|
function unwrapObjectFreeze(node) {
|
|
6977
7112
|
const inner = unwrap3(node);
|
|
6978
|
-
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) {
|
|
6979
7114
|
return unwrap3(inner.arguments[0]);
|
|
6980
7115
|
}
|
|
6981
7116
|
return inner;
|
|
@@ -6991,19 +7126,19 @@ function classify(init, checkRegex) {
|
|
|
6991
7126
|
}
|
|
6992
7127
|
return { kind: "regex", size: 1 };
|
|
6993
7128
|
}
|
|
6994
|
-
if (node.type ===
|
|
7129
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ArrayExpression) {
|
|
6995
7130
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6996
7131
|
}
|
|
6997
|
-
if (node.type ===
|
|
7132
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ObjectExpression) {
|
|
6998
7133
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6999
7134
|
}
|
|
7000
|
-
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)) {
|
|
7001
7136
|
const arg = node.arguments[0];
|
|
7002
|
-
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) {
|
|
7003
7138
|
return null;
|
|
7004
7139
|
}
|
|
7005
7140
|
const entries = unwrap3(arg);
|
|
7006
|
-
if (entries.type !==
|
|
7141
|
+
if (entries.type !== import_utils51.AST_NODE_TYPES.ArrayExpression) {
|
|
7007
7142
|
return null;
|
|
7008
7143
|
}
|
|
7009
7144
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -7032,10 +7167,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
7032
7167
|
);
|
|
7033
7168
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
7034
7169
|
const callee = node.callee;
|
|
7035
|
-
if (callee.type ===
|
|
7170
|
+
if (callee.type === import_utils51.AST_NODE_TYPES.Identifier && callee.name === "structuredClone") {
|
|
7036
7171
|
return true;
|
|
7037
7172
|
}
|
|
7038
|
-
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) {
|
|
7039
7174
|
return false;
|
|
7040
7175
|
}
|
|
7041
7176
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -7049,38 +7184,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
7049
7184
|
}
|
|
7050
7185
|
function isSafeRead(identifier) {
|
|
7051
7186
|
const parent = identifier.parent;
|
|
7052
|
-
if (parent.type ===
|
|
7187
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.MemberExpression) {
|
|
7053
7188
|
if (parent.object !== identifier) {
|
|
7054
7189
|
return true;
|
|
7055
7190
|
}
|
|
7056
7191
|
const grandparent = parent.parent;
|
|
7057
|
-
if (grandparent.type ===
|
|
7192
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.AssignmentExpression && grandparent.left === parent) {
|
|
7058
7193
|
return false;
|
|
7059
7194
|
}
|
|
7060
|
-
if (grandparent.type ===
|
|
7195
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.UpdateExpression) {
|
|
7061
7196
|
return false;
|
|
7062
7197
|
}
|
|
7063
|
-
if (grandparent.type ===
|
|
7198
|
+
if (grandparent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && grandparent.operator === "delete") {
|
|
7064
7199
|
return false;
|
|
7065
7200
|
}
|
|
7066
|
-
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) {
|
|
7067
7202
|
return false;
|
|
7068
7203
|
}
|
|
7069
7204
|
return true;
|
|
7070
7205
|
}
|
|
7071
|
-
if (parent.type ===
|
|
7206
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.ForOfStatement && parent.right === identifier) {
|
|
7072
7207
|
return true;
|
|
7073
7208
|
}
|
|
7074
|
-
if (parent.type ===
|
|
7209
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.SpreadElement) {
|
|
7075
7210
|
return true;
|
|
7076
7211
|
}
|
|
7077
|
-
if (parent.type ===
|
|
7212
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.BinaryExpression) {
|
|
7078
7213
|
return true;
|
|
7079
7214
|
}
|
|
7080
|
-
if (parent.type ===
|
|
7215
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
7081
7216
|
return true;
|
|
7082
7217
|
}
|
|
7083
|
-
if (parent.type ===
|
|
7218
|
+
if (parent.type === import_utils51.AST_NODE_TYPES.UnaryExpression && parent.operator !== "delete") {
|
|
7084
7219
|
return true;
|
|
7085
7220
|
}
|
|
7086
7221
|
return false;
|
|
@@ -7135,7 +7270,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7135
7270
|
if (reference.isWrite()) {
|
|
7136
7271
|
return false;
|
|
7137
7272
|
}
|
|
7138
|
-
if (reference.identifier.type !==
|
|
7273
|
+
if (reference.identifier.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
7139
7274
|
return false;
|
|
7140
7275
|
}
|
|
7141
7276
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -7147,10 +7282,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7147
7282
|
return {
|
|
7148
7283
|
VariableDeclarator(node) {
|
|
7149
7284
|
const declaration = node.parent;
|
|
7150
|
-
if (declaration.type !==
|
|
7285
|
+
if (declaration.type !== import_utils51.AST_NODE_TYPES.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
7151
7286
|
return;
|
|
7152
7287
|
}
|
|
7153
|
-
if (node.id.type !==
|
|
7288
|
+
if (node.id.type !== import_utils51.AST_NODE_TYPES.Identifier || node.init === null) {
|
|
7154
7289
|
return;
|
|
7155
7290
|
}
|
|
7156
7291
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7177,7 +7312,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7177
7312
|
});
|
|
7178
7313
|
|
|
7179
7314
|
// src/rules/prefer-module-level-schema.ts
|
|
7180
|
-
var
|
|
7315
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7181
7316
|
|
|
7182
7317
|
// src/rules/_zod.ts
|
|
7183
7318
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7243,9 +7378,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7243
7378
|
"intl"
|
|
7244
7379
|
]);
|
|
7245
7380
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7381
|
+
import_utils52.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
7382
|
+
import_utils52.AST_NODE_TYPES.FunctionDeclaration,
|
|
7383
|
+
import_utils52.AST_NODE_TYPES.FunctionExpression
|
|
7249
7384
|
]);
|
|
7250
7385
|
function schemaExpression(node) {
|
|
7251
7386
|
let current = node;
|
|
@@ -7254,10 +7389,10 @@ function schemaExpression(node) {
|
|
|
7254
7389
|
if (parent === void 0) {
|
|
7255
7390
|
return current;
|
|
7256
7391
|
}
|
|
7257
|
-
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)) {
|
|
7258
7393
|
return current;
|
|
7259
7394
|
}
|
|
7260
|
-
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) {
|
|
7261
7396
|
current = parent;
|
|
7262
7397
|
continue;
|
|
7263
7398
|
}
|
|
@@ -7308,22 +7443,22 @@ function subtreeSome(root, predicate) {
|
|
|
7308
7443
|
function readsReceiver(node) {
|
|
7309
7444
|
return subtreeSome(
|
|
7310
7445
|
node,
|
|
7311
|
-
(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"
|
|
7312
7447
|
);
|
|
7313
7448
|
}
|
|
7314
7449
|
function buildsLocalizedText(node) {
|
|
7315
7450
|
return subtreeSome(node, (inner) => {
|
|
7316
|
-
if (inner.type ===
|
|
7451
|
+
if (inner.type === import_utils52.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
7317
7452
|
return true;
|
|
7318
7453
|
}
|
|
7319
|
-
if (inner.type !==
|
|
7454
|
+
if (inner.type !== import_utils52.AST_NODE_TYPES.CallExpression) {
|
|
7320
7455
|
return false;
|
|
7321
7456
|
}
|
|
7322
7457
|
const { callee } = inner;
|
|
7323
|
-
if (callee.type ===
|
|
7458
|
+
if (callee.type === import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7324
7459
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7325
7460
|
}
|
|
7326
|
-
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);
|
|
7327
7462
|
});
|
|
7328
7463
|
}
|
|
7329
7464
|
function collectReferences(scope, out) {
|
|
@@ -7380,15 +7515,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7380
7515
|
}
|
|
7381
7516
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7382
7517
|
function isZodCall(node) {
|
|
7383
|
-
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);
|
|
7384
7519
|
}
|
|
7385
7520
|
function isCovered(node) {
|
|
7386
7521
|
let current = node.parent ?? void 0;
|
|
7387
7522
|
while (current !== void 0) {
|
|
7388
|
-
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)) {
|
|
7389
7524
|
return true;
|
|
7390
7525
|
}
|
|
7391
|
-
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))) {
|
|
7392
7527
|
return true;
|
|
7393
7528
|
}
|
|
7394
7529
|
current = current.parent ?? void 0;
|
|
@@ -7403,11 +7538,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7403
7538
|
if (parent === void 0) {
|
|
7404
7539
|
return confirmed;
|
|
7405
7540
|
}
|
|
7406
|
-
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) {
|
|
7407
7542
|
current = parent;
|
|
7408
7543
|
continue;
|
|
7409
7544
|
}
|
|
7410
|
-
if (parent.type ===
|
|
7545
|
+
if (parent.type === import_utils52.AST_NODE_TYPES.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7411
7546
|
current = schemaExpression(parent);
|
|
7412
7547
|
confirmed = current;
|
|
7413
7548
|
continue;
|
|
@@ -7417,7 +7552,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7417
7552
|
}
|
|
7418
7553
|
function isSchemaComposition(node) {
|
|
7419
7554
|
const { callee } = node;
|
|
7420
|
-
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);
|
|
7421
7556
|
return isCombinator || isZodCall(node);
|
|
7422
7557
|
}
|
|
7423
7558
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7451,13 +7586,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7451
7586
|
}
|
|
7452
7587
|
function ownerName(enclosing) {
|
|
7453
7588
|
const parent = enclosing.parent ?? void 0;
|
|
7454
|
-
if (enclosing.type ===
|
|
7589
|
+
if (enclosing.type === import_utils52.AST_NODE_TYPES.FunctionDeclaration && enclosing.id !== null) {
|
|
7455
7590
|
return enclosing.id.name;
|
|
7456
7591
|
}
|
|
7457
|
-
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) {
|
|
7458
7593
|
return parent.id.name;
|
|
7459
7594
|
}
|
|
7460
|
-
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) {
|
|
7461
7596
|
return parent.key.name;
|
|
7462
7597
|
}
|
|
7463
7598
|
return "this function";
|
|
@@ -7468,7 +7603,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7468
7603
|
return;
|
|
7469
7604
|
}
|
|
7470
7605
|
for (const specifier of node.specifiers) {
|
|
7471
|
-
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") {
|
|
7472
7607
|
zodNamespaces.add(specifier.local.name);
|
|
7473
7608
|
}
|
|
7474
7609
|
}
|
|
@@ -7478,7 +7613,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7478
7613
|
return;
|
|
7479
7614
|
}
|
|
7480
7615
|
const callee = node.callee;
|
|
7481
|
-
if (callee.property.type !==
|
|
7616
|
+
if (callee.property.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
7482
7617
|
return;
|
|
7483
7618
|
}
|
|
7484
7619
|
const factory = callee.property.name;
|
|
@@ -7493,7 +7628,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7493
7628
|
return;
|
|
7494
7629
|
}
|
|
7495
7630
|
const shape = node.arguments[0];
|
|
7496
|
-
if (shape !== void 0 && shape.type ===
|
|
7631
|
+
if (shape !== void 0 && shape.type === import_utils52.AST_NODE_TYPES.ObjectExpression && shape.properties.length < minProperties) {
|
|
7497
7632
|
return;
|
|
7498
7633
|
}
|
|
7499
7634
|
const expression = schemaExpression(node);
|
|
@@ -7521,9 +7656,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7521
7656
|
});
|
|
7522
7657
|
|
|
7523
7658
|
// src/rules/prefer-native-random-uuid.ts
|
|
7524
|
-
var
|
|
7659
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7525
7660
|
function requireUuid(node) {
|
|
7526
|
-
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";
|
|
7527
7662
|
}
|
|
7528
7663
|
var prefer_native_random_uuid_default = createRule({
|
|
7529
7664
|
name: "prefer-native-random-uuid",
|
|
@@ -7544,7 +7679,7 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7544
7679
|
const directBindings = /* @__PURE__ */ new Set();
|
|
7545
7680
|
const namespaceBindings = /* @__PURE__ */ new Set();
|
|
7546
7681
|
function resolve(identifier) {
|
|
7547
|
-
return
|
|
7682
|
+
return import_utils53.ASTUtils.findVariable(context.sourceCode.getScope(identifier), identifier.name);
|
|
7548
7683
|
}
|
|
7549
7684
|
function record(identifier, destination) {
|
|
7550
7685
|
const variable = resolve(identifier);
|
|
@@ -7566,37 +7701,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7566
7701
|
ImportDeclaration(node) {
|
|
7567
7702
|
if (node.source.value !== "uuid") return;
|
|
7568
7703
|
for (const specifier of node.specifiers) {
|
|
7569
|
-
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")) {
|
|
7570
7705
|
record(specifier.local, directBindings);
|
|
7571
|
-
} else if (specifier.type ===
|
|
7706
|
+
} else if (specifier.type === import_utils53.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
7572
7707
|
record(specifier.local, namespaceBindings);
|
|
7573
7708
|
}
|
|
7574
7709
|
}
|
|
7575
7710
|
},
|
|
7576
7711
|
VariableDeclarator(node) {
|
|
7577
7712
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7578
|
-
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) {
|
|
7579
7714
|
return;
|
|
7580
7715
|
}
|
|
7581
|
-
if (node.id.type ===
|
|
7716
|
+
if (node.id.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7582
7717
|
record(node.id, namespaceBindings);
|
|
7583
7718
|
return;
|
|
7584
7719
|
}
|
|
7585
|
-
if (node.id.type !==
|
|
7720
|
+
if (node.id.type !== import_utils53.AST_NODE_TYPES.ObjectPattern) return;
|
|
7586
7721
|
for (const property of node.id.properties) {
|
|
7587
|
-
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) {
|
|
7588
7723
|
record(property.value, directBindings);
|
|
7589
7724
|
}
|
|
7590
7725
|
}
|
|
7591
7726
|
},
|
|
7592
7727
|
"CallExpression:exit"(node) {
|
|
7593
7728
|
if (node.arguments.length !== 0) return;
|
|
7594
|
-
if (node.callee.type ===
|
|
7729
|
+
if (node.callee.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7595
7730
|
const variable2 = resolve(node.callee);
|
|
7596
7731
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7597
7732
|
return;
|
|
7598
7733
|
}
|
|
7599
|
-
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") {
|
|
7600
7735
|
return;
|
|
7601
7736
|
}
|
|
7602
7737
|
const variable = resolve(node.callee.object);
|
|
@@ -7607,20 +7742,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7607
7742
|
});
|
|
7608
7743
|
|
|
7609
7744
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7610
|
-
var
|
|
7745
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7611
7746
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7612
7747
|
function propertyName(node) {
|
|
7613
7748
|
const key = node.key;
|
|
7614
|
-
if (key.type ===
|
|
7615
|
-
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);
|
|
7616
7751
|
return "collection";
|
|
7617
7752
|
}
|
|
7618
7753
|
function isArrayType(node) {
|
|
7619
|
-
if (node.type ===
|
|
7620
|
-
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);
|
|
7621
7756
|
}
|
|
7622
7757
|
function isNullishType(node) {
|
|
7623
|
-
return node.type ===
|
|
7758
|
+
return node.type === import_utils54.AST_NODE_TYPES.TSNullKeyword || node.type === import_utils54.AST_NODE_TYPES.TSUndefinedKeyword;
|
|
7624
7759
|
}
|
|
7625
7760
|
function isNullableArrayOnly(node) {
|
|
7626
7761
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7648,7 +7783,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7648
7783
|
if (node.optional) return;
|
|
7649
7784
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7650
7785
|
if (annotation === void 0) return;
|
|
7651
|
-
if (annotation.type !==
|
|
7786
|
+
if (annotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7652
7787
|
return;
|
|
7653
7788
|
}
|
|
7654
7789
|
context.report({
|
|
@@ -7661,7 +7796,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7661
7796
|
TSPropertySignature: checkOptionalProperty,
|
|
7662
7797
|
PropertyDefinition: checkOptionalProperty,
|
|
7663
7798
|
TSTypeAliasDeclaration(node) {
|
|
7664
|
-
if (node.typeAnnotation.type !==
|
|
7799
|
+
if (node.typeAnnotation.type !== import_utils54.AST_NODE_TYPES.TSUnionType) return;
|
|
7665
7800
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7666
7801
|
context.report({
|
|
7667
7802
|
node,
|
|
@@ -7674,13 +7809,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7674
7809
|
});
|
|
7675
7810
|
|
|
7676
7811
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7677
|
-
var
|
|
7812
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
7678
7813
|
var unwrap4 = (node) => {
|
|
7679
7814
|
let current = node;
|
|
7680
7815
|
while (current !== null && current !== void 0) {
|
|
7681
|
-
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) {
|
|
7682
7817
|
current = current.expression;
|
|
7683
|
-
} else if (current.type ===
|
|
7818
|
+
} else if (current.type === import_utils55.AST_NODE_TYPES.ChainExpression) {
|
|
7684
7819
|
current = current.expression;
|
|
7685
7820
|
} else {
|
|
7686
7821
|
break;
|
|
@@ -7695,23 +7830,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7695
7830
|
]);
|
|
7696
7831
|
var isSchemaParseReference = (node) => {
|
|
7697
7832
|
const inner = unwrap4(node);
|
|
7698
|
-
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");
|
|
7699
7834
|
};
|
|
7700
7835
|
var isRawPayloadSource = (node) => {
|
|
7701
7836
|
let current = unwrap4(node);
|
|
7702
7837
|
if (current === null) return false;
|
|
7703
|
-
if (current.type ===
|
|
7838
|
+
if (current.type === import_utils55.AST_NODE_TYPES.AwaitExpression) {
|
|
7704
7839
|
current = unwrap4(current.argument);
|
|
7705
7840
|
}
|
|
7706
|
-
if (current === null || current.type !==
|
|
7841
|
+
if (current === null || current.type !== import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7707
7842
|
return false;
|
|
7708
7843
|
}
|
|
7709
7844
|
const callee = unwrap4(current.callee);
|
|
7710
|
-
if (callee === null || callee.type !==
|
|
7845
|
+
if (callee === null || callee.type !== import_utils55.AST_NODE_TYPES.MemberExpression) {
|
|
7711
7846
|
return false;
|
|
7712
7847
|
}
|
|
7713
7848
|
const property = unwrap4(callee.property);
|
|
7714
|
-
if (property === null || property.type !==
|
|
7849
|
+
if (property === null || property.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7715
7850
|
return false;
|
|
7716
7851
|
}
|
|
7717
7852
|
if (property.name === "json") {
|
|
@@ -7721,16 +7856,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7721
7856
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7722
7857
|
}
|
|
7723
7858
|
const object = unwrap4(callee.object);
|
|
7724
|
-
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]);
|
|
7725
7860
|
};
|
|
7726
7861
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7727
7862
|
var isLocalFileRead = (node) => {
|
|
7728
7863
|
let found = false;
|
|
7729
7864
|
const visit = (current) => {
|
|
7730
7865
|
if (found || current === null || current === void 0) return;
|
|
7731
|
-
if (current.type ===
|
|
7866
|
+
if (current.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7732
7867
|
const callee = unwrap4(current.callee);
|
|
7733
|
-
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;
|
|
7734
7869
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7735
7870
|
found = true;
|
|
7736
7871
|
return;
|
|
@@ -7752,15 +7887,15 @@ var isLocalFileRead = (node) => {
|
|
|
7752
7887
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7753
7888
|
var isInsideAssertion = (node) => {
|
|
7754
7889
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7755
|
-
if (current.type !==
|
|
7890
|
+
if (current.type !== import_utils55.AST_NODE_TYPES.CallExpression) continue;
|
|
7756
7891
|
let callee = current.callee;
|
|
7757
|
-
while (callee.type ===
|
|
7892
|
+
while (callee.type === import_utils55.AST_NODE_TYPES.MemberExpression) {
|
|
7758
7893
|
callee = callee.object;
|
|
7759
7894
|
}
|
|
7760
|
-
if (callee.type ===
|
|
7895
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.CallExpression) {
|
|
7761
7896
|
callee = callee.callee;
|
|
7762
7897
|
}
|
|
7763
|
-
if (callee.type ===
|
|
7898
|
+
if (callee.type === import_utils55.AST_NODE_TYPES.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7764
7899
|
return true;
|
|
7765
7900
|
}
|
|
7766
7901
|
}
|
|
@@ -7779,39 +7914,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7779
7914
|
var isValidationRead = (node) => {
|
|
7780
7915
|
let current = node;
|
|
7781
7916
|
let parent = current.parent;
|
|
7782
|
-
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)) {
|
|
7783
7918
|
current = parent;
|
|
7784
7919
|
parent = parent.parent;
|
|
7785
7920
|
}
|
|
7786
7921
|
if (parent === null || parent === void 0) return false;
|
|
7787
|
-
if (parent.type ===
|
|
7922
|
+
if (parent.type === import_utils55.AST_NODE_TYPES.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7788
7923
|
return true;
|
|
7789
7924
|
}
|
|
7790
|
-
if (parent.type !==
|
|
7925
|
+
if (parent.type !== import_utils55.AST_NODE_TYPES.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7791
7926
|
return false;
|
|
7792
7927
|
}
|
|
7793
7928
|
const callee = parent.callee;
|
|
7794
|
-
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") {
|
|
7795
7930
|
return parent.arguments.length === 1;
|
|
7796
7931
|
}
|
|
7797
|
-
return callee.type ===
|
|
7932
|
+
return callee.type === import_utils55.AST_NODE_TYPES.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7798
7933
|
};
|
|
7799
7934
|
var isGuardTestPosition = (node) => {
|
|
7800
7935
|
let current = node;
|
|
7801
7936
|
let parent = current.parent;
|
|
7802
7937
|
while (parent !== void 0 && parent !== null) {
|
|
7803
7938
|
switch (parent.type) {
|
|
7804
|
-
case
|
|
7805
|
-
case
|
|
7806
|
-
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:
|
|
7807
7942
|
current = parent;
|
|
7808
7943
|
parent = parent.parent;
|
|
7809
7944
|
continue;
|
|
7810
|
-
case
|
|
7811
|
-
case
|
|
7812
|
-
case
|
|
7813
|
-
case
|
|
7814
|
-
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:
|
|
7815
7950
|
return parent.test === current;
|
|
7816
7951
|
default:
|
|
7817
7952
|
return false;
|
|
@@ -7821,7 +7956,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7821
7956
|
};
|
|
7822
7957
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7823
7958
|
const unwrapped = unwrap4(node);
|
|
7824
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7959
|
+
if (unwrapped === null || unwrapped.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7825
7960
|
return false;
|
|
7826
7961
|
}
|
|
7827
7962
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7864,11 +7999,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7864
7999
|
return {
|
|
7865
8000
|
VariableDeclarator(node) {
|
|
7866
8001
|
const scope = context.sourceCode.getScope(node);
|
|
7867
|
-
if (node.id.type ===
|
|
8002
|
+
if (node.id.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7868
8003
|
trackInitializer(node);
|
|
7869
8004
|
return;
|
|
7870
8005
|
}
|
|
7871
|
-
if (node.id.type ===
|
|
8006
|
+
if (node.id.type === import_utils55.AST_NODE_TYPES.ObjectPattern || node.id.type === import_utils55.AST_NODE_TYPES.ArrayPattern) {
|
|
7872
8007
|
if (isRawPayloadSource(node.init)) {
|
|
7873
8008
|
if (!isFullyNarrowedPattern(node)) {
|
|
7874
8009
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7882,7 +8017,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7882
8017
|
},
|
|
7883
8018
|
AssignmentExpression(node) {
|
|
7884
8019
|
const scope = context.sourceCode.getScope(node);
|
|
7885
|
-
if (node.left.type ===
|
|
8020
|
+
if (node.left.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7886
8021
|
const variable = findVariable2(scope, node.left.name);
|
|
7887
8022
|
if (variable === null) return;
|
|
7888
8023
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7892,7 +8027,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7892
8027
|
}
|
|
7893
8028
|
return;
|
|
7894
8029
|
}
|
|
7895
|
-
if (node.left.type ===
|
|
8030
|
+
if (node.left.type === import_utils55.AST_NODE_TYPES.ObjectPattern || node.left.type === import_utils55.AST_NODE_TYPES.ArrayPattern) {
|
|
7896
8031
|
if (isRawPayloadSource(node.right)) {
|
|
7897
8032
|
context.report({
|
|
7898
8033
|
node: node.left,
|
|
@@ -7909,15 +8044,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7909
8044
|
}
|
|
7910
8045
|
},
|
|
7911
8046
|
CallExpression(node) {
|
|
7912
|
-
if (node.callee.type !==
|
|
8047
|
+
if (node.callee.type !== import_utils55.AST_NODE_TYPES.Identifier) return;
|
|
7913
8048
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7914
8049
|
return;
|
|
7915
8050
|
}
|
|
7916
8051
|
const scope = context.sourceCode.getScope(node);
|
|
7917
8052
|
for (const arg of node.arguments) {
|
|
7918
|
-
if (arg.type ===
|
|
8053
|
+
if (arg.type === import_utils55.AST_NODE_TYPES.SpreadElement) continue;
|
|
7919
8054
|
const unwrapped = unwrap4(arg);
|
|
7920
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8055
|
+
if (unwrapped === null || unwrapped.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7921
8056
|
continue;
|
|
7922
8057
|
}
|
|
7923
8058
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7931,13 +8066,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7931
8066
|
const obj = unwrap4(node.object);
|
|
7932
8067
|
if (isRawPayloadSource(obj)) {
|
|
7933
8068
|
const parent = node.parent;
|
|
7934
|
-
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))) {
|
|
7935
8070
|
return;
|
|
7936
8071
|
}
|
|
7937
8072
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7938
8073
|
return;
|
|
7939
8074
|
}
|
|
7940
|
-
if (obj !== null && obj.type ===
|
|
8075
|
+
if (obj !== null && obj.type === import_utils55.AST_NODE_TYPES.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7941
8076
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7942
8077
|
const variable = findVariable2(scope, obj.name);
|
|
7943
8078
|
if (variable !== null) {
|
|
@@ -7950,7 +8085,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7950
8085
|
});
|
|
7951
8086
|
|
|
7952
8087
|
// src/rules/prefer-semantic-colors.ts
|
|
7953
|
-
var
|
|
8088
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
7954
8089
|
var import_fs = require("fs");
|
|
7955
8090
|
var import_path = require("path");
|
|
7956
8091
|
|
|
@@ -8050,8 +8185,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
8050
8185
|
]);
|
|
8051
8186
|
function jsxElementName(node) {
|
|
8052
8187
|
const name = node.openingElement.name;
|
|
8053
|
-
if (name.type ===
|
|
8054
|
-
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) {
|
|
8055
8190
|
return name.property.name;
|
|
8056
8191
|
}
|
|
8057
8192
|
return null;
|
|
@@ -8077,7 +8212,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
8077
8212
|
var isInsideSvg = (node) => {
|
|
8078
8213
|
let current = node.parent;
|
|
8079
8214
|
while (current !== void 0 && current !== null) {
|
|
8080
|
-
if (current.type ===
|
|
8215
|
+
if (current.type === import_utils56.AST_NODE_TYPES.JSXElement) {
|
|
8081
8216
|
const name = jsxElementName(current);
|
|
8082
8217
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
8083
8218
|
}
|
|
@@ -8088,7 +8223,7 @@ var isInsideSvg = (node) => {
|
|
|
8088
8223
|
var isInsideIconFactoryPath = (node) => {
|
|
8089
8224
|
let current = node.parent;
|
|
8090
8225
|
while (current !== void 0 && current !== null) {
|
|
8091
|
-
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") {
|
|
8092
8227
|
return true;
|
|
8093
8228
|
}
|
|
8094
8229
|
current = current.parent;
|
|
@@ -8225,12 +8360,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8225
8360
|
return root !== null && workspaceHasMarker(root);
|
|
8226
8361
|
};
|
|
8227
8362
|
var propName = (key) => {
|
|
8228
|
-
if (key.type ===
|
|
8229
|
-
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;
|
|
8230
8365
|
return null;
|
|
8231
8366
|
};
|
|
8232
8367
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8233
|
-
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) {
|
|
8234
8369
|
return false;
|
|
8235
8370
|
}
|
|
8236
8371
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8282,27 +8417,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8282
8417
|
const checkClassNode = (node) => {
|
|
8283
8418
|
if (node === null) return;
|
|
8284
8419
|
switch (node.type) {
|
|
8285
|
-
case
|
|
8420
|
+
case import_utils56.AST_NODE_TYPES.Literal:
|
|
8286
8421
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8287
8422
|
break;
|
|
8288
|
-
case
|
|
8423
|
+
case import_utils56.AST_NODE_TYPES.TemplateLiteral:
|
|
8289
8424
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8290
8425
|
break;
|
|
8291
|
-
case
|
|
8426
|
+
case import_utils56.AST_NODE_TYPES.ArrayExpression:
|
|
8292
8427
|
for (const element of node.elements) {
|
|
8293
|
-
if (element !== null && element.type !==
|
|
8428
|
+
if (element !== null && element.type !== import_utils56.AST_NODE_TYPES.SpreadElement) checkClassNode(element);
|
|
8294
8429
|
}
|
|
8295
8430
|
break;
|
|
8296
|
-
case
|
|
8431
|
+
case import_utils56.AST_NODE_TYPES.ObjectExpression:
|
|
8297
8432
|
for (const property of node.properties) {
|
|
8298
|
-
if (property.type ===
|
|
8433
|
+
if (property.type === import_utils56.AST_NODE_TYPES.Property) checkClassNode(property.value);
|
|
8299
8434
|
}
|
|
8300
8435
|
break;
|
|
8301
|
-
case
|
|
8436
|
+
case import_utils56.AST_NODE_TYPES.ConditionalExpression:
|
|
8302
8437
|
checkClassNode(node.consequent);
|
|
8303
8438
|
checkClassNode(node.alternate);
|
|
8304
8439
|
break;
|
|
8305
|
-
case
|
|
8440
|
+
case import_utils56.AST_NODE_TYPES.LogicalExpression:
|
|
8306
8441
|
checkClassNode(node.right);
|
|
8307
8442
|
break;
|
|
8308
8443
|
default:
|
|
@@ -8310,32 +8445,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8310
8445
|
}
|
|
8311
8446
|
};
|
|
8312
8447
|
const checkColorValueNode = (node) => {
|
|
8313
|
-
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)) {
|
|
8314
8449
|
report(node, "inlineColor", { value: node.value });
|
|
8315
8450
|
}
|
|
8316
8451
|
};
|
|
8317
8452
|
return {
|
|
8318
8453
|
"JSXAttribute[name.name='className']"(node) {
|
|
8319
8454
|
if (node.value === null) return;
|
|
8320
|
-
if (node.value.type ===
|
|
8321
|
-
else if (node.value.type ===
|
|
8322
|
-
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) {
|
|
8323
8458
|
checkClassNode(node.value.expression);
|
|
8324
8459
|
}
|
|
8325
8460
|
}
|
|
8326
8461
|
},
|
|
8327
8462
|
CallExpression(node) {
|
|
8328
|
-
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)) {
|
|
8329
8464
|
importsEmailOrPdfRenderer = true;
|
|
8330
8465
|
}
|
|
8331
|
-
if (node.callee.type ===
|
|
8466
|
+
if (node.callee.type === import_utils56.AST_NODE_TYPES.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8332
8467
|
for (const arg of node.arguments) {
|
|
8333
|
-
if (arg.type !==
|
|
8468
|
+
if (arg.type !== import_utils56.AST_NODE_TYPES.SpreadElement) checkClassNode(arg);
|
|
8334
8469
|
}
|
|
8335
8470
|
}
|
|
8336
8471
|
},
|
|
8337
8472
|
VariableDeclarator(node) {
|
|
8338
|
-
if (node.id.type ===
|
|
8473
|
+
if (node.id.type === import_utils56.AST_NODE_TYPES.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8339
8474
|
checkClassNode(node.init);
|
|
8340
8475
|
}
|
|
8341
8476
|
},
|
|
@@ -8345,9 +8480,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8345
8480
|
},
|
|
8346
8481
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8347
8482
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8348
|
-
if (node.value?.type !==
|
|
8483
|
+
if (node.value?.type !== import_utils56.AST_NODE_TYPES.Literal) return;
|
|
8349
8484
|
const owner = node.parent.name;
|
|
8350
|
-
if (owner.type ===
|
|
8485
|
+
if (owner.type === import_utils56.AST_NODE_TYPES.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8351
8486
|
return;
|
|
8352
8487
|
}
|
|
8353
8488
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8361,7 +8496,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8361
8496
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8362
8497
|
},
|
|
8363
8498
|
ImportExpression(node) {
|
|
8364
|
-
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)) {
|
|
8365
8500
|
importsEmailOrPdfRenderer = true;
|
|
8366
8501
|
}
|
|
8367
8502
|
},
|
|
@@ -8374,7 +8509,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8374
8509
|
});
|
|
8375
8510
|
|
|
8376
8511
|
// src/rules/prefer-server-actions.ts
|
|
8377
|
-
var
|
|
8512
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
8378
8513
|
var MUTATION_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
8379
8514
|
var AXIOS_MUTATION_METHODS = /* @__PURE__ */ new Set(["post", "put", "delete", "patch"]);
|
|
8380
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\/)/;
|
|
@@ -8565,7 +8700,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8565
8700
|
});
|
|
8566
8701
|
|
|
8567
8702
|
// src/rules/prefer-string-literal-union.ts
|
|
8568
|
-
var
|
|
8703
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
8569
8704
|
var ts2 = __toESM(require("typescript"), 1);
|
|
8570
8705
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
8571
8706
|
"status",
|
|
@@ -8608,19 +8743,19 @@ function isChoiceLikeName(name) {
|
|
|
8608
8743
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8609
8744
|
}
|
|
8610
8745
|
function keyName(key) {
|
|
8611
|
-
if (key.type ===
|
|
8746
|
+
if (key.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8612
8747
|
return key.name;
|
|
8613
8748
|
}
|
|
8614
|
-
if (key.type ===
|
|
8749
|
+
if (key.type === import_utils58.AST_NODE_TYPES.Literal && typeof key.value === "string") {
|
|
8615
8750
|
return key.value;
|
|
8616
8751
|
}
|
|
8617
8752
|
return null;
|
|
8618
8753
|
}
|
|
8619
8754
|
function isStringLiteralMember(t) {
|
|
8620
|
-
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";
|
|
8621
8756
|
}
|
|
8622
8757
|
function isStringLiteralUnion(node) {
|
|
8623
|
-
if (node?.type !==
|
|
8758
|
+
if (node?.type !== import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
8624
8759
|
return false;
|
|
8625
8760
|
}
|
|
8626
8761
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8649,12 +8784,12 @@ function bindingSourceExpression(decl) {
|
|
|
8649
8784
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8650
8785
|
}
|
|
8651
8786
|
function refKey(node) {
|
|
8652
|
-
if (node.type ===
|
|
8787
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8653
8788
|
return node.name;
|
|
8654
8789
|
}
|
|
8655
|
-
if (node.type ===
|
|
8790
|
+
if (node.type === import_utils58.AST_NODE_TYPES.MemberExpression && !node.computed) {
|
|
8656
8791
|
const inner = refKey(node.object);
|
|
8657
|
-
if (inner === null || node.property.type !==
|
|
8792
|
+
if (inner === null || node.property.type !== import_utils58.AST_NODE_TYPES.Identifier) {
|
|
8658
8793
|
return null;
|
|
8659
8794
|
}
|
|
8660
8795
|
return `${inner}.${node.property.name}`;
|
|
@@ -8662,7 +8797,7 @@ function refKey(node) {
|
|
|
8662
8797
|
return null;
|
|
8663
8798
|
}
|
|
8664
8799
|
function strLiteral(node) {
|
|
8665
|
-
if (node.type ===
|
|
8800
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
8666
8801
|
return node.value;
|
|
8667
8802
|
}
|
|
8668
8803
|
return null;
|
|
@@ -8703,7 +8838,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8703
8838
|
);
|
|
8704
8839
|
let services;
|
|
8705
8840
|
try {
|
|
8706
|
-
services =
|
|
8841
|
+
services = import_utils58.ESLintUtils.getParserServices(context);
|
|
8707
8842
|
} catch {
|
|
8708
8843
|
services = null;
|
|
8709
8844
|
}
|
|
@@ -8815,7 +8950,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8815
8950
|
containersWithUnion.add(container);
|
|
8816
8951
|
return;
|
|
8817
8952
|
}
|
|
8818
|
-
if (typeNode?.type !==
|
|
8953
|
+
if (typeNode?.type !== import_utils58.AST_NODE_TYPES.TSStringKeyword) {
|
|
8819
8954
|
return;
|
|
8820
8955
|
}
|
|
8821
8956
|
const name = keyName(key);
|
|
@@ -8903,10 +9038,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8903
9038
|
}
|
|
8904
9039
|
};
|
|
8905
9040
|
function refKeyText(node) {
|
|
8906
|
-
if (node.type ===
|
|
9041
|
+
if (node.type === import_utils58.AST_NODE_TYPES.BinaryExpression) {
|
|
8907
9042
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8908
9043
|
}
|
|
8909
|
-
if (node.type ===
|
|
9044
|
+
if (node.type === import_utils58.AST_NODE_TYPES.SwitchStatement) {
|
|
8910
9045
|
return refKey(node.discriminant) ?? "value";
|
|
8911
9046
|
}
|
|
8912
9047
|
return "value";
|
|
@@ -8915,7 +9050,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8915
9050
|
});
|
|
8916
9051
|
|
|
8917
9052
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8918
|
-
var
|
|
9053
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
8919
9054
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8920
9055
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8921
9056
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8924,11 +9059,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8924
9059
|
var MIN_RUN_LENGTH = 2;
|
|
8925
9060
|
function literalText(node, getText) {
|
|
8926
9061
|
switch (node.type) {
|
|
8927
|
-
case
|
|
9062
|
+
case import_utils59.AST_NODE_TYPES.Literal:
|
|
8928
9063
|
return "regex" in node ? null : getText(node);
|
|
8929
|
-
case
|
|
9064
|
+
case import_utils59.AST_NODE_TYPES.TemplateLiteral:
|
|
8930
9065
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8931
|
-
case
|
|
9066
|
+
case import_utils59.AST_NODE_TYPES.UnaryExpression:
|
|
8932
9067
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8933
9068
|
default:
|
|
8934
9069
|
return null;
|
|
@@ -8936,15 +9071,15 @@ function literalText(node, getText) {
|
|
|
8936
9071
|
}
|
|
8937
9072
|
function isPureReceiver(node) {
|
|
8938
9073
|
switch (node.type) {
|
|
8939
|
-
case
|
|
8940
|
-
case
|
|
9074
|
+
case import_utils59.AST_NODE_TYPES.Identifier:
|
|
9075
|
+
case import_utils59.AST_NODE_TYPES.ThisExpression:
|
|
8941
9076
|
return true;
|
|
8942
|
-
case
|
|
9077
|
+
case import_utils59.AST_NODE_TYPES.MemberExpression:
|
|
8943
9078
|
if (node.optional) {
|
|
8944
9079
|
return false;
|
|
8945
9080
|
}
|
|
8946
9081
|
if (node.computed) {
|
|
8947
|
-
return node.property.type ===
|
|
9082
|
+
return node.property.type === import_utils59.AST_NODE_TYPES.Literal && isPureReceiver(node.object);
|
|
8948
9083
|
}
|
|
8949
9084
|
return isPureReceiver(node.object);
|
|
8950
9085
|
default:
|
|
@@ -8952,7 +9087,7 @@ function isPureReceiver(node) {
|
|
|
8952
9087
|
}
|
|
8953
9088
|
}
|
|
8954
9089
|
function literalIndex(node) {
|
|
8955
|
-
if (node.type !==
|
|
9090
|
+
if (node.type !== import_utils59.AST_NODE_TYPES.Literal || typeof node.value !== "number") {
|
|
8956
9091
|
return null;
|
|
8957
9092
|
}
|
|
8958
9093
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8978,24 +9113,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8978
9113
|
}
|
|
8979
9114
|
const { sourceCode } = context;
|
|
8980
9115
|
function parseAssertion(statement) {
|
|
8981
|
-
if (statement.type !==
|
|
9116
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExpressionStatement) {
|
|
8982
9117
|
return null;
|
|
8983
9118
|
}
|
|
8984
9119
|
const call = statement.expression;
|
|
8985
|
-
if (call.type !==
|
|
9120
|
+
if (call.type !== import_utils59.AST_NODE_TYPES.CallExpression) {
|
|
8986
9121
|
return null;
|
|
8987
9122
|
}
|
|
8988
9123
|
const callee = call.callee;
|
|
8989
|
-
if (callee.type !==
|
|
9124
|
+
if (callee.type !== import_utils59.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils59.AST_NODE_TYPES.Identifier) {
|
|
8990
9125
|
return null;
|
|
8991
9126
|
}
|
|
8992
9127
|
const matcher = callee.property.name;
|
|
8993
9128
|
const expectCall = callee.object;
|
|
8994
|
-
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) {
|
|
8995
9130
|
return null;
|
|
8996
9131
|
}
|
|
8997
9132
|
const actual = expectCall.arguments[0];
|
|
8998
|
-
if (actual === void 0 || actual.type !==
|
|
9133
|
+
if (actual === void 0 || actual.type !== import_utils59.AST_NODE_TYPES.MemberExpression || actual.optional) {
|
|
8999
9134
|
return null;
|
|
9000
9135
|
}
|
|
9001
9136
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -9009,7 +9144,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9009
9144
|
}
|
|
9010
9145
|
key = { kind: "index", index };
|
|
9011
9146
|
} else {
|
|
9012
|
-
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)) {
|
|
9013
9148
|
return null;
|
|
9014
9149
|
}
|
|
9015
9150
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -9021,7 +9156,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9021
9156
|
return null;
|
|
9022
9157
|
}
|
|
9023
9158
|
const expected = call.arguments[0];
|
|
9024
|
-
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) {
|
|
9025
9160
|
return null;
|
|
9026
9161
|
}
|
|
9027
9162
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -9136,7 +9271,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
9136
9271
|
});
|
|
9137
9272
|
|
|
9138
9273
|
// src/rules/prefer-zod-enum.ts
|
|
9139
|
-
var
|
|
9274
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
9140
9275
|
var prefer_zod_enum_default = createRule({
|
|
9141
9276
|
name: "prefer-zod-enum",
|
|
9142
9277
|
meta: {
|
|
@@ -9156,25 +9291,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
9156
9291
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
9157
9292
|
function enumValues(node) {
|
|
9158
9293
|
const callee = node.callee;
|
|
9159
|
-
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) {
|
|
9160
9295
|
return null;
|
|
9161
9296
|
}
|
|
9162
9297
|
const argument = node.arguments[0];
|
|
9163
|
-
if (argument === void 0 || argument.type !==
|
|
9298
|
+
if (argument === void 0 || argument.type !== import_utils60.AST_NODE_TYPES.ArrayExpression || argument.elements.length === 0) {
|
|
9164
9299
|
return null;
|
|
9165
9300
|
}
|
|
9166
9301
|
const values = [];
|
|
9167
9302
|
let canFix = true;
|
|
9168
9303
|
for (const element of argument.elements) {
|
|
9169
|
-
if (element?.type ===
|
|
9304
|
+
if (element?.type === import_utils60.AST_NODE_TYPES.SpreadElement) {
|
|
9170
9305
|
canFix = false;
|
|
9171
9306
|
continue;
|
|
9172
9307
|
}
|
|
9173
|
-
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") {
|
|
9174
9309
|
return null;
|
|
9175
9310
|
}
|
|
9176
9311
|
const value = element.arguments[0];
|
|
9177
|
-
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") {
|
|
9178
9313
|
canFix = false;
|
|
9179
9314
|
continue;
|
|
9180
9315
|
}
|
|
@@ -9184,11 +9319,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9184
9319
|
}
|
|
9185
9320
|
function buildFix(node, values) {
|
|
9186
9321
|
const argument = node.arguments[0];
|
|
9187
|
-
if (argument === void 0 || argument.type !==
|
|
9322
|
+
if (argument === void 0 || argument.type !== import_utils60.AST_NODE_TYPES.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9188
9323
|
return void 0;
|
|
9189
9324
|
}
|
|
9190
9325
|
const callee = node.callee;
|
|
9191
|
-
if (callee.type !==
|
|
9326
|
+
if (callee.type !== import_utils60.AST_NODE_TYPES.MemberExpression || callee.property.type !== import_utils60.AST_NODE_TYPES.Identifier) {
|
|
9192
9327
|
return void 0;
|
|
9193
9328
|
}
|
|
9194
9329
|
return (fixer) => [
|
|
@@ -9205,7 +9340,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9205
9340
|
return;
|
|
9206
9341
|
}
|
|
9207
9342
|
for (const specifier of node.specifiers) {
|
|
9208
|
-
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") {
|
|
9209
9344
|
zodNamespaces.add(specifier.local.name);
|
|
9210
9345
|
}
|
|
9211
9346
|
}
|
|
@@ -9227,7 +9362,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9227
9362
|
});
|
|
9228
9363
|
|
|
9229
9364
|
// src/rules/prefer-zod-infer.ts
|
|
9230
|
-
var
|
|
9365
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
9231
9366
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9232
9367
|
"describe",
|
|
9233
9368
|
"refine",
|
|
@@ -9264,44 +9399,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9264
9399
|
"Schema"
|
|
9265
9400
|
]);
|
|
9266
9401
|
var LEAF_NODE_TYPES = {
|
|
9267
|
-
string: [
|
|
9268
|
-
email: [
|
|
9269
|
-
url: [
|
|
9270
|
-
uuid: [
|
|
9271
|
-
ulid: [
|
|
9272
|
-
cuid: [
|
|
9273
|
-
cuid2: [
|
|
9274
|
-
nanoid: [
|
|
9275
|
-
iso: [
|
|
9276
|
-
number: [
|
|
9277
|
-
int: [
|
|
9278
|
-
float32: [
|
|
9279
|
-
float64: [
|
|
9280
|
-
boolean: [
|
|
9281
|
-
bigint: [
|
|
9282
|
-
symbol: [
|
|
9283
|
-
any: [
|
|
9284
|
-
unknown: [
|
|
9285
|
-
never: [
|
|
9286
|
-
void: [
|
|
9287
|
-
null: [
|
|
9288
|
-
undefined: [
|
|
9289
|
-
literal: [
|
|
9290
|
-
date: [
|
|
9291
|
-
array: [
|
|
9292
|
-
tuple: [
|
|
9293
|
-
object: [
|
|
9294
|
-
strictObject: [
|
|
9295
|
-
looseObject: [
|
|
9296
|
-
record: [
|
|
9297
|
-
map: [
|
|
9298
|
-
set: [
|
|
9299
|
-
promise: [
|
|
9300
|
-
enum: [
|
|
9301
|
-
nativeEnum: [
|
|
9302
|
-
union: [
|
|
9303
|
-
discriminatedUnion: [
|
|
9304
|
-
intersection: [
|
|
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]
|
|
9305
9440
|
};
|
|
9306
9441
|
function normalizeSchemaName(name) {
|
|
9307
9442
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9310,20 +9445,20 @@ function normalizeTypeName(name) {
|
|
|
9310
9445
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9311
9446
|
}
|
|
9312
9447
|
function unwrapNullish(annotation) {
|
|
9313
|
-
if (annotation.type !==
|
|
9448
|
+
if (annotation.type !== import_utils61.AST_NODE_TYPES.TSUnionType) {
|
|
9314
9449
|
return {
|
|
9315
9450
|
core: annotation,
|
|
9316
|
-
nullable: annotation.type ===
|
|
9451
|
+
nullable: annotation.type === import_utils61.AST_NODE_TYPES.TSNullKeyword
|
|
9317
9452
|
};
|
|
9318
9453
|
}
|
|
9319
9454
|
const rest = [];
|
|
9320
9455
|
let nullable = false;
|
|
9321
9456
|
for (const member of annotation.types) {
|
|
9322
|
-
if (member.type ===
|
|
9457
|
+
if (member.type === import_utils61.AST_NODE_TYPES.TSNullKeyword) {
|
|
9323
9458
|
nullable = true;
|
|
9324
9459
|
continue;
|
|
9325
9460
|
}
|
|
9326
|
-
if (member.type ===
|
|
9461
|
+
if (member.type === import_utils61.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
9327
9462
|
continue;
|
|
9328
9463
|
}
|
|
9329
9464
|
rest.push(member);
|
|
@@ -9388,14 +9523,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9388
9523
|
function zodCallChain(node) {
|
|
9389
9524
|
const chain = [];
|
|
9390
9525
|
let current = node;
|
|
9391
|
-
while (current.type ===
|
|
9526
|
+
while (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9392
9527
|
const callee = current.callee;
|
|
9393
|
-
if (callee.type !==
|
|
9528
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9394
9529
|
return null;
|
|
9395
9530
|
}
|
|
9396
9531
|
chain.push(current);
|
|
9397
9532
|
const receiver = callee.object;
|
|
9398
|
-
if (receiver.type ===
|
|
9533
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9399
9534
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9400
9535
|
}
|
|
9401
9536
|
current = receiver;
|
|
@@ -9404,19 +9539,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9404
9539
|
}
|
|
9405
9540
|
function methodName(call) {
|
|
9406
9541
|
const callee = call.callee;
|
|
9407
|
-
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 : "";
|
|
9408
9543
|
}
|
|
9409
9544
|
function schemaField(node) {
|
|
9410
9545
|
const modifiers = [];
|
|
9411
9546
|
let current = node;
|
|
9412
9547
|
let leaf = null;
|
|
9413
|
-
while (current.type ===
|
|
9548
|
+
while (current.type === import_utils61.AST_NODE_TYPES.CallExpression) {
|
|
9414
9549
|
const callee = current.callee;
|
|
9415
|
-
if (callee.type !==
|
|
9550
|
+
if (callee.type !== import_utils61.AST_NODE_TYPES.MemberExpression || callee.computed || callee.property.type !== import_utils61.AST_NODE_TYPES.Identifier) {
|
|
9416
9551
|
break;
|
|
9417
9552
|
}
|
|
9418
9553
|
const receiver = callee.object;
|
|
9419
|
-
if (receiver.type ===
|
|
9554
|
+
if (receiver.type === import_utils61.AST_NODE_TYPES.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9420
9555
|
leaf = callee.property.name;
|
|
9421
9556
|
break;
|
|
9422
9557
|
}
|
|
@@ -9447,16 +9582,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9447
9582
|
return null;
|
|
9448
9583
|
}
|
|
9449
9584
|
const shape = base.arguments[0];
|
|
9450
|
-
if (shape === void 0 || shape.type !==
|
|
9585
|
+
if (shape === void 0 || shape.type !== import_utils61.AST_NODE_TYPES.ObjectExpression) {
|
|
9451
9586
|
return null;
|
|
9452
9587
|
}
|
|
9453
9588
|
const fields = /* @__PURE__ */ new Map();
|
|
9454
9589
|
for (const property of shape.properties) {
|
|
9455
|
-
if (property.type !==
|
|
9590
|
+
if (property.type !== import_utils61.AST_NODE_TYPES.Property || property.computed) {
|
|
9456
9591
|
return null;
|
|
9457
9592
|
}
|
|
9458
9593
|
const { key } = property;
|
|
9459
|
-
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;
|
|
9460
9595
|
if (name === null) {
|
|
9461
9596
|
return null;
|
|
9462
9597
|
}
|
|
@@ -9467,11 +9602,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9467
9602
|
function typeMembers(members) {
|
|
9468
9603
|
const result = /* @__PURE__ */ new Map();
|
|
9469
9604
|
for (const member of members) {
|
|
9470
|
-
if (member.type !==
|
|
9605
|
+
if (member.type !== import_utils61.AST_NODE_TYPES.TSPropertySignature || member.computed) {
|
|
9471
9606
|
return null;
|
|
9472
9607
|
}
|
|
9473
9608
|
const { key } = member;
|
|
9474
|
-
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;
|
|
9475
9610
|
if (name === null) {
|
|
9476
9611
|
return null;
|
|
9477
9612
|
}
|
|
@@ -9485,8 +9620,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9485
9620
|
return result.size === 0 ? null : result;
|
|
9486
9621
|
}
|
|
9487
9622
|
function collectConstrainedNames(node) {
|
|
9488
|
-
if (node.type ===
|
|
9489
|
-
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) {
|
|
9490
9625
|
constrainedTypeNames.add(node.typeName.name);
|
|
9491
9626
|
}
|
|
9492
9627
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9494,11 +9629,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9494
9629
|
}
|
|
9495
9630
|
return;
|
|
9496
9631
|
}
|
|
9497
|
-
if (node.type ===
|
|
9632
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSArrayType) {
|
|
9498
9633
|
collectConstrainedNames(node.elementType);
|
|
9499
9634
|
return;
|
|
9500
9635
|
}
|
|
9501
|
-
if (node.type ===
|
|
9636
|
+
if (node.type === import_utils61.AST_NODE_TYPES.TSUnionType || node.type === import_utils61.AST_NODE_TYPES.TSIntersectionType) {
|
|
9502
9637
|
for (const member of node.types) {
|
|
9503
9638
|
collectConstrainedNames(member);
|
|
9504
9639
|
}
|
|
@@ -9542,13 +9677,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9542
9677
|
return;
|
|
9543
9678
|
}
|
|
9544
9679
|
for (const specifier of node.specifiers) {
|
|
9545
|
-
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") {
|
|
9546
9681
|
zodNamespaces.add(specifier.local.name);
|
|
9547
9682
|
}
|
|
9548
9683
|
}
|
|
9549
9684
|
},
|
|
9550
9685
|
VariableDeclarator(node) {
|
|
9551
|
-
if (node.id.type !==
|
|
9686
|
+
if (node.id.type !== import_utils61.AST_NODE_TYPES.Identifier || node.init == null) {
|
|
9552
9687
|
return;
|
|
9553
9688
|
}
|
|
9554
9689
|
const fields = schemaFields(node.init);
|
|
@@ -9558,14 +9693,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9558
9693
|
},
|
|
9559
9694
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9560
9695
|
"MemberExpression[computed=false]"(node) {
|
|
9561
|
-
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)) {
|
|
9562
9697
|
reshapedSchemaNames.add(node.object.name);
|
|
9563
9698
|
}
|
|
9564
9699
|
},
|
|
9565
9700
|
/** Records every type argument carried by a Zod constraint. */
|
|
9566
9701
|
TSTypeReference(node) {
|
|
9567
9702
|
const { typeName } = node;
|
|
9568
|
-
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;
|
|
9569
9704
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9570
9705
|
return;
|
|
9571
9706
|
}
|
|
@@ -9583,7 +9718,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9583
9718
|
}
|
|
9584
9719
|
},
|
|
9585
9720
|
TSTypeAliasDeclaration(node) {
|
|
9586
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9721
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9587
9722
|
return;
|
|
9588
9723
|
}
|
|
9589
9724
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9628,10 +9763,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9628
9763
|
});
|
|
9629
9764
|
|
|
9630
9765
|
// src/rules/require-assert-never.ts
|
|
9631
|
-
var
|
|
9766
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
9632
9767
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9633
|
-
if (statement.type ===
|
|
9634
|
-
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) {
|
|
9635
9770
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9636
9771
|
}
|
|
9637
9772
|
return true;
|
|
@@ -9647,7 +9782,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9647
9782
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9648
9783
|
}
|
|
9649
9784
|
const only = defaultCase.consequent[0];
|
|
9650
|
-
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) {
|
|
9651
9786
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9652
9787
|
}
|
|
9653
9788
|
return false;
|
|
@@ -9687,7 +9822,7 @@ var require_assert_never_default = createRule({
|
|
|
9687
9822
|
});
|
|
9688
9823
|
|
|
9689
9824
|
// src/rules/require-fetch-timeout.ts
|
|
9690
|
-
var
|
|
9825
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
9691
9826
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9692
9827
|
"globalThis",
|
|
9693
9828
|
"window",
|
|
@@ -9703,14 +9838,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9703
9838
|
return false;
|
|
9704
9839
|
}
|
|
9705
9840
|
function initProvablyLacksSignal(init) {
|
|
9706
|
-
if (init.type !==
|
|
9841
|
+
if (init.type !== import_utils63.AST_NODE_TYPES.ObjectExpression) {
|
|
9707
9842
|
return false;
|
|
9708
9843
|
}
|
|
9709
9844
|
for (const prop of init.properties) {
|
|
9710
|
-
if (prop.type ===
|
|
9845
|
+
if (prop.type === import_utils63.AST_NODE_TYPES.SpreadElement) {
|
|
9711
9846
|
return false;
|
|
9712
9847
|
}
|
|
9713
|
-
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") {
|
|
9714
9849
|
return false;
|
|
9715
9850
|
}
|
|
9716
9851
|
if (prop.computed) {
|
|
@@ -9720,7 +9855,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9720
9855
|
return true;
|
|
9721
9856
|
}
|
|
9722
9857
|
function isStringish(node) {
|
|
9723
|
-
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;
|
|
9724
9859
|
}
|
|
9725
9860
|
var require_fetch_timeout_default = createRule({
|
|
9726
9861
|
name: "require-fetch-timeout",
|
|
@@ -9757,14 +9892,14 @@ var require_fetch_timeout_default = createRule({
|
|
|
9757
9892
|
}
|
|
9758
9893
|
function resolvesToGlobal(identifier) {
|
|
9759
9894
|
const scope = context.sourceCode.getScope(identifier);
|
|
9760
|
-
const variable =
|
|
9895
|
+
const variable = import_utils63.ASTUtils.findVariable(scope, identifier.name);
|
|
9761
9896
|
return variable === null || variable.defs.length === 0;
|
|
9762
9897
|
}
|
|
9763
9898
|
function isGlobalFetchCall2(callee) {
|
|
9764
|
-
if (callee.type ===
|
|
9899
|
+
if (callee.type === import_utils63.AST_NODE_TYPES.Identifier) {
|
|
9765
9900
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9766
9901
|
}
|
|
9767
|
-
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);
|
|
9768
9903
|
}
|
|
9769
9904
|
return {
|
|
9770
9905
|
CallExpression(node) {
|
|
@@ -9784,7 +9919,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9784
9919
|
});
|
|
9785
9920
|
|
|
9786
9921
|
// src/rules/require-interface-for-injected-service.ts
|
|
9787
|
-
var
|
|
9922
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
9788
9923
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9789
9924
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9790
9925
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9792,20 +9927,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9792
9927
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9793
9928
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9794
9929
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9795
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9796
|
-
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}` : "";
|
|
9797
9932
|
var readTypeReference = (annotation) => {
|
|
9798
|
-
if (annotation === void 0 || annotation.type !==
|
|
9933
|
+
if (annotation === void 0 || annotation.type !== import_utils64.AST_NODE_TYPES.TSTypeReference) return null;
|
|
9799
9934
|
const { typeName } = annotation;
|
|
9800
|
-
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;
|
|
9801
9936
|
if (rightmost === null) return null;
|
|
9802
9937
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9803
9938
|
};
|
|
9804
9939
|
var namedParameterCollaborator = (annotated) => {
|
|
9805
9940
|
let target = annotated;
|
|
9806
|
-
if (target.type ===
|
|
9807
|
-
if (target.type ===
|
|
9808
|
-
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;
|
|
9809
9944
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9810
9945
|
if (reference === null) return null;
|
|
9811
9946
|
return { name: target.name, ...reference };
|
|
@@ -9813,8 +9948,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9813
9948
|
var propertySignatureTypes = (members) => {
|
|
9814
9949
|
const types = /* @__PURE__ */ new Map();
|
|
9815
9950
|
for (const member of members) {
|
|
9816
|
-
if (member.type !==
|
|
9817
|
-
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;
|
|
9818
9953
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9819
9954
|
if (reference === null) continue;
|
|
9820
9955
|
types.set(member.key.name, reference);
|
|
@@ -9825,18 +9960,18 @@ var fileTypeIndex = (program) => {
|
|
|
9825
9960
|
const objects = /* @__PURE__ */ new Map();
|
|
9826
9961
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9827
9962
|
for (const statement of program.body) {
|
|
9828
|
-
const declaration = statement.type ===
|
|
9829
|
-
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) {
|
|
9830
9965
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9831
9966
|
continue;
|
|
9832
9967
|
}
|
|
9833
|
-
if (declaration?.type !==
|
|
9968
|
+
if (declaration?.type !== import_utils64.AST_NODE_TYPES.TSTypeAliasDeclaration) continue;
|
|
9834
9969
|
const aliased = declaration.typeAnnotation;
|
|
9835
|
-
if (aliased.type ===
|
|
9970
|
+
if (aliased.type === import_utils64.AST_NODE_TYPES.TSFunctionType || aliased.type === import_utils64.AST_NODE_TYPES.TSConstructorType) {
|
|
9836
9971
|
functionAliases.add(declaration.id.name);
|
|
9837
9972
|
continue;
|
|
9838
9973
|
}
|
|
9839
|
-
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) : [];
|
|
9840
9975
|
if (literals.length === 0) continue;
|
|
9841
9976
|
const merged = /* @__PURE__ */ new Map();
|
|
9842
9977
|
for (const literal of literals) {
|
|
@@ -9849,10 +9984,10 @@ var fileTypeIndex = (program) => {
|
|
|
9849
9984
|
return { objects, functionAliases };
|
|
9850
9985
|
};
|
|
9851
9986
|
var bagMemberTypes = (annotation, declared) => {
|
|
9852
|
-
if (annotation.type ===
|
|
9987
|
+
if (annotation.type === import_utils64.AST_NODE_TYPES.TSTypeLiteral) {
|
|
9853
9988
|
return propertySignatureTypes(annotation.members);
|
|
9854
9989
|
}
|
|
9855
|
-
if (annotation.type !==
|
|
9990
|
+
if (annotation.type !== import_utils64.AST_NODE_TYPES.TSTypeReference || annotation.typeName.type !== import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9856
9991
|
return null;
|
|
9857
9992
|
}
|
|
9858
9993
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9864,11 +9999,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9864
9999
|
if (members === null) return [];
|
|
9865
10000
|
const collaborators = [];
|
|
9866
10001
|
for (const property of pattern.properties) {
|
|
9867
|
-
if (property.type !==
|
|
9868
|
-
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;
|
|
9869
10004
|
const key = property.key.name;
|
|
9870
|
-
const bound = property.value.type ===
|
|
9871
|
-
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;
|
|
9872
10007
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9873
10008
|
const reference = members.get(key);
|
|
9874
10009
|
if (reference === void 0) continue;
|
|
@@ -9878,8 +10013,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9878
10013
|
};
|
|
9879
10014
|
var parameterCollaborators = (parameter, declared) => {
|
|
9880
10015
|
let target = parameter;
|
|
9881
|
-
if (target.type ===
|
|
9882
|
-
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) {
|
|
9883
10018
|
return objectPatternCollaborators(target, declared);
|
|
9884
10019
|
}
|
|
9885
10020
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9898,17 +10033,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9898
10033
|
let constructedFields = 0;
|
|
9899
10034
|
if (body2 !== null && body2 !== void 0) {
|
|
9900
10035
|
for (const statement of body2.body) {
|
|
9901
|
-
if (statement.type !==
|
|
10036
|
+
if (statement.type !== import_utils64.AST_NODE_TYPES.ExpressionStatement) continue;
|
|
9902
10037
|
const expression = statement.expression;
|
|
9903
|
-
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) {
|
|
9904
10039
|
continue;
|
|
9905
10040
|
}
|
|
9906
10041
|
const source = expression.right;
|
|
9907
|
-
if (source.type ===
|
|
10042
|
+
if (source.type === import_utils64.AST_NODE_TYPES.NewExpression) {
|
|
9908
10043
|
constructedFields += 1;
|
|
9909
|
-
} else if (source.type ===
|
|
10044
|
+
} else if (source.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9910
10045
|
storedFrom.add(source.name);
|
|
9911
|
-
} else if (source.type ===
|
|
10046
|
+
} else if (source.type === import_utils64.AST_NODE_TYPES.MemberExpression && source.object.type === import_utils64.AST_NODE_TYPES.Identifier) {
|
|
9912
10047
|
storedFrom.add(source.object.name);
|
|
9913
10048
|
}
|
|
9914
10049
|
}
|
|
@@ -9916,7 +10051,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9916
10051
|
const collaborators = [];
|
|
9917
10052
|
for (const parameter of ctor.value.params) {
|
|
9918
10053
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9919
|
-
const stored = parameter.type ===
|
|
10054
|
+
const stored = parameter.type === import_utils64.AST_NODE_TYPES.TSParameterProperty || storedFrom.has(reference.name);
|
|
9920
10055
|
if (!stored) continue;
|
|
9921
10056
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9922
10057
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9950,19 +10085,19 @@ var subtreeHas = (root, found) => {
|
|
|
9950
10085
|
return hit;
|
|
9951
10086
|
};
|
|
9952
10087
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9953
|
-
if (node.type ===
|
|
10088
|
+
if (node.type === import_utils64.AST_NODE_TYPES.CallExpression) {
|
|
9954
10089
|
const { callee } = node;
|
|
9955
|
-
if (callee.type ===
|
|
9956
|
-
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;
|
|
9957
10092
|
}
|
|
9958
|
-
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);
|
|
9959
10094
|
});
|
|
9960
10095
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9961
10096
|
var fileInterfaceNames = (program) => {
|
|
9962
10097
|
const names = [];
|
|
9963
10098
|
for (const statement of program.body) {
|
|
9964
|
-
const declaration = statement.type ===
|
|
9965
|
-
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);
|
|
9966
10101
|
}
|
|
9967
10102
|
return names;
|
|
9968
10103
|
};
|
|
@@ -9980,11 +10115,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9980
10115
|
var publicMethodNames = (body2) => {
|
|
9981
10116
|
const names = [];
|
|
9982
10117
|
for (const member of body2.body) {
|
|
9983
|
-
if (member.type !==
|
|
10118
|
+
if (member.type !== import_utils64.AST_NODE_TYPES.MethodDefinition) continue;
|
|
9984
10119
|
if (member.kind !== "method" || member.static) continue;
|
|
9985
10120
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9986
|
-
if (member.key.type ===
|
|
9987
|
-
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);
|
|
9988
10123
|
else names.push("\u2026");
|
|
9989
10124
|
}
|
|
9990
10125
|
return names;
|
|
@@ -10017,7 +10152,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10017
10152
|
if (node.implements.length > 0) return;
|
|
10018
10153
|
if (node.decorators.length > 0) return;
|
|
10019
10154
|
const ctor = node.body.body.find(
|
|
10020
|
-
(member) => member.type ===
|
|
10155
|
+
(member) => member.type === import_utils64.AST_NODE_TYPES.MethodDefinition && member.kind === "constructor"
|
|
10021
10156
|
);
|
|
10022
10157
|
if (ctor === void 0) return;
|
|
10023
10158
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -10046,37 +10181,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
10046
10181
|
});
|
|
10047
10182
|
|
|
10048
10183
|
// src/rules/require-static-next-matcher.ts
|
|
10049
|
-
var
|
|
10184
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
10050
10185
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
10051
|
-
function
|
|
10052
|
-
if (node.type ===
|
|
10053
|
-
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);
|
|
10054
10189
|
}
|
|
10055
10190
|
return node;
|
|
10056
10191
|
}
|
|
10057
10192
|
function isStaticValue(node) {
|
|
10058
|
-
const value =
|
|
10059
|
-
if (value.type ===
|
|
10193
|
+
const value = unwrapExpression2(node);
|
|
10194
|
+
if (value.type === import_utils65.AST_NODE_TYPES.Literal) {
|
|
10060
10195
|
return true;
|
|
10061
10196
|
}
|
|
10062
|
-
if (value.type ===
|
|
10197
|
+
if (value.type === import_utils65.AST_NODE_TYPES.TemplateLiteral) {
|
|
10063
10198
|
return value.expressions.length === 0;
|
|
10064
10199
|
}
|
|
10065
|
-
if (value.type ===
|
|
10200
|
+
if (value.type === import_utils65.AST_NODE_TYPES.ArrayExpression) {
|
|
10066
10201
|
return value.elements.every(
|
|
10067
|
-
(element) => element !== null && element.type !==
|
|
10202
|
+
(element) => element !== null && element.type !== import_utils65.AST_NODE_TYPES.SpreadElement && isStaticValue(element)
|
|
10068
10203
|
);
|
|
10069
10204
|
}
|
|
10070
|
-
if (value.type ===
|
|
10205
|
+
if (value.type === import_utils65.AST_NODE_TYPES.ObjectExpression) {
|
|
10071
10206
|
return value.properties.every(
|
|
10072
|
-
(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)
|
|
10073
10208
|
);
|
|
10074
10209
|
}
|
|
10075
10210
|
return false;
|
|
10076
10211
|
}
|
|
10077
10212
|
function propertyName2(property) {
|
|
10078
10213
|
if (property.computed) return null;
|
|
10079
|
-
if (property.key.type ===
|
|
10214
|
+
if (property.key.type === import_utils65.AST_NODE_TYPES.Identifier) return property.key.name;
|
|
10080
10215
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
10081
10216
|
}
|
|
10082
10217
|
var require_static_next_matcher_default = createRule({
|
|
@@ -10098,19 +10233,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
10098
10233
|
}
|
|
10099
10234
|
return {
|
|
10100
10235
|
ExportNamedDeclaration(node) {
|
|
10101
|
-
if (node.declaration?.type !==
|
|
10236
|
+
if (node.declaration?.type !== import_utils65.AST_NODE_TYPES.VariableDeclaration) {
|
|
10102
10237
|
return;
|
|
10103
10238
|
}
|
|
10104
10239
|
for (const declaration of node.declaration.declarations) {
|
|
10105
|
-
if (declaration.id.type !==
|
|
10240
|
+
if (declaration.id.type !== import_utils65.AST_NODE_TYPES.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
10106
10241
|
continue;
|
|
10107
10242
|
}
|
|
10108
|
-
const config =
|
|
10109
|
-
if (config.type !==
|
|
10243
|
+
const config = unwrapExpression2(declaration.init);
|
|
10244
|
+
if (config.type !== import_utils65.AST_NODE_TYPES.ObjectExpression) {
|
|
10110
10245
|
continue;
|
|
10111
10246
|
}
|
|
10112
10247
|
for (const property of config.properties) {
|
|
10113
|
-
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) {
|
|
10114
10249
|
continue;
|
|
10115
10250
|
}
|
|
10116
10251
|
if (!isStaticValue(property.value)) {
|
|
@@ -10124,18 +10259,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
10124
10259
|
});
|
|
10125
10260
|
|
|
10126
10261
|
// src/rules/require-zod-form-validation.ts
|
|
10127
|
-
var
|
|
10262
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
10128
10263
|
var looksLikeZodSchema = (node) => {
|
|
10129
10264
|
let current = node;
|
|
10130
10265
|
while (true) {
|
|
10131
|
-
if (current.type ===
|
|
10266
|
+
if (current.type === import_utils66.AST_NODE_TYPES.Identifier) {
|
|
10132
10267
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
10133
10268
|
}
|
|
10134
|
-
if (current.type ===
|
|
10269
|
+
if (current.type === import_utils66.AST_NODE_TYPES.CallExpression) {
|
|
10135
10270
|
current = current.callee;
|
|
10136
10271
|
continue;
|
|
10137
10272
|
}
|
|
10138
|
-
if (current.type ===
|
|
10273
|
+
if (current.type === import_utils66.AST_NODE_TYPES.MemberExpression) {
|
|
10139
10274
|
current = current.object;
|
|
10140
10275
|
continue;
|
|
10141
10276
|
}
|
|
@@ -10143,23 +10278,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
10143
10278
|
}
|
|
10144
10279
|
};
|
|
10145
10280
|
var isZodParseCall = (node) => {
|
|
10146
|
-
if (node.type !==
|
|
10281
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.CallExpression) return false;
|
|
10147
10282
|
const callee = node.callee;
|
|
10148
|
-
if (callee.type !==
|
|
10283
|
+
if (callee.type !== import_utils66.AST_NODE_TYPES.MemberExpression) return false;
|
|
10149
10284
|
if (callee.computed) return false;
|
|
10150
|
-
if (callee.property.type !==
|
|
10285
|
+
if (callee.property.type !== import_utils66.AST_NODE_TYPES.Identifier) return false;
|
|
10151
10286
|
const method = callee.property.name;
|
|
10152
10287
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
10153
10288
|
return looksLikeZodSchema(callee.object);
|
|
10154
10289
|
};
|
|
10155
10290
|
var isFormDataMethodCall = (node) => {
|
|
10156
10291
|
let current = node;
|
|
10157
|
-
if (current.type ===
|
|
10292
|
+
if (current.type === import_utils66.AST_NODE_TYPES.AwaitExpression) {
|
|
10158
10293
|
current = current.argument;
|
|
10159
10294
|
}
|
|
10160
|
-
if (current.type !==
|
|
10295
|
+
if (current.type !== import_utils66.AST_NODE_TYPES.CallExpression) return false;
|
|
10161
10296
|
const callee = current.callee;
|
|
10162
|
-
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";
|
|
10163
10298
|
};
|
|
10164
10299
|
var require_zod_form_validation_default = createRule({
|
|
10165
10300
|
name: "require-zod-form-validation",
|
|
@@ -10179,14 +10314,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10179
10314
|
return {};
|
|
10180
10315
|
}
|
|
10181
10316
|
const isFormSourceIdentifier = (node) => {
|
|
10182
|
-
if (node.type !==
|
|
10317
|
+
if (node.type !== import_utils66.AST_NODE_TYPES.Identifier) return false;
|
|
10183
10318
|
if (/formdata/i.test(node.name)) return true;
|
|
10184
10319
|
let scope = context.sourceCode.getScope(node);
|
|
10185
10320
|
while (scope !== null) {
|
|
10186
10321
|
const variable = scope.set.get(node.name);
|
|
10187
10322
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10188
10323
|
const def = variable.defs[0];
|
|
10189
|
-
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) {
|
|
10190
10325
|
return isFormDataMethodCall(def.node.init);
|
|
10191
10326
|
}
|
|
10192
10327
|
return false;
|
|
@@ -10197,8 +10332,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10197
10332
|
};
|
|
10198
10333
|
const isFormDataGetCall = (node) => {
|
|
10199
10334
|
const callee = node.callee;
|
|
10200
|
-
if (callee.type !==
|
|
10201
|
-
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") {
|
|
10202
10337
|
return false;
|
|
10203
10338
|
}
|
|
10204
10339
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10213,11 +10348,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10213
10348
|
};
|
|
10214
10349
|
const isInstanceofNarrowing = (node) => {
|
|
10215
10350
|
const parent = node.parent;
|
|
10216
|
-
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");
|
|
10217
10352
|
};
|
|
10218
10353
|
const boundDeclarator = (node) => {
|
|
10219
10354
|
const parent = node.parent;
|
|
10220
|
-
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) {
|
|
10221
10356
|
return parent;
|
|
10222
10357
|
}
|
|
10223
10358
|
return null;
|
|
@@ -10245,7 +10380,7 @@ var require_zod_form_validation_default = createRule({
|
|
|
10245
10380
|
});
|
|
10246
10381
|
|
|
10247
10382
|
// src/rules/store-insert-requires-on-conflict.ts
|
|
10248
|
-
var
|
|
10383
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
10249
10384
|
var INSERT_WRITE = /\bINSERT\s+(?:OR\s+\w+\s+)?INTO\s+[\w."'`?$:@-]+\s*(?:\([^)]*\)\s*)?(?:VALUES|SELECT|DEFAULT\s+VALUES)\b/i;
|
|
10250
10385
|
var CONFLICT_HANDLED = /\bON\s+CONFLICT\b|\bON\s+DUPLICATE\s+KEY\b|\bINSERT\s+OR\s+(?:IGNORE|REPLACE)\b/i;
|
|
10251
10386
|
var INSERT_GATE = /insert/i;
|
|
@@ -10276,7 +10411,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10276
10411
|
});
|
|
10277
10412
|
|
|
10278
10413
|
// src/rules/zod-naming-convention.ts
|
|
10279
|
-
var
|
|
10414
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
10280
10415
|
var CONVENTIONS = {
|
|
10281
10416
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10282
10417
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10301,15 +10436,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10301
10436
|
"registry",
|
|
10302
10437
|
"implement"
|
|
10303
10438
|
]);
|
|
10304
|
-
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;
|
|
10305
10440
|
var calleeChainStartsWithZ = (node) => {
|
|
10306
10441
|
let current = node;
|
|
10307
|
-
while (current.type ===
|
|
10442
|
+
while (current.type === import_utils68.AST_NODE_TYPES.MemberExpression) {
|
|
10308
10443
|
const receiver = current.object;
|
|
10309
|
-
if (receiver.type ===
|
|
10444
|
+
if (receiver.type === import_utils68.AST_NODE_TYPES.Identifier && receiver.name === "z") {
|
|
10310
10445
|
return true;
|
|
10311
10446
|
}
|
|
10312
|
-
if (receiver.type ===
|
|
10447
|
+
if (receiver.type === import_utils68.AST_NODE_TYPES.CallExpression) {
|
|
10313
10448
|
current = receiver.callee;
|
|
10314
10449
|
continue;
|
|
10315
10450
|
}
|
|
@@ -10354,13 +10489,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10354
10489
|
VariableDeclarator(node) {
|
|
10355
10490
|
const init = node.init;
|
|
10356
10491
|
if (init === null || init === void 0) return;
|
|
10357
|
-
if (init.type !==
|
|
10492
|
+
if (init.type !== import_utils68.AST_NODE_TYPES.CallExpression) return;
|
|
10358
10493
|
const callee = init.callee;
|
|
10359
|
-
if (callee.type !==
|
|
10494
|
+
if (callee.type !== import_utils68.AST_NODE_TYPES.MemberExpression) return;
|
|
10360
10495
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10361
10496
|
const terminal = terminalMethodName(callee);
|
|
10362
10497
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10363
|
-
if (node.id.type !==
|
|
10498
|
+
if (node.id.type !== import_utils68.AST_NODE_TYPES.Identifier) return;
|
|
10364
10499
|
if (test.test(node.id.name)) return;
|
|
10365
10500
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10366
10501
|
context.report({
|
|
@@ -10472,6 +10607,7 @@ var rules = {
|
|
|
10472
10607
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10473
10608
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10474
10609
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10610
|
+
"prefer-immutable-module-constant": prefer_immutable_module_constant_default,
|
|
10475
10611
|
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
10476
10612
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10477
10613
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
@@ -10495,7 +10631,7 @@ var rules = {
|
|
|
10495
10631
|
};
|
|
10496
10632
|
var meta = {
|
|
10497
10633
|
name: "@sarj/eslint-plugin",
|
|
10498
|
-
version: "9.
|
|
10634
|
+
version: "9.13.0"
|
|
10499
10635
|
};
|
|
10500
10636
|
var applicationOnlyRules = [
|
|
10501
10637
|
"no-restricted-library-load",
|
|
@@ -10540,6 +10676,7 @@ var recommendedRules = {
|
|
|
10540
10676
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10541
10677
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10542
10678
|
"@sarj/prefer-input-group-search": "error",
|
|
10679
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10543
10680
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10544
10681
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10545
10682
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10601,6 +10738,7 @@ var strictRules = {
|
|
|
10601
10738
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10602
10739
|
"@sarj/prefer-discriminated-union": "error",
|
|
10603
10740
|
"@sarj/prefer-input-group-search": "error",
|
|
10741
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10604
10742
|
"@sarj/prefer-module-level-constant": "error",
|
|
10605
10743
|
"@sarj/prefer-module-level-schema": "error",
|
|
10606
10744
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10651,4 +10789,3 @@ var index_default = plugin;
|
|
|
10651
10789
|
rules,
|
|
10652
10790
|
strictRules
|
|
10653
10791
|
});
|
|
10654
|
-
//# sourceMappingURL=index.cjs.map
|