@sarj/eslint-plugin 9.11.0 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.cjs +617 -345
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +612 -340
- package/package.json +10 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -641,7 +641,7 @@ var CODE_KEYWORD_RE = /^(import |export |const |let |var |function\b|class |inte
|
|
|
641
641
|
var CODE_TAIL_RE = /[;{}()]\s*$|=>\s*$|,\s*$/;
|
|
642
642
|
var ASSIGN_RE = /^[A-Za-z_$][\w.$[\]]*\s*(?:=(?![=>])|\+=|-=|\*=)\s*\S.*[;)}\]]\s*$/;
|
|
643
643
|
var CALL_RE = /^[A-Za-z_$][\w.$]*\([^)]*\)\s*;?\s*$/;
|
|
644
|
-
var ASSERTION_CODE_RE = /^(?:await\s+)?(?:expect(?:TypeOf)
|
|
644
|
+
var ASSERTION_CODE_RE = /^(?:await\s+)?(?:expect(?:TypeOf)?|assert(?:\.\w+)?)\s*\(/;
|
|
645
645
|
var PSEUDOCODE_RE = /%\w+%|\[opt\]|(?:^|\s)<[A-Za-z]\w*>|…|\.\.\./;
|
|
646
646
|
function stripCommentMarker(line) {
|
|
647
647
|
return line.replace(/^\s*\/{1,2}/, "").replace(/^\s*\*+/, "").trim();
|
|
@@ -6708,8 +6708,276 @@ var prefer_input_group_search_default = createRule({
|
|
|
6708
6708
|
}
|
|
6709
6709
|
});
|
|
6710
6710
|
|
|
6711
|
-
// src/rules/prefer-module-
|
|
6711
|
+
// src/rules/prefer-immutable-module-constant.ts
|
|
6712
6712
|
import { AST_NODE_TYPES as AST_NODE_TYPES35 } from "@typescript-eslint/utils";
|
|
6713
|
+
var CONSTANT_NAME = /^_?[A-Z][A-Z0-9_]*$/;
|
|
6714
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
6715
|
+
"add",
|
|
6716
|
+
"clear",
|
|
6717
|
+
"copyWithin",
|
|
6718
|
+
"delete",
|
|
6719
|
+
"fill",
|
|
6720
|
+
"pop",
|
|
6721
|
+
"push",
|
|
6722
|
+
"reverse",
|
|
6723
|
+
"set",
|
|
6724
|
+
"shift",
|
|
6725
|
+
"sort",
|
|
6726
|
+
"splice",
|
|
6727
|
+
"unshift"
|
|
6728
|
+
]);
|
|
6729
|
+
function isAsConst(node, sourceText) {
|
|
6730
|
+
if (node.type === AST_NODE_TYPES35.TSSatisfiesExpression) {
|
|
6731
|
+
return isAsConst(node.expression, sourceText);
|
|
6732
|
+
}
|
|
6733
|
+
return node.type === AST_NODE_TYPES35.TSAsExpression && sourceText(node.typeAnnotation).trim() === "const";
|
|
6734
|
+
}
|
|
6735
|
+
function unwrapExpression(node) {
|
|
6736
|
+
if (node.type === AST_NODE_TYPES35.TSAsExpression || node.type === AST_NODE_TYPES35.TSSatisfiesExpression || node.type === AST_NODE_TYPES35.TSNonNullExpression) {
|
|
6737
|
+
return unwrapExpression(node.expression);
|
|
6738
|
+
}
|
|
6739
|
+
return node;
|
|
6740
|
+
}
|
|
6741
|
+
function isObjectFreeze(node) {
|
|
6742
|
+
const inner = unwrapExpression(node);
|
|
6743
|
+
return inner.type === AST_NODE_TYPES35.CallExpression && inner.callee.type === AST_NODE_TYPES35.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES35.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES35.Identifier && inner.callee.property.name === "freeze";
|
|
6744
|
+
}
|
|
6745
|
+
function collectionKind(node) {
|
|
6746
|
+
const inner = unwrapExpression(node);
|
|
6747
|
+
if (inner.type === AST_NODE_TYPES35.ArrayExpression || inner.type === AST_NODE_TYPES35.ObjectExpression) {
|
|
6748
|
+
return "literal";
|
|
6749
|
+
}
|
|
6750
|
+
if (inner.type === AST_NODE_TYPES35.NewExpression && inner.callee.type === AST_NODE_TYPES35.Identifier && (inner.callee.name === "Set" || inner.callee.name === "Map")) {
|
|
6751
|
+
return inner.callee.name;
|
|
6752
|
+
}
|
|
6753
|
+
return null;
|
|
6754
|
+
}
|
|
6755
|
+
function isReadonlyType(node, kind) {
|
|
6756
|
+
if (node.type === AST_NODE_TYPES35.TSTypeOperator && node.operator === "readonly") {
|
|
6757
|
+
return true;
|
|
6758
|
+
}
|
|
6759
|
+
if (node.type !== AST_NODE_TYPES35.TSTypeReference || node.typeName.type !== AST_NODE_TYPES35.Identifier) {
|
|
6760
|
+
return false;
|
|
6761
|
+
}
|
|
6762
|
+
if (node.typeName.name === "Readonly") {
|
|
6763
|
+
return true;
|
|
6764
|
+
}
|
|
6765
|
+
return kind === "literal" ? node.typeName.name === "ReadonlyArray" : node.typeName.name === `Readonly${kind}`;
|
|
6766
|
+
}
|
|
6767
|
+
function declaredReadonlyType(node, kind) {
|
|
6768
|
+
const annotation = node.id.type === AST_NODE_TYPES35.Identifier ? node.id.typeAnnotation : void 0;
|
|
6769
|
+
if (annotation !== void 0 && isReadonlyType(annotation.typeAnnotation, kind)) {
|
|
6770
|
+
return true;
|
|
6771
|
+
}
|
|
6772
|
+
return node.init?.type === AST_NODE_TYPES35.TSAsExpression && isReadonlyType(node.init.typeAnnotation, kind);
|
|
6773
|
+
}
|
|
6774
|
+
function referenceMutates(identifier) {
|
|
6775
|
+
let member = identifier.parent;
|
|
6776
|
+
if (member?.type !== AST_NODE_TYPES35.MemberExpression || member.object !== identifier) {
|
|
6777
|
+
return member?.type === AST_NODE_TYPES35.CallExpression && member.arguments[0] === identifier && member.callee.type === AST_NODE_TYPES35.MemberExpression && !member.callee.computed && member.callee.object.type === AST_NODE_TYPES35.Identifier && member.callee.object.name === "Object" && member.callee.property.type === AST_NODE_TYPES35.Identifier && member.callee.property.name === "assign";
|
|
6778
|
+
}
|
|
6779
|
+
while (member.parent.type === AST_NODE_TYPES35.MemberExpression && member.parent.object === member) {
|
|
6780
|
+
member = member.parent;
|
|
6781
|
+
}
|
|
6782
|
+
const parent = member.parent;
|
|
6783
|
+
if (parent?.type === AST_NODE_TYPES35.AssignmentExpression && parent.left === member) {
|
|
6784
|
+
return true;
|
|
6785
|
+
}
|
|
6786
|
+
if (parent?.type === AST_NODE_TYPES35.UpdateExpression && parent.argument === member) {
|
|
6787
|
+
return true;
|
|
6788
|
+
}
|
|
6789
|
+
if (parent?.type === AST_NODE_TYPES35.UnaryExpression && parent.operator === "delete" && parent.argument === member) {
|
|
6790
|
+
return true;
|
|
6791
|
+
}
|
|
6792
|
+
return parent?.type === AST_NODE_TYPES35.CallExpression && parent.callee === member && member.property.type === AST_NODE_TYPES35.Identifier && MUTATING_METHODS.has(member.property.name);
|
|
6793
|
+
}
|
|
6794
|
+
var prefer_immutable_module_constant_default = createRule({
|
|
6795
|
+
name: "prefer-immutable-module-constant",
|
|
6796
|
+
meta: {
|
|
6797
|
+
type: "suggestion",
|
|
6798
|
+
docs: {
|
|
6799
|
+
description: "Require module-level constant collections to expose readonly state."
|
|
6800
|
+
},
|
|
6801
|
+
schema: [],
|
|
6802
|
+
messages: {
|
|
6803
|
+
preferAsConst: "Module constant `{{name}}` is a mutable literal. Add `as const` or use `Object.freeze` so consumers cannot mutate shared state.",
|
|
6804
|
+
preferReadonlyCollection: "Module constant `{{name}}` is a mutable {{kind}}. Expose it as `Readonly{{kind}}` or an immutable collection."
|
|
6805
|
+
}
|
|
6806
|
+
},
|
|
6807
|
+
defaultOptions: [],
|
|
6808
|
+
create(context) {
|
|
6809
|
+
const sourceCode = context.sourceCode;
|
|
6810
|
+
if (isTestFile(context.filename) || isGeneratedFile(context.filename, sourceCode.getText())) {
|
|
6811
|
+
return {};
|
|
6812
|
+
}
|
|
6813
|
+
return {
|
|
6814
|
+
VariableDeclarator(node) {
|
|
6815
|
+
const declaration = node.parent;
|
|
6816
|
+
if (declaration.type !== AST_NODE_TYPES35.VariableDeclaration || declaration.kind !== "const" || node.id.type !== AST_NODE_TYPES35.Identifier || node.init === null || !CONSTANT_NAME.test(node.id.name)) {
|
|
6817
|
+
return;
|
|
6818
|
+
}
|
|
6819
|
+
const container = declaration.parent;
|
|
6820
|
+
if (container.type !== AST_NODE_TYPES35.Program && !(container.type === AST_NODE_TYPES35.ExportNamedDeclaration && container.parent.type === AST_NODE_TYPES35.Program)) {
|
|
6821
|
+
return;
|
|
6822
|
+
}
|
|
6823
|
+
if (isAsConst(node.init, (target) => sourceCode.getText(target)) || isObjectFreeze(node.init)) {
|
|
6824
|
+
return;
|
|
6825
|
+
}
|
|
6826
|
+
const kind = collectionKind(node.init);
|
|
6827
|
+
if (kind === null || declaredReadonlyType(node, kind)) {
|
|
6828
|
+
return;
|
|
6829
|
+
}
|
|
6830
|
+
const variable = sourceCode.getDeclaredVariables(node)[0];
|
|
6831
|
+
if (variable?.references.some(
|
|
6832
|
+
(reference) => reference.identifier.type === AST_NODE_TYPES35.Identifier && referenceMutates(reference.identifier)
|
|
6833
|
+
) === true) {
|
|
6834
|
+
return;
|
|
6835
|
+
}
|
|
6836
|
+
context.report({
|
|
6837
|
+
node: node.id,
|
|
6838
|
+
messageId: kind === "literal" ? "preferAsConst" : "preferReadonlyCollection",
|
|
6839
|
+
data: { name: node.id.name, kind }
|
|
6840
|
+
});
|
|
6841
|
+
}
|
|
6842
|
+
};
|
|
6843
|
+
}
|
|
6844
|
+
});
|
|
6845
|
+
|
|
6846
|
+
// src/rules/prefer-shadcn-primitives.ts
|
|
6847
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES36 } from "@typescript-eslint/utils";
|
|
6848
|
+
var SHADCN_PRIMITIVES = {
|
|
6849
|
+
button: "Button",
|
|
6850
|
+
dialog: "Dialog or AlertDialog family",
|
|
6851
|
+
input: "Input",
|
|
6852
|
+
label: "Label",
|
|
6853
|
+
progress: "Progress",
|
|
6854
|
+
select: "Select family",
|
|
6855
|
+
table: "Table family",
|
|
6856
|
+
textarea: "Textarea"
|
|
6857
|
+
};
|
|
6858
|
+
var LABELABLE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
6859
|
+
"button",
|
|
6860
|
+
"input",
|
|
6861
|
+
"meter",
|
|
6862
|
+
"output",
|
|
6863
|
+
"progress",
|
|
6864
|
+
"select",
|
|
6865
|
+
"textarea"
|
|
6866
|
+
]);
|
|
6867
|
+
function rawElementName(node) {
|
|
6868
|
+
if (node.name.type !== AST_NODE_TYPES36.JSXIdentifier) return null;
|
|
6869
|
+
const name = node.name.name;
|
|
6870
|
+
return Object.hasOwn(SHADCN_PRIMITIVES, name) ? name : null;
|
|
6871
|
+
}
|
|
6872
|
+
function staticExpressionString(expression) {
|
|
6873
|
+
if (expression.type === AST_NODE_TYPES36.Literal) {
|
|
6874
|
+
return typeof expression.value === "string" ? expression.value : null;
|
|
6875
|
+
}
|
|
6876
|
+
if (expression.type === AST_NODE_TYPES36.TemplateLiteral) {
|
|
6877
|
+
let value = expression.quasis[0]?.value.cooked ?? "";
|
|
6878
|
+
for (const [index, substitution] of expression.expressions.entries()) {
|
|
6879
|
+
const staticSubstitution = staticExpressionString(substitution);
|
|
6880
|
+
if (staticSubstitution === null) return null;
|
|
6881
|
+
value += staticSubstitution;
|
|
6882
|
+
value += expression.quasis[index + 1]?.value.cooked ?? "";
|
|
6883
|
+
}
|
|
6884
|
+
return value;
|
|
6885
|
+
}
|
|
6886
|
+
if (expression.type === AST_NODE_TYPES36.TSAsExpression || expression.type === AST_NODE_TYPES36.TSNonNullExpression || expression.type === AST_NODE_TYPES36.TSSatisfiesExpression || expression.type === AST_NODE_TYPES36.TSTypeAssertion) {
|
|
6887
|
+
return staticExpressionString(expression.expression);
|
|
6888
|
+
}
|
|
6889
|
+
return null;
|
|
6890
|
+
}
|
|
6891
|
+
function staticString(value) {
|
|
6892
|
+
if (value?.type === AST_NODE_TYPES36.Literal) {
|
|
6893
|
+
return typeof value.value === "string" ? value.value : null;
|
|
6894
|
+
}
|
|
6895
|
+
if (value?.type !== AST_NODE_TYPES36.JSXExpressionContainer) return null;
|
|
6896
|
+
return staticExpressionString(value.expression);
|
|
6897
|
+
}
|
|
6898
|
+
function effectiveAttribute(node, attributeName) {
|
|
6899
|
+
for (const attribute of node.attributes.toReversed()) {
|
|
6900
|
+
if (attribute.type === AST_NODE_TYPES36.JSXSpreadAttribute) {
|
|
6901
|
+
return { kind: "unknown" };
|
|
6902
|
+
}
|
|
6903
|
+
if (attribute.name.type !== AST_NODE_TYPES36.JSXIdentifier || attribute.name.name !== attributeName) {
|
|
6904
|
+
continue;
|
|
6905
|
+
}
|
|
6906
|
+
const value = staticString(attribute.value);
|
|
6907
|
+
return value === null ? { kind: "unknown" } : { kind: "known", value };
|
|
6908
|
+
}
|
|
6909
|
+
return { kind: "missing" };
|
|
6910
|
+
}
|
|
6911
|
+
function isLabelableElement(node) {
|
|
6912
|
+
if (node.openingElement.name.type !== AST_NODE_TYPES36.JSXIdentifier) {
|
|
6913
|
+
return false;
|
|
6914
|
+
}
|
|
6915
|
+
const name = node.openingElement.name.name;
|
|
6916
|
+
if (!LABELABLE_ELEMENTS.has(name)) return false;
|
|
6917
|
+
if (name !== "input") return true;
|
|
6918
|
+
const typeAttribute = effectiveAttribute(node.openingElement, "type");
|
|
6919
|
+
if (typeAttribute.kind === "unknown") return false;
|
|
6920
|
+
return !(typeAttribute.kind === "known" && typeAttribute.value.toLowerCase() === "hidden");
|
|
6921
|
+
}
|
|
6922
|
+
function containsLabelableElement(node) {
|
|
6923
|
+
return node.children.some((child) => {
|
|
6924
|
+
if (child.type === AST_NODE_TYPES36.JSXElement) {
|
|
6925
|
+
return isLabelableElement(child) || containsLabelableElement(child);
|
|
6926
|
+
}
|
|
6927
|
+
if (child.type === AST_NODE_TYPES36.JSXFragment) {
|
|
6928
|
+
return containsLabelableElement(child);
|
|
6929
|
+
}
|
|
6930
|
+
return false;
|
|
6931
|
+
});
|
|
6932
|
+
}
|
|
6933
|
+
function isStaticallyAssociatedLabel(node) {
|
|
6934
|
+
const htmlFor = effectiveAttribute(node, "htmlFor");
|
|
6935
|
+
if (htmlFor.kind === "known" && htmlFor.value.trim().length > 0) return true;
|
|
6936
|
+
return node.parent.type === AST_NODE_TYPES36.JSXElement && containsLabelableElement(node.parent);
|
|
6937
|
+
}
|
|
6938
|
+
function replacementFor(node, element) {
|
|
6939
|
+
if (element !== "input") return SHADCN_PRIMITIVES[element];
|
|
6940
|
+
const typeAttribute = effectiveAttribute(node, "type");
|
|
6941
|
+
if (typeAttribute.kind === "unknown") return null;
|
|
6942
|
+
const inputType = typeAttribute.kind === "known" ? typeAttribute.value.toLowerCase() : "text";
|
|
6943
|
+
if (inputType === "hidden" || inputType === "file") return null;
|
|
6944
|
+
if (inputType === "checkbox") return "Checkbox";
|
|
6945
|
+
if (inputType === "radio") return "RadioGroup family";
|
|
6946
|
+
return "Input";
|
|
6947
|
+
}
|
|
6948
|
+
var prefer_shadcn_primitives_default = createRule({
|
|
6949
|
+
name: "prefer-shadcn-primitives",
|
|
6950
|
+
meta: {
|
|
6951
|
+
type: "suggestion",
|
|
6952
|
+
docs: {
|
|
6953
|
+
description: "Require visible raw JSX controls to use the corresponding shared shadcn primitive."
|
|
6954
|
+
},
|
|
6955
|
+
schema: [],
|
|
6956
|
+
messages: {
|
|
6957
|
+
preferShadcnPrimitive: "Use the shared {{ replacement }} shadcn primitive instead of raw <{{ element }}> markup."
|
|
6958
|
+
}
|
|
6959
|
+
},
|
|
6960
|
+
defaultOptions: [],
|
|
6961
|
+
create(context) {
|
|
6962
|
+
return {
|
|
6963
|
+
JSXOpeningElement(node) {
|
|
6964
|
+
const element = rawElementName(node);
|
|
6965
|
+
if (element === null) return;
|
|
6966
|
+
if (element === "label" && !isStaticallyAssociatedLabel(node)) return;
|
|
6967
|
+
const replacement = replacementFor(node, element);
|
|
6968
|
+
if (replacement === null) return;
|
|
6969
|
+
context.report({
|
|
6970
|
+
node,
|
|
6971
|
+
messageId: "preferShadcnPrimitive",
|
|
6972
|
+
data: { element, replacement }
|
|
6973
|
+
});
|
|
6974
|
+
}
|
|
6975
|
+
};
|
|
6976
|
+
}
|
|
6977
|
+
});
|
|
6978
|
+
|
|
6979
|
+
// src/rules/prefer-module-level-constant.ts
|
|
6980
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES37 } from "@typescript-eslint/utils";
|
|
6713
6981
|
var DEFAULT_MIN_ELEMENTS = 3;
|
|
6714
6982
|
var MAX_LITERAL_DEPTH = 4;
|
|
6715
6983
|
var IGNORE_PATTERNS2 = [
|
|
@@ -6718,7 +6986,7 @@ var IGNORE_PATTERNS2 = [
|
|
|
6718
6986
|
/\.generated\.tsx?$/,
|
|
6719
6987
|
/\.d\.ts$/
|
|
6720
6988
|
];
|
|
6721
|
-
var
|
|
6989
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set([
|
|
6722
6990
|
// Array
|
|
6723
6991
|
"push",
|
|
6724
6992
|
"pop",
|
|
@@ -6738,9 +7006,9 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
|
6738
7006
|
"assign"
|
|
6739
7007
|
]);
|
|
6740
7008
|
var FUNCTION_TYPES5 = /* @__PURE__ */ new Set([
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
7009
|
+
AST_NODE_TYPES37.FunctionDeclaration,
|
|
7010
|
+
AST_NODE_TYPES37.FunctionExpression,
|
|
7011
|
+
AST_NODE_TYPES37.ArrowFunctionExpression
|
|
6744
7012
|
]);
|
|
6745
7013
|
var COLLECTION_CONSTRUCTORS = /* @__PURE__ */ new Set(["Set", "Map"]);
|
|
6746
7014
|
function isIgnoredFile2(filename, sourceText) {
|
|
@@ -6753,14 +7021,14 @@ function isLocalFixtureFile(filename) {
|
|
|
6753
7021
|
return isTestFile(filename) || isStoryFile(filename);
|
|
6754
7022
|
}
|
|
6755
7023
|
function unwrap3(node) {
|
|
6756
|
-
if (node.type ===
|
|
7024
|
+
if (node.type === AST_NODE_TYPES37.TSAsExpression || node.type === AST_NODE_TYPES37.TSSatisfiesExpression || node.type === AST_NODE_TYPES37.TSNonNullExpression) {
|
|
6757
7025
|
return unwrap3(node.expression);
|
|
6758
7026
|
}
|
|
6759
7027
|
return node;
|
|
6760
7028
|
}
|
|
6761
7029
|
var HAS_STATEFUL_FLAG_RE = /[gy]/;
|
|
6762
7030
|
function isRegexLiteral(node) {
|
|
6763
|
-
return node.type ===
|
|
7031
|
+
return node.type === AST_NODE_TYPES37.Literal && "regex" in node && node.regex !== void 0;
|
|
6764
7032
|
}
|
|
6765
7033
|
function isLiteralOnly(node, depth) {
|
|
6766
7034
|
if (depth > MAX_LITERAL_DEPTH) {
|
|
@@ -6768,29 +7036,29 @@ function isLiteralOnly(node, depth) {
|
|
|
6768
7036
|
}
|
|
6769
7037
|
const inner = unwrap3(node);
|
|
6770
7038
|
switch (inner.type) {
|
|
6771
|
-
case
|
|
7039
|
+
case AST_NODE_TYPES37.Literal: {
|
|
6772
7040
|
return !(isRegexLiteral(inner) && HAS_STATEFUL_FLAG_RE.test(inner.regex.flags));
|
|
6773
7041
|
}
|
|
6774
|
-
case
|
|
7042
|
+
case AST_NODE_TYPES37.TemplateLiteral: {
|
|
6775
7043
|
return inner.expressions.length === 0;
|
|
6776
7044
|
}
|
|
6777
|
-
case
|
|
6778
|
-
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type ===
|
|
7045
|
+
case AST_NODE_TYPES37.UnaryExpression: {
|
|
7046
|
+
return (inner.operator === "-" || inner.operator === "+") && inner.argument.type === AST_NODE_TYPES37.Literal && typeof inner.argument.value === "number";
|
|
6779
7047
|
}
|
|
6780
|
-
case
|
|
7048
|
+
case AST_NODE_TYPES37.ArrayExpression: {
|
|
6781
7049
|
return inner.elements.every(
|
|
6782
|
-
(el) => el !== null && el.type !==
|
|
7050
|
+
(el) => el !== null && el.type !== AST_NODE_TYPES37.SpreadElement && isLiteralOnly(el, depth + 1)
|
|
6783
7051
|
);
|
|
6784
7052
|
}
|
|
6785
|
-
case
|
|
7053
|
+
case AST_NODE_TYPES37.ObjectExpression: {
|
|
6786
7054
|
return inner.properties.every((prop) => {
|
|
6787
|
-
if (prop.type !==
|
|
7055
|
+
if (prop.type !== AST_NODE_TYPES37.Property) {
|
|
6788
7056
|
return false;
|
|
6789
7057
|
}
|
|
6790
7058
|
if (prop.shorthand || prop.method || prop.kind !== "init") {
|
|
6791
7059
|
return false;
|
|
6792
7060
|
}
|
|
6793
|
-
if (prop.computed && prop.key.type !==
|
|
7061
|
+
if (prop.computed && prop.key.type !== AST_NODE_TYPES37.Literal) {
|
|
6794
7062
|
return false;
|
|
6795
7063
|
}
|
|
6796
7064
|
return isLiteralOnly(prop.value, depth + 1);
|
|
@@ -6803,7 +7071,7 @@ function isLiteralOnly(node, depth) {
|
|
|
6803
7071
|
}
|
|
6804
7072
|
function unwrapObjectFreeze(node) {
|
|
6805
7073
|
const inner = unwrap3(node);
|
|
6806
|
-
if (inner.type ===
|
|
7074
|
+
if (inner.type === AST_NODE_TYPES37.CallExpression && inner.callee.type === AST_NODE_TYPES37.MemberExpression && !inner.callee.computed && inner.callee.object.type === AST_NODE_TYPES37.Identifier && inner.callee.object.name === "Object" && inner.callee.property.type === AST_NODE_TYPES37.Identifier && inner.callee.property.name === "freeze" && inner.arguments.length === 1 && inner.arguments[0] !== void 0 && inner.arguments[0].type !== AST_NODE_TYPES37.SpreadElement) {
|
|
6807
7075
|
return unwrap3(inner.arguments[0]);
|
|
6808
7076
|
}
|
|
6809
7077
|
return inner;
|
|
@@ -6819,19 +7087,19 @@ function classify(init, checkRegex) {
|
|
|
6819
7087
|
}
|
|
6820
7088
|
return { kind: "regex", size: 1 };
|
|
6821
7089
|
}
|
|
6822
|
-
if (node.type ===
|
|
7090
|
+
if (node.type === AST_NODE_TYPES37.ArrayExpression) {
|
|
6823
7091
|
return isLiteralOnly(node, 0) ? { kind: "array", size: node.elements.length } : null;
|
|
6824
7092
|
}
|
|
6825
|
-
if (node.type ===
|
|
7093
|
+
if (node.type === AST_NODE_TYPES37.ObjectExpression) {
|
|
6826
7094
|
return isLiteralOnly(node, 0) ? { kind: "object", size: node.properties.length } : null;
|
|
6827
7095
|
}
|
|
6828
|
-
if (node.type ===
|
|
7096
|
+
if (node.type === AST_NODE_TYPES37.NewExpression && node.callee.type === AST_NODE_TYPES37.Identifier && COLLECTION_CONSTRUCTORS.has(node.callee.name)) {
|
|
6829
7097
|
const arg = node.arguments[0];
|
|
6830
|
-
if (node.arguments.length !== 1 || arg === void 0 || arg.type ===
|
|
7098
|
+
if (node.arguments.length !== 1 || arg === void 0 || arg.type === AST_NODE_TYPES37.SpreadElement) {
|
|
6831
7099
|
return null;
|
|
6832
7100
|
}
|
|
6833
7101
|
const entries = unwrap3(arg);
|
|
6834
|
-
if (entries.type !==
|
|
7102
|
+
if (entries.type !== AST_NODE_TYPES37.ArrayExpression) {
|
|
6835
7103
|
return null;
|
|
6836
7104
|
}
|
|
6837
7105
|
return isLiteralOnly(entries, 0) ? { kind: node.callee.name === "Set" ? "Set" : "Map", size: entries.elements.length } : null;
|
|
@@ -6860,10 +7128,10 @@ var NON_RETAINING_BUILTINS = /* @__PURE__ */ new Map(
|
|
|
6860
7128
|
);
|
|
6861
7129
|
function isNonRetainingBuiltinCall(node, argument) {
|
|
6862
7130
|
const callee = node.callee;
|
|
6863
|
-
if (callee.type ===
|
|
7131
|
+
if (callee.type === AST_NODE_TYPES37.Identifier && callee.name === "structuredClone") {
|
|
6864
7132
|
return true;
|
|
6865
7133
|
}
|
|
6866
|
-
if (callee.type !==
|
|
7134
|
+
if (callee.type !== AST_NODE_TYPES37.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES37.Identifier || callee.property.type !== AST_NODE_TYPES37.Identifier) {
|
|
6867
7135
|
return false;
|
|
6868
7136
|
}
|
|
6869
7137
|
const members = NON_RETAINING_BUILTINS.get(callee.object.name);
|
|
@@ -6877,38 +7145,38 @@ function isNonRetainingBuiltinCall(node, argument) {
|
|
|
6877
7145
|
}
|
|
6878
7146
|
function isSafeRead(identifier) {
|
|
6879
7147
|
const parent = identifier.parent;
|
|
6880
|
-
if (parent.type ===
|
|
7148
|
+
if (parent.type === AST_NODE_TYPES37.MemberExpression) {
|
|
6881
7149
|
if (parent.object !== identifier) {
|
|
6882
7150
|
return true;
|
|
6883
7151
|
}
|
|
6884
7152
|
const grandparent = parent.parent;
|
|
6885
|
-
if (grandparent.type ===
|
|
7153
|
+
if (grandparent.type === AST_NODE_TYPES37.AssignmentExpression && grandparent.left === parent) {
|
|
6886
7154
|
return false;
|
|
6887
7155
|
}
|
|
6888
|
-
if (grandparent.type ===
|
|
7156
|
+
if (grandparent.type === AST_NODE_TYPES37.UpdateExpression) {
|
|
6889
7157
|
return false;
|
|
6890
7158
|
}
|
|
6891
|
-
if (grandparent.type ===
|
|
7159
|
+
if (grandparent.type === AST_NODE_TYPES37.UnaryExpression && grandparent.operator === "delete") {
|
|
6892
7160
|
return false;
|
|
6893
7161
|
}
|
|
6894
|
-
if (!parent.computed && parent.property.type ===
|
|
7162
|
+
if (!parent.computed && parent.property.type === AST_NODE_TYPES37.Identifier && MUTATING_METHODS2.has(parent.property.name) && grandparent.type === AST_NODE_TYPES37.CallExpression && grandparent.callee === parent) {
|
|
6895
7163
|
return false;
|
|
6896
7164
|
}
|
|
6897
7165
|
return true;
|
|
6898
7166
|
}
|
|
6899
|
-
if (parent.type ===
|
|
7167
|
+
if (parent.type === AST_NODE_TYPES37.ForOfStatement && parent.right === identifier) {
|
|
6900
7168
|
return true;
|
|
6901
7169
|
}
|
|
6902
|
-
if (parent.type ===
|
|
7170
|
+
if (parent.type === AST_NODE_TYPES37.SpreadElement) {
|
|
6903
7171
|
return true;
|
|
6904
7172
|
}
|
|
6905
|
-
if (parent.type ===
|
|
7173
|
+
if (parent.type === AST_NODE_TYPES37.BinaryExpression) {
|
|
6906
7174
|
return true;
|
|
6907
7175
|
}
|
|
6908
|
-
if (parent.type ===
|
|
7176
|
+
if (parent.type === AST_NODE_TYPES37.CallExpression && parent.arguments.includes(identifier) && isNonRetainingBuiltinCall(parent, identifier)) {
|
|
6909
7177
|
return true;
|
|
6910
7178
|
}
|
|
6911
|
-
if (parent.type ===
|
|
7179
|
+
if (parent.type === AST_NODE_TYPES37.UnaryExpression && parent.operator !== "delete") {
|
|
6912
7180
|
return true;
|
|
6913
7181
|
}
|
|
6914
7182
|
return false;
|
|
@@ -6963,7 +7231,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6963
7231
|
if (reference.isWrite()) {
|
|
6964
7232
|
return false;
|
|
6965
7233
|
}
|
|
6966
|
-
if (reference.identifier.type !==
|
|
7234
|
+
if (reference.identifier.type !== AST_NODE_TYPES37.Identifier) {
|
|
6967
7235
|
return false;
|
|
6968
7236
|
}
|
|
6969
7237
|
if (!isSafeRead(reference.identifier)) {
|
|
@@ -6975,10 +7243,10 @@ var prefer_module_level_constant_default = createRule({
|
|
|
6975
7243
|
return {
|
|
6976
7244
|
VariableDeclarator(node) {
|
|
6977
7245
|
const declaration = node.parent;
|
|
6978
|
-
if (declaration.type !==
|
|
7246
|
+
if (declaration.type !== AST_NODE_TYPES37.VariableDeclaration || declaration.kind !== "const" || declaration.declare === true) {
|
|
6979
7247
|
return;
|
|
6980
7248
|
}
|
|
6981
|
-
if (node.id.type !==
|
|
7249
|
+
if (node.id.type !== AST_NODE_TYPES37.Identifier || node.init === null) {
|
|
6982
7250
|
return;
|
|
6983
7251
|
}
|
|
6984
7252
|
if (enclosingFunction2(node) === null) {
|
|
@@ -7005,7 +7273,7 @@ var prefer_module_level_constant_default = createRule({
|
|
|
7005
7273
|
});
|
|
7006
7274
|
|
|
7007
7275
|
// src/rules/prefer-module-level-schema.ts
|
|
7008
|
-
import { AST_NODE_TYPES as
|
|
7276
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES38 } from "@typescript-eslint/utils";
|
|
7009
7277
|
|
|
7010
7278
|
// src/rules/_zod.ts
|
|
7011
7279
|
var ZOD_PREFIX_RE = /^Z[A-Z]/;
|
|
@@ -7071,9 +7339,9 @@ var I18N_RECEIVER_NAMES = /* @__PURE__ */ new Set([
|
|
|
7071
7339
|
"intl"
|
|
7072
7340
|
]);
|
|
7073
7341
|
var FUNCTION_TYPES6 = /* @__PURE__ */ new Set([
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7342
|
+
AST_NODE_TYPES38.ArrowFunctionExpression,
|
|
7343
|
+
AST_NODE_TYPES38.FunctionDeclaration,
|
|
7344
|
+
AST_NODE_TYPES38.FunctionExpression
|
|
7077
7345
|
]);
|
|
7078
7346
|
function schemaExpression(node) {
|
|
7079
7347
|
let current = node;
|
|
@@ -7082,10 +7350,10 @@ function schemaExpression(node) {
|
|
|
7082
7350
|
if (parent === void 0) {
|
|
7083
7351
|
return current;
|
|
7084
7352
|
}
|
|
7085
|
-
if (parent.type ===
|
|
7353
|
+
if (parent.type === AST_NODE_TYPES38.MemberExpression && parent.object === current && !parent.computed && parent.property.type === AST_NODE_TYPES38.Identifier && TERMINAL_METHODS.has(parent.property.name)) {
|
|
7086
7354
|
return current;
|
|
7087
7355
|
}
|
|
7088
|
-
if (parent.type ===
|
|
7356
|
+
if (parent.type === AST_NODE_TYPES38.MemberExpression && parent.object === current || parent.type === AST_NODE_TYPES38.CallExpression && parent.callee === current || parent.type === AST_NODE_TYPES38.TSAsExpression && parent.expression === current || parent.type === AST_NODE_TYPES38.TSNonNullExpression && parent.expression === current) {
|
|
7089
7357
|
current = parent;
|
|
7090
7358
|
continue;
|
|
7091
7359
|
}
|
|
@@ -7136,22 +7404,22 @@ function subtreeSome(root, predicate) {
|
|
|
7136
7404
|
function readsReceiver(node) {
|
|
7137
7405
|
return subtreeSome(
|
|
7138
7406
|
node,
|
|
7139
|
-
(inner) => inner.type ===
|
|
7407
|
+
(inner) => inner.type === AST_NODE_TYPES38.ThisExpression || inner.type === AST_NODE_TYPES38.Super || inner.type === AST_NODE_TYPES38.Identifier && inner.name === "arguments"
|
|
7140
7408
|
);
|
|
7141
7409
|
}
|
|
7142
7410
|
function buildsLocalizedText(node) {
|
|
7143
7411
|
return subtreeSome(node, (inner) => {
|
|
7144
|
-
if (inner.type ===
|
|
7412
|
+
if (inner.type === AST_NODE_TYPES38.TaggedTemplateExpression) {
|
|
7145
7413
|
return true;
|
|
7146
7414
|
}
|
|
7147
|
-
if (inner.type !==
|
|
7415
|
+
if (inner.type !== AST_NODE_TYPES38.CallExpression) {
|
|
7148
7416
|
return false;
|
|
7149
7417
|
}
|
|
7150
7418
|
const { callee } = inner;
|
|
7151
|
-
if (callee.type ===
|
|
7419
|
+
if (callee.type === AST_NODE_TYPES38.Identifier) {
|
|
7152
7420
|
return I18N_CALLEE_NAMES.has(callee.name);
|
|
7153
7421
|
}
|
|
7154
|
-
return callee.type ===
|
|
7422
|
+
return callee.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES38.Identifier && I18N_RECEIVER_NAMES.has(callee.object.name);
|
|
7155
7423
|
});
|
|
7156
7424
|
}
|
|
7157
7425
|
function collectReferences(scope, out) {
|
|
@@ -7208,15 +7476,15 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7208
7476
|
}
|
|
7209
7477
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
7210
7478
|
function isZodCall(node) {
|
|
7211
|
-
return node.type ===
|
|
7479
|
+
return node.type === AST_NODE_TYPES38.CallExpression && node.callee.type === AST_NODE_TYPES38.MemberExpression && !node.callee.computed && node.callee.object.type === AST_NODE_TYPES38.Identifier && zodNamespaces.has(node.callee.object.name);
|
|
7212
7480
|
}
|
|
7213
7481
|
function isCovered(node) {
|
|
7214
7482
|
let current = node.parent ?? void 0;
|
|
7215
7483
|
while (current !== void 0) {
|
|
7216
|
-
if (current !== node && isZodCall(current) && current.callee.type ===
|
|
7484
|
+
if (current !== node && isZodCall(current) && current.callee.type === AST_NODE_TYPES38.MemberExpression && current.callee.property.type === AST_NODE_TYPES38.Identifier && factories.has(current.callee.property.name)) {
|
|
7217
7485
|
return true;
|
|
7218
7486
|
}
|
|
7219
|
-
if (current.type ===
|
|
7487
|
+
if (current.type === AST_NODE_TYPES38.CallExpression && (current.callee.type === AST_NODE_TYPES38.Identifier && MEMO_CALLEES.has(current.callee.name) || current.callee.type === AST_NODE_TYPES38.MemberExpression && !current.callee.computed && current.callee.property.type === AST_NODE_TYPES38.Identifier && MEMO_CALLEES.has(current.callee.property.name))) {
|
|
7220
7488
|
return true;
|
|
7221
7489
|
}
|
|
7222
7490
|
current = current.parent ?? void 0;
|
|
@@ -7231,11 +7499,11 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7231
7499
|
if (parent === void 0) {
|
|
7232
7500
|
return confirmed;
|
|
7233
7501
|
}
|
|
7234
|
-
if (parent.type ===
|
|
7502
|
+
if (parent.type === AST_NODE_TYPES38.Property && parent.value === current || parent.type === AST_NODE_TYPES38.ObjectExpression || parent.type === AST_NODE_TYPES38.ArrayExpression) {
|
|
7235
7503
|
current = parent;
|
|
7236
7504
|
continue;
|
|
7237
7505
|
}
|
|
7238
|
-
if (parent.type ===
|
|
7506
|
+
if (parent.type === AST_NODE_TYPES38.CallExpression && parent.arguments.includes(current) && isSchemaComposition(parent)) {
|
|
7239
7507
|
current = schemaExpression(parent);
|
|
7240
7508
|
confirmed = current;
|
|
7241
7509
|
continue;
|
|
@@ -7245,7 +7513,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7245
7513
|
}
|
|
7246
7514
|
function isSchemaComposition(node) {
|
|
7247
7515
|
const { callee } = node;
|
|
7248
|
-
const isCombinator = callee.type ===
|
|
7516
|
+
const isCombinator = callee.type === AST_NODE_TYPES38.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES38.Identifier && ZOD_COMBINATOR_METHODS.has(callee.property.name);
|
|
7249
7517
|
return isCombinator || isZodCall(node);
|
|
7250
7518
|
}
|
|
7251
7519
|
function closesOverNothing(node, enclosing) {
|
|
@@ -7279,13 +7547,13 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7279
7547
|
}
|
|
7280
7548
|
function ownerName(enclosing) {
|
|
7281
7549
|
const parent = enclosing.parent ?? void 0;
|
|
7282
|
-
if (enclosing.type ===
|
|
7550
|
+
if (enclosing.type === AST_NODE_TYPES38.FunctionDeclaration && enclosing.id !== null) {
|
|
7283
7551
|
return enclosing.id.name;
|
|
7284
7552
|
}
|
|
7285
|
-
if (parent !== void 0 && parent.type ===
|
|
7553
|
+
if (parent !== void 0 && parent.type === AST_NODE_TYPES38.VariableDeclarator && parent.id.type === AST_NODE_TYPES38.Identifier) {
|
|
7286
7554
|
return parent.id.name;
|
|
7287
7555
|
}
|
|
7288
|
-
if (parent !== void 0 && (parent.type ===
|
|
7556
|
+
if (parent !== void 0 && (parent.type === AST_NODE_TYPES38.MethodDefinition || parent.type === AST_NODE_TYPES38.Property) && parent.key.type === AST_NODE_TYPES38.Identifier) {
|
|
7289
7557
|
return parent.key.name;
|
|
7290
7558
|
}
|
|
7291
7559
|
return "this function";
|
|
@@ -7296,7 +7564,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7296
7564
|
return;
|
|
7297
7565
|
}
|
|
7298
7566
|
for (const specifier of node.specifiers) {
|
|
7299
|
-
if (specifier.type ===
|
|
7567
|
+
if (specifier.type === AST_NODE_TYPES38.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES38.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES38.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES38.Identifier && specifier.imported.name === "z") {
|
|
7300
7568
|
zodNamespaces.add(specifier.local.name);
|
|
7301
7569
|
}
|
|
7302
7570
|
}
|
|
@@ -7306,7 +7574,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7306
7574
|
return;
|
|
7307
7575
|
}
|
|
7308
7576
|
const callee = node.callee;
|
|
7309
|
-
if (callee.property.type !==
|
|
7577
|
+
if (callee.property.type !== AST_NODE_TYPES38.Identifier) {
|
|
7310
7578
|
return;
|
|
7311
7579
|
}
|
|
7312
7580
|
const factory = callee.property.name;
|
|
@@ -7321,7 +7589,7 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7321
7589
|
return;
|
|
7322
7590
|
}
|
|
7323
7591
|
const shape = node.arguments[0];
|
|
7324
|
-
if (shape !== void 0 && shape.type ===
|
|
7592
|
+
if (shape !== void 0 && shape.type === AST_NODE_TYPES38.ObjectExpression && shape.properties.length < minProperties) {
|
|
7325
7593
|
return;
|
|
7326
7594
|
}
|
|
7327
7595
|
const expression = schemaExpression(node);
|
|
@@ -7349,9 +7617,9 @@ var prefer_module_level_schema_default = createRule({
|
|
|
7349
7617
|
});
|
|
7350
7618
|
|
|
7351
7619
|
// src/rules/prefer-native-random-uuid.ts
|
|
7352
|
-
import { AST_NODE_TYPES as
|
|
7620
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES39, ASTUtils as ASTUtils3 } from "@typescript-eslint/utils";
|
|
7353
7621
|
function requireUuid(node) {
|
|
7354
|
-
return node?.type ===
|
|
7622
|
+
return node?.type === AST_NODE_TYPES39.CallExpression && node.callee.type === AST_NODE_TYPES39.Identifier && node.callee.name === "require" && node.arguments.length === 1 && node.arguments[0]?.type === AST_NODE_TYPES39.Literal && node.arguments[0].value === "uuid";
|
|
7355
7623
|
}
|
|
7356
7624
|
var prefer_native_random_uuid_default = createRule({
|
|
7357
7625
|
name: "prefer-native-random-uuid",
|
|
@@ -7394,37 +7662,37 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7394
7662
|
ImportDeclaration(node) {
|
|
7395
7663
|
if (node.source.value !== "uuid") return;
|
|
7396
7664
|
for (const specifier of node.specifiers) {
|
|
7397
|
-
if (specifier.type ===
|
|
7665
|
+
if (specifier.type === AST_NODE_TYPES39.ImportSpecifier && (specifier.imported.type === AST_NODE_TYPES39.Identifier ? specifier.imported.name === "v4" : specifier.imported.value === "v4")) {
|
|
7398
7666
|
record(specifier.local, directBindings);
|
|
7399
|
-
} else if (specifier.type ===
|
|
7667
|
+
} else if (specifier.type === AST_NODE_TYPES39.ImportNamespaceSpecifier) {
|
|
7400
7668
|
record(specifier.local, namespaceBindings);
|
|
7401
7669
|
}
|
|
7402
7670
|
}
|
|
7403
7671
|
},
|
|
7404
7672
|
VariableDeclarator(node) {
|
|
7405
7673
|
if (node.parent.kind !== "const" || !requireUuid(node.init)) return;
|
|
7406
|
-
if (node.init?.type !==
|
|
7674
|
+
if (node.init?.type !== AST_NODE_TYPES39.CallExpression || node.init.callee.type !== AST_NODE_TYPES39.Identifier || (resolve(node.init.callee)?.defs.length ?? 0) > 0) {
|
|
7407
7675
|
return;
|
|
7408
7676
|
}
|
|
7409
|
-
if (node.id.type ===
|
|
7677
|
+
if (node.id.type === AST_NODE_TYPES39.Identifier) {
|
|
7410
7678
|
record(node.id, namespaceBindings);
|
|
7411
7679
|
return;
|
|
7412
7680
|
}
|
|
7413
|
-
if (node.id.type !==
|
|
7681
|
+
if (node.id.type !== AST_NODE_TYPES39.ObjectPattern) return;
|
|
7414
7682
|
for (const property of node.id.properties) {
|
|
7415
|
-
if (property.type ===
|
|
7683
|
+
if (property.type === AST_NODE_TYPES39.Property && !property.computed && (property.key.type === AST_NODE_TYPES39.Identifier && property.key.name === "v4" || property.key.type === AST_NODE_TYPES39.Literal && property.key.value === "v4") && property.value.type === AST_NODE_TYPES39.Identifier) {
|
|
7416
7684
|
record(property.value, directBindings);
|
|
7417
7685
|
}
|
|
7418
7686
|
}
|
|
7419
7687
|
},
|
|
7420
7688
|
"CallExpression:exit"(node) {
|
|
7421
7689
|
if (node.arguments.length !== 0) return;
|
|
7422
|
-
if (node.callee.type ===
|
|
7690
|
+
if (node.callee.type === AST_NODE_TYPES39.Identifier) {
|
|
7423
7691
|
const variable2 = resolve(node.callee);
|
|
7424
7692
|
if (variable2 !== null && directBindings.has(variable2)) report(node);
|
|
7425
7693
|
return;
|
|
7426
7694
|
}
|
|
7427
|
-
if (node.callee.type !==
|
|
7695
|
+
if (node.callee.type !== AST_NODE_TYPES39.MemberExpression || node.callee.computed || node.callee.object.type !== AST_NODE_TYPES39.Identifier || node.callee.property.type !== AST_NODE_TYPES39.Identifier || node.callee.property.name !== "v4") {
|
|
7428
7696
|
return;
|
|
7429
7697
|
}
|
|
7430
7698
|
const variable = resolve(node.callee.object);
|
|
@@ -7435,20 +7703,20 @@ var prefer_native_random_uuid_default = createRule({
|
|
|
7435
7703
|
});
|
|
7436
7704
|
|
|
7437
7705
|
// src/rules/prefer-non-nullable-collection.ts
|
|
7438
|
-
import { AST_NODE_TYPES as
|
|
7706
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES40 } from "@typescript-eslint/utils";
|
|
7439
7707
|
var ARRAY_TYPE_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
|
|
7440
7708
|
function propertyName(node) {
|
|
7441
7709
|
const key = node.key;
|
|
7442
|
-
if (key.type ===
|
|
7443
|
-
if (key.type ===
|
|
7710
|
+
if (key.type === AST_NODE_TYPES40.Identifier) return key.name;
|
|
7711
|
+
if (key.type === AST_NODE_TYPES40.Literal) return String(key.value);
|
|
7444
7712
|
return "collection";
|
|
7445
7713
|
}
|
|
7446
7714
|
function isArrayType(node) {
|
|
7447
|
-
if (node.type ===
|
|
7448
|
-
return node.type ===
|
|
7715
|
+
if (node.type === AST_NODE_TYPES40.TSArrayType) return true;
|
|
7716
|
+
return node.type === AST_NODE_TYPES40.TSTypeReference && node.typeName.type === AST_NODE_TYPES40.Identifier && ARRAY_TYPE_NAMES.has(node.typeName.name);
|
|
7449
7717
|
}
|
|
7450
7718
|
function isNullishType(node) {
|
|
7451
|
-
return node.type ===
|
|
7719
|
+
return node.type === AST_NODE_TYPES40.TSNullKeyword || node.type === AST_NODE_TYPES40.TSUndefinedKeyword;
|
|
7452
7720
|
}
|
|
7453
7721
|
function isNullableArrayOnly(node) {
|
|
7454
7722
|
const values = node.types.filter((member) => !isNullishType(member));
|
|
@@ -7476,7 +7744,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7476
7744
|
if (node.optional) return;
|
|
7477
7745
|
const annotation = node.typeAnnotation?.typeAnnotation;
|
|
7478
7746
|
if (annotation === void 0) return;
|
|
7479
|
-
if (annotation.type !==
|
|
7747
|
+
if (annotation.type !== AST_NODE_TYPES40.TSUnionType || !isNullableArrayOnly(annotation)) {
|
|
7480
7748
|
return;
|
|
7481
7749
|
}
|
|
7482
7750
|
context.report({
|
|
@@ -7489,7 +7757,7 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7489
7757
|
TSPropertySignature: checkOptionalProperty,
|
|
7490
7758
|
PropertyDefinition: checkOptionalProperty,
|
|
7491
7759
|
TSTypeAliasDeclaration(node) {
|
|
7492
|
-
if (node.typeAnnotation.type !==
|
|
7760
|
+
if (node.typeAnnotation.type !== AST_NODE_TYPES40.TSUnionType) return;
|
|
7493
7761
|
if (!isNullableArrayOnly(node.typeAnnotation)) return;
|
|
7494
7762
|
context.report({
|
|
7495
7763
|
node,
|
|
@@ -7502,13 +7770,13 @@ var prefer_non_nullable_collection_default = createRule({
|
|
|
7502
7770
|
});
|
|
7503
7771
|
|
|
7504
7772
|
// src/rules/prefer-schema-for-api-payload.ts
|
|
7505
|
-
import { AST_NODE_TYPES as
|
|
7773
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES41 } from "@typescript-eslint/utils";
|
|
7506
7774
|
var unwrap4 = (node) => {
|
|
7507
7775
|
let current = node;
|
|
7508
7776
|
while (current !== null && current !== void 0) {
|
|
7509
|
-
if (current.type ===
|
|
7777
|
+
if (current.type === AST_NODE_TYPES41.TSAsExpression || current.type === AST_NODE_TYPES41.TSTypeAssertion || current.type === AST_NODE_TYPES41.TSNonNullExpression || current.type === AST_NODE_TYPES41.TSSatisfiesExpression) {
|
|
7510
7778
|
current = current.expression;
|
|
7511
|
-
} else if (current.type ===
|
|
7779
|
+
} else if (current.type === AST_NODE_TYPES41.ChainExpression) {
|
|
7512
7780
|
current = current.expression;
|
|
7513
7781
|
} else {
|
|
7514
7782
|
break;
|
|
@@ -7523,23 +7791,23 @@ var PROMISE_CHAIN_METHODS = /* @__PURE__ */ new Set([
|
|
|
7523
7791
|
]);
|
|
7524
7792
|
var isSchemaParseReference = (node) => {
|
|
7525
7793
|
const inner = unwrap4(node);
|
|
7526
|
-
return inner !== null && inner.type ===
|
|
7794
|
+
return inner !== null && inner.type === AST_NODE_TYPES41.MemberExpression && !inner.computed && inner.property.type === AST_NODE_TYPES41.Identifier && (inner.property.name === "parse" || inner.property.name === "safeParse");
|
|
7527
7795
|
};
|
|
7528
7796
|
var isRawPayloadSource = (node) => {
|
|
7529
7797
|
let current = unwrap4(node);
|
|
7530
7798
|
if (current === null) return false;
|
|
7531
|
-
if (current.type ===
|
|
7799
|
+
if (current.type === AST_NODE_TYPES41.AwaitExpression) {
|
|
7532
7800
|
current = unwrap4(current.argument);
|
|
7533
7801
|
}
|
|
7534
|
-
if (current === null || current.type !==
|
|
7802
|
+
if (current === null || current.type !== AST_NODE_TYPES41.CallExpression) {
|
|
7535
7803
|
return false;
|
|
7536
7804
|
}
|
|
7537
7805
|
const callee = unwrap4(current.callee);
|
|
7538
|
-
if (callee === null || callee.type !==
|
|
7806
|
+
if (callee === null || callee.type !== AST_NODE_TYPES41.MemberExpression) {
|
|
7539
7807
|
return false;
|
|
7540
7808
|
}
|
|
7541
7809
|
const property = unwrap4(callee.property);
|
|
7542
|
-
if (property === null || property.type !==
|
|
7810
|
+
if (property === null || property.type !== AST_NODE_TYPES41.Identifier) {
|
|
7543
7811
|
return false;
|
|
7544
7812
|
}
|
|
7545
7813
|
if (property.name === "json") {
|
|
@@ -7549,16 +7817,16 @@ var isRawPayloadSource = (node) => {
|
|
|
7549
7817
|
return !current.arguments.some(isSchemaParseReference) && isRawPayloadSource(callee.object);
|
|
7550
7818
|
}
|
|
7551
7819
|
const object = unwrap4(callee.object);
|
|
7552
|
-
return property.name === "parse" && object !== null && object.type ===
|
|
7820
|
+
return property.name === "parse" && object !== null && object.type === AST_NODE_TYPES41.Identifier && object.name === "JSON" && !isLocalFileRead(current.arguments[0]);
|
|
7553
7821
|
};
|
|
7554
7822
|
var FILE_READ_RE = /^(readFile|readFileSync|readJson|readJsonSync|readJSON)$/;
|
|
7555
7823
|
var isLocalFileRead = (node) => {
|
|
7556
7824
|
let found = false;
|
|
7557
7825
|
const visit = (current) => {
|
|
7558
7826
|
if (found || current === null || current === void 0) return;
|
|
7559
|
-
if (current.type ===
|
|
7827
|
+
if (current.type === AST_NODE_TYPES41.CallExpression) {
|
|
7560
7828
|
const callee = unwrap4(current.callee);
|
|
7561
|
-
const name = callee?.type ===
|
|
7829
|
+
const name = callee?.type === AST_NODE_TYPES41.Identifier ? callee.name : callee?.type === AST_NODE_TYPES41.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES41.Identifier ? callee.property.name : null;
|
|
7562
7830
|
if (name !== null && FILE_READ_RE.test(name)) {
|
|
7563
7831
|
found = true;
|
|
7564
7832
|
return;
|
|
@@ -7580,15 +7848,15 @@ var isLocalFileRead = (node) => {
|
|
|
7580
7848
|
var ASSERTION_CALLEE_RE = /^(expect|assert|should|invariant)$/;
|
|
7581
7849
|
var isInsideAssertion = (node) => {
|
|
7582
7850
|
for (let current = node.parent; current !== void 0 && current !== null; current = current.parent) {
|
|
7583
|
-
if (current.type !==
|
|
7851
|
+
if (current.type !== AST_NODE_TYPES41.CallExpression) continue;
|
|
7584
7852
|
let callee = current.callee;
|
|
7585
|
-
while (callee.type ===
|
|
7853
|
+
while (callee.type === AST_NODE_TYPES41.MemberExpression) {
|
|
7586
7854
|
callee = callee.object;
|
|
7587
7855
|
}
|
|
7588
|
-
if (callee.type ===
|
|
7856
|
+
if (callee.type === AST_NODE_TYPES41.CallExpression) {
|
|
7589
7857
|
callee = callee.callee;
|
|
7590
7858
|
}
|
|
7591
|
-
if (callee.type ===
|
|
7859
|
+
if (callee.type === AST_NODE_TYPES41.Identifier && ASSERTION_CALLEE_RE.test(callee.name)) {
|
|
7592
7860
|
return true;
|
|
7593
7861
|
}
|
|
7594
7862
|
}
|
|
@@ -7607,39 +7875,39 @@ var GUARD_NAME_RE = /^(?:is|validate|parse|assert|decode|coerce)[A-Z]/;
|
|
|
7607
7875
|
var isValidationRead = (node) => {
|
|
7608
7876
|
let current = node;
|
|
7609
7877
|
let parent = current.parent;
|
|
7610
|
-
while (parent !== null && parent !== void 0 && (parent.type ===
|
|
7878
|
+
while (parent !== null && parent !== void 0 && (parent.type === AST_NODE_TYPES41.TSAsExpression || parent.type === AST_NODE_TYPES41.TSTypeAssertion || parent.type === AST_NODE_TYPES41.TSNonNullExpression || parent.type === AST_NODE_TYPES41.TSSatisfiesExpression || parent.type === AST_NODE_TYPES41.ChainExpression)) {
|
|
7611
7879
|
current = parent;
|
|
7612
7880
|
parent = parent.parent;
|
|
7613
7881
|
}
|
|
7614
7882
|
if (parent === null || parent === void 0) return false;
|
|
7615
|
-
if (parent.type ===
|
|
7883
|
+
if (parent.type === AST_NODE_TYPES41.UnaryExpression && parent.operator === "typeof" && parent.argument === current) {
|
|
7616
7884
|
return true;
|
|
7617
7885
|
}
|
|
7618
|
-
if (parent.type !==
|
|
7886
|
+
if (parent.type !== AST_NODE_TYPES41.CallExpression || !parent.arguments.some((arg) => arg === current)) {
|
|
7619
7887
|
return false;
|
|
7620
7888
|
}
|
|
7621
7889
|
const callee = parent.callee;
|
|
7622
|
-
if (callee.type ===
|
|
7890
|
+
if (callee.type === AST_NODE_TYPES41.MemberExpression && !callee.computed && callee.object.type === AST_NODE_TYPES41.Identifier && callee.object.name === "Array" && callee.property.type === AST_NODE_TYPES41.Identifier && callee.property.name === "isArray") {
|
|
7623
7891
|
return parent.arguments.length === 1;
|
|
7624
7892
|
}
|
|
7625
|
-
return callee.type ===
|
|
7893
|
+
return callee.type === AST_NODE_TYPES41.Identifier && GUARD_NAME_RE.test(callee.name);
|
|
7626
7894
|
};
|
|
7627
7895
|
var isGuardTestPosition = (node) => {
|
|
7628
7896
|
let current = node;
|
|
7629
7897
|
let parent = current.parent;
|
|
7630
7898
|
while (parent !== void 0 && parent !== null) {
|
|
7631
7899
|
switch (parent.type) {
|
|
7632
|
-
case
|
|
7633
|
-
case
|
|
7634
|
-
case
|
|
7900
|
+
case AST_NODE_TYPES41.UnaryExpression:
|
|
7901
|
+
case AST_NODE_TYPES41.LogicalExpression:
|
|
7902
|
+
case AST_NODE_TYPES41.ChainExpression:
|
|
7635
7903
|
current = parent;
|
|
7636
7904
|
parent = parent.parent;
|
|
7637
7905
|
continue;
|
|
7638
|
-
case
|
|
7639
|
-
case
|
|
7640
|
-
case
|
|
7641
|
-
case
|
|
7642
|
-
case
|
|
7906
|
+
case AST_NODE_TYPES41.IfStatement:
|
|
7907
|
+
case AST_NODE_TYPES41.ConditionalExpression:
|
|
7908
|
+
case AST_NODE_TYPES41.WhileStatement:
|
|
7909
|
+
case AST_NODE_TYPES41.DoWhileStatement:
|
|
7910
|
+
case AST_NODE_TYPES41.ForStatement:
|
|
7643
7911
|
return parent.test === current;
|
|
7644
7912
|
default:
|
|
7645
7913
|
return false;
|
|
@@ -7649,7 +7917,7 @@ var isGuardTestPosition = (node) => {
|
|
|
7649
7917
|
};
|
|
7650
7918
|
var isUnvalidatedVariableRef = (node, scope, tracked) => {
|
|
7651
7919
|
const unwrapped = unwrap4(node);
|
|
7652
|
-
if (unwrapped === null || unwrapped.type !==
|
|
7920
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES41.Identifier) {
|
|
7653
7921
|
return false;
|
|
7654
7922
|
}
|
|
7655
7923
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7692,11 +7960,11 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7692
7960
|
return {
|
|
7693
7961
|
VariableDeclarator(node) {
|
|
7694
7962
|
const scope = context.sourceCode.getScope(node);
|
|
7695
|
-
if (node.id.type ===
|
|
7963
|
+
if (node.id.type === AST_NODE_TYPES41.Identifier) {
|
|
7696
7964
|
trackInitializer(node);
|
|
7697
7965
|
return;
|
|
7698
7966
|
}
|
|
7699
|
-
if (node.id.type ===
|
|
7967
|
+
if (node.id.type === AST_NODE_TYPES41.ObjectPattern || node.id.type === AST_NODE_TYPES41.ArrayPattern) {
|
|
7700
7968
|
if (isRawPayloadSource(node.init)) {
|
|
7701
7969
|
if (!isFullyNarrowedPattern(node)) {
|
|
7702
7970
|
context.report({ node: node.id, messageId: "unparsedJsonAccess" });
|
|
@@ -7710,7 +7978,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7710
7978
|
},
|
|
7711
7979
|
AssignmentExpression(node) {
|
|
7712
7980
|
const scope = context.sourceCode.getScope(node);
|
|
7713
|
-
if (node.left.type ===
|
|
7981
|
+
if (node.left.type === AST_NODE_TYPES41.Identifier) {
|
|
7714
7982
|
const variable = findVariable2(scope, node.left.name);
|
|
7715
7983
|
if (variable === null) return;
|
|
7716
7984
|
if (isRawPayloadSource(node.right)) {
|
|
@@ -7720,7 +7988,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7720
7988
|
}
|
|
7721
7989
|
return;
|
|
7722
7990
|
}
|
|
7723
|
-
if (node.left.type ===
|
|
7991
|
+
if (node.left.type === AST_NODE_TYPES41.ObjectPattern || node.left.type === AST_NODE_TYPES41.ArrayPattern) {
|
|
7724
7992
|
if (isRawPayloadSource(node.right)) {
|
|
7725
7993
|
context.report({
|
|
7726
7994
|
node: node.left,
|
|
@@ -7737,15 +8005,15 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7737
8005
|
}
|
|
7738
8006
|
},
|
|
7739
8007
|
CallExpression(node) {
|
|
7740
|
-
if (node.callee.type !==
|
|
8008
|
+
if (node.callee.type !== AST_NODE_TYPES41.Identifier) return;
|
|
7741
8009
|
if (!GUARD_NAME_RE.test(node.callee.name) && !isGuardTestPosition(node)) {
|
|
7742
8010
|
return;
|
|
7743
8011
|
}
|
|
7744
8012
|
const scope = context.sourceCode.getScope(node);
|
|
7745
8013
|
for (const arg of node.arguments) {
|
|
7746
|
-
if (arg.type ===
|
|
8014
|
+
if (arg.type === AST_NODE_TYPES41.SpreadElement) continue;
|
|
7747
8015
|
const unwrapped = unwrap4(arg);
|
|
7748
|
-
if (unwrapped === null || unwrapped.type !==
|
|
8016
|
+
if (unwrapped === null || unwrapped.type !== AST_NODE_TYPES41.Identifier) {
|
|
7749
8017
|
continue;
|
|
7750
8018
|
}
|
|
7751
8019
|
const variable = findVariable2(scope, unwrapped.name);
|
|
@@ -7759,13 +8027,13 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7759
8027
|
const obj = unwrap4(node.object);
|
|
7760
8028
|
if (isRawPayloadSource(obj)) {
|
|
7761
8029
|
const parent = node.parent;
|
|
7762
|
-
if (parent.type ===
|
|
8030
|
+
if (parent.type === AST_NODE_TYPES41.CallExpression && parent.callee === node && node.property.type === AST_NODE_TYPES41.Identifier && (node.property.name === "parse" || node.property.name === "safeParse" || PROMISE_CHAIN_METHODS.has(node.property.name))) {
|
|
7763
8031
|
return;
|
|
7764
8032
|
}
|
|
7765
8033
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7766
8034
|
return;
|
|
7767
8035
|
}
|
|
7768
|
-
if (obj !== null && obj.type ===
|
|
8036
|
+
if (obj !== null && obj.type === AST_NODE_TYPES41.Identifier && isUnvalidatedVariableRef(obj, scope, unvalidatedVariables)) {
|
|
7769
8037
|
context.report({ node, messageId: "unparsedJsonAccess" });
|
|
7770
8038
|
const variable = findVariable2(scope, obj.name);
|
|
7771
8039
|
if (variable !== null) {
|
|
@@ -7778,7 +8046,7 @@ var prefer_schema_for_api_payload_default = createRule({
|
|
|
7778
8046
|
});
|
|
7779
8047
|
|
|
7780
8048
|
// src/rules/prefer-semantic-colors.ts
|
|
7781
|
-
import { AST_NODE_TYPES as
|
|
8049
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES42 } from "@typescript-eslint/utils";
|
|
7782
8050
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
7783
8051
|
import { dirname, join, parse } from "path";
|
|
7784
8052
|
|
|
@@ -7878,8 +8146,8 @@ var SVG_EXEMPT_COLOR_VALUES = /* @__PURE__ */ new Set([
|
|
|
7878
8146
|
]);
|
|
7879
8147
|
function jsxElementName(node) {
|
|
7880
8148
|
const name = node.openingElement.name;
|
|
7881
|
-
if (name.type ===
|
|
7882
|
-
if (name.type ===
|
|
8149
|
+
if (name.type === AST_NODE_TYPES42.JSXIdentifier) return name.name;
|
|
8150
|
+
if (name.type === AST_NODE_TYPES42.JSXMemberExpression && name.property.type === AST_NODE_TYPES42.JSXIdentifier) {
|
|
7883
8151
|
return name.property.name;
|
|
7884
8152
|
}
|
|
7885
8153
|
return null;
|
|
@@ -7905,7 +8173,7 @@ var EMAIL_OR_PDF_MODULE_RE = /^@react-(?:email|pdf)\//;
|
|
|
7905
8173
|
var isInsideSvg = (node) => {
|
|
7906
8174
|
let current = node.parent;
|
|
7907
8175
|
while (current !== void 0 && current !== null) {
|
|
7908
|
-
if (current.type ===
|
|
8176
|
+
if (current.type === AST_NODE_TYPES42.JSXElement) {
|
|
7909
8177
|
const name = jsxElementName(current);
|
|
7910
8178
|
if (name !== null && isSvgLikeElementName(name)) return true;
|
|
7911
8179
|
}
|
|
@@ -7916,7 +8184,7 @@ var isInsideSvg = (node) => {
|
|
|
7916
8184
|
var isInsideIconFactoryPath = (node) => {
|
|
7917
8185
|
let current = node.parent;
|
|
7918
8186
|
while (current !== void 0 && current !== null) {
|
|
7919
|
-
if (current.type ===
|
|
8187
|
+
if (current.type === AST_NODE_TYPES42.Property && propName(current.key) === "path" && current.parent.type === AST_NODE_TYPES42.ObjectExpression && current.parent.parent.type === AST_NODE_TYPES42.CallExpression && current.parent.parent.callee.type === AST_NODE_TYPES42.Identifier && current.parent.parent.callee.name === "createIcon") {
|
|
7920
8188
|
return true;
|
|
7921
8189
|
}
|
|
7922
8190
|
current = current.parent;
|
|
@@ -8053,12 +8321,12 @@ var hasSemanticTokenSystem = (filename) => {
|
|
|
8053
8321
|
return root !== null && workspaceHasMarker(root);
|
|
8054
8322
|
};
|
|
8055
8323
|
var propName = (key) => {
|
|
8056
|
-
if (key.type ===
|
|
8057
|
-
if (key.type ===
|
|
8324
|
+
if (key.type === AST_NODE_TYPES42.Identifier) return key.name;
|
|
8325
|
+
if (key.type === AST_NODE_TYPES42.Literal && typeof key.value === "string") return key.value;
|
|
8058
8326
|
return null;
|
|
8059
8327
|
};
|
|
8060
8328
|
var staticallyImportsEmailOrPdfRenderer = (program) => program.body.some((statement) => {
|
|
8061
|
-
if (statement.type !==
|
|
8329
|
+
if (statement.type !== AST_NODE_TYPES42.ImportDeclaration && statement.type !== AST_NODE_TYPES42.ExportNamedDeclaration && statement.type !== AST_NODE_TYPES42.ExportAllDeclaration) {
|
|
8062
8330
|
return false;
|
|
8063
8331
|
}
|
|
8064
8332
|
return statement.source !== null && typeof statement.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(statement.source.value);
|
|
@@ -8110,27 +8378,27 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8110
8378
|
const checkClassNode = (node) => {
|
|
8111
8379
|
if (node === null) return;
|
|
8112
8380
|
switch (node.type) {
|
|
8113
|
-
case
|
|
8381
|
+
case AST_NODE_TYPES42.Literal:
|
|
8114
8382
|
if (typeof node.value === "string") reportClasses(node.value, node);
|
|
8115
8383
|
break;
|
|
8116
|
-
case
|
|
8384
|
+
case AST_NODE_TYPES42.TemplateLiteral:
|
|
8117
8385
|
for (const quasi of node.quasis) reportClasses(quasi.value.cooked ?? "", quasi);
|
|
8118
8386
|
break;
|
|
8119
|
-
case
|
|
8387
|
+
case AST_NODE_TYPES42.ArrayExpression:
|
|
8120
8388
|
for (const element of node.elements) {
|
|
8121
|
-
if (element !== null && element.type !==
|
|
8389
|
+
if (element !== null && element.type !== AST_NODE_TYPES42.SpreadElement) checkClassNode(element);
|
|
8122
8390
|
}
|
|
8123
8391
|
break;
|
|
8124
|
-
case
|
|
8392
|
+
case AST_NODE_TYPES42.ObjectExpression:
|
|
8125
8393
|
for (const property of node.properties) {
|
|
8126
|
-
if (property.type ===
|
|
8394
|
+
if (property.type === AST_NODE_TYPES42.Property) checkClassNode(property.value);
|
|
8127
8395
|
}
|
|
8128
8396
|
break;
|
|
8129
|
-
case
|
|
8397
|
+
case AST_NODE_TYPES42.ConditionalExpression:
|
|
8130
8398
|
checkClassNode(node.consequent);
|
|
8131
8399
|
checkClassNode(node.alternate);
|
|
8132
8400
|
break;
|
|
8133
|
-
case
|
|
8401
|
+
case AST_NODE_TYPES42.LogicalExpression:
|
|
8134
8402
|
checkClassNode(node.right);
|
|
8135
8403
|
break;
|
|
8136
8404
|
default:
|
|
@@ -8138,32 +8406,32 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8138
8406
|
}
|
|
8139
8407
|
};
|
|
8140
8408
|
const checkColorValueNode = (node) => {
|
|
8141
|
-
if (node.type ===
|
|
8409
|
+
if (node.type === AST_NODE_TYPES42.Literal && typeof node.value === "string" && RAW_COLOR_VALUE_RE.test(node.value) && !CSS_VAR_REFERENCE_RE.test(node.value)) {
|
|
8142
8410
|
report(node, "inlineColor", { value: node.value });
|
|
8143
8411
|
}
|
|
8144
8412
|
};
|
|
8145
8413
|
return {
|
|
8146
8414
|
"JSXAttribute[name.name='className']"(node) {
|
|
8147
8415
|
if (node.value === null) return;
|
|
8148
|
-
if (node.value.type ===
|
|
8149
|
-
else if (node.value.type ===
|
|
8150
|
-
if (node.value.expression.type !==
|
|
8416
|
+
if (node.value.type === AST_NODE_TYPES42.Literal) checkClassNode(node.value);
|
|
8417
|
+
else if (node.value.type === AST_NODE_TYPES42.JSXExpressionContainer) {
|
|
8418
|
+
if (node.value.expression.type !== AST_NODE_TYPES42.JSXEmptyExpression) {
|
|
8151
8419
|
checkClassNode(node.value.expression);
|
|
8152
8420
|
}
|
|
8153
8421
|
}
|
|
8154
8422
|
},
|
|
8155
8423
|
CallExpression(node) {
|
|
8156
|
-
if (node.callee.type ===
|
|
8424
|
+
if (node.callee.type === AST_NODE_TYPES42.Identifier && node.callee.name === "require" && node.arguments[0]?.type === AST_NODE_TYPES42.Literal && typeof node.arguments[0].value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.arguments[0].value)) {
|
|
8157
8425
|
importsEmailOrPdfRenderer = true;
|
|
8158
8426
|
}
|
|
8159
|
-
if (node.callee.type ===
|
|
8427
|
+
if (node.callee.type === AST_NODE_TYPES42.Identifier && CLASS_FNS.has(node.callee.name)) {
|
|
8160
8428
|
for (const arg of node.arguments) {
|
|
8161
|
-
if (arg.type !==
|
|
8429
|
+
if (arg.type !== AST_NODE_TYPES42.SpreadElement) checkClassNode(arg);
|
|
8162
8430
|
}
|
|
8163
8431
|
}
|
|
8164
8432
|
},
|
|
8165
8433
|
VariableDeclarator(node) {
|
|
8166
|
-
if (node.id.type ===
|
|
8434
|
+
if (node.id.type === AST_NODE_TYPES42.Identifier && CLASS_NAME_RE.test(node.id.name)) {
|
|
8167
8435
|
checkClassNode(node.init);
|
|
8168
8436
|
}
|
|
8169
8437
|
},
|
|
@@ -8173,9 +8441,9 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8173
8441
|
},
|
|
8174
8442
|
// SVG artwork colors are exempt; component presentation colors still report.
|
|
8175
8443
|
"JSXAttribute[name.name=/^(fill|stroke|color)$/]"(node) {
|
|
8176
|
-
if (node.value?.type !==
|
|
8444
|
+
if (node.value?.type !== AST_NODE_TYPES42.Literal) return;
|
|
8177
8445
|
const owner = node.parent.name;
|
|
8178
|
-
if (owner.type ===
|
|
8446
|
+
if (owner.type === AST_NODE_TYPES42.JSXIdentifier && SVG_SHAPE_PRIMITIVES.has(owner.name)) {
|
|
8179
8447
|
return;
|
|
8180
8448
|
}
|
|
8181
8449
|
if (typeof node.value.value === "string" && SVG_EXEMPT_COLOR_VALUES.has(node.value.value.toLowerCase())) {
|
|
@@ -8189,7 +8457,7 @@ var prefer_semantic_colors_default = createRule({
|
|
|
8189
8457
|
if (name !== null && STYLE_COLOR_PROPS.has(name)) checkColorValueNode(node.value);
|
|
8190
8458
|
},
|
|
8191
8459
|
ImportExpression(node) {
|
|
8192
|
-
if (node.source.type ===
|
|
8460
|
+
if (node.source.type === AST_NODE_TYPES42.Literal && typeof node.source.value === "string" && EMAIL_OR_PDF_MODULE_RE.test(node.source.value)) {
|
|
8193
8461
|
importsEmailOrPdfRenderer = true;
|
|
8194
8462
|
}
|
|
8195
8463
|
},
|
|
@@ -8395,7 +8663,7 @@ var prefer_single_sentence_comment_default = createRule({
|
|
|
8395
8663
|
// src/rules/prefer-string-literal-union.ts
|
|
8396
8664
|
import {
|
|
8397
8665
|
ESLintUtils as ESLintUtils3,
|
|
8398
|
-
AST_NODE_TYPES as
|
|
8666
|
+
AST_NODE_TYPES as AST_NODE_TYPES43
|
|
8399
8667
|
} from "@typescript-eslint/utils";
|
|
8400
8668
|
import * as ts2 from "typescript";
|
|
8401
8669
|
var CHOICE_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -8439,19 +8707,19 @@ function isChoiceLikeName(name) {
|
|
|
8439
8707
|
return CHOICE_TOKENS.has(lastWord(name));
|
|
8440
8708
|
}
|
|
8441
8709
|
function keyName(key) {
|
|
8442
|
-
if (key.type ===
|
|
8710
|
+
if (key.type === AST_NODE_TYPES43.Identifier) {
|
|
8443
8711
|
return key.name;
|
|
8444
8712
|
}
|
|
8445
|
-
if (key.type ===
|
|
8713
|
+
if (key.type === AST_NODE_TYPES43.Literal && typeof key.value === "string") {
|
|
8446
8714
|
return key.value;
|
|
8447
8715
|
}
|
|
8448
8716
|
return null;
|
|
8449
8717
|
}
|
|
8450
8718
|
function isStringLiteralMember(t) {
|
|
8451
|
-
return t.type ===
|
|
8719
|
+
return t.type === AST_NODE_TYPES43.TSLiteralType && t.literal.type === AST_NODE_TYPES43.Literal && typeof t.literal.value === "string";
|
|
8452
8720
|
}
|
|
8453
8721
|
function isStringLiteralUnion(node) {
|
|
8454
|
-
if (node?.type !==
|
|
8722
|
+
if (node?.type !== AST_NODE_TYPES43.TSUnionType) {
|
|
8455
8723
|
return false;
|
|
8456
8724
|
}
|
|
8457
8725
|
return node.types.filter(isStringLiteralMember).length >= MIN_CLUSTER_SIZE;
|
|
@@ -8480,12 +8748,12 @@ function bindingSourceExpression(decl) {
|
|
|
8480
8748
|
return ts2.isForOfStatement(node) ? node.expression : node.initializer;
|
|
8481
8749
|
}
|
|
8482
8750
|
function refKey(node) {
|
|
8483
|
-
if (node.type ===
|
|
8751
|
+
if (node.type === AST_NODE_TYPES43.Identifier) {
|
|
8484
8752
|
return node.name;
|
|
8485
8753
|
}
|
|
8486
|
-
if (node.type ===
|
|
8754
|
+
if (node.type === AST_NODE_TYPES43.MemberExpression && !node.computed) {
|
|
8487
8755
|
const inner = refKey(node.object);
|
|
8488
|
-
if (inner === null || node.property.type !==
|
|
8756
|
+
if (inner === null || node.property.type !== AST_NODE_TYPES43.Identifier) {
|
|
8489
8757
|
return null;
|
|
8490
8758
|
}
|
|
8491
8759
|
return `${inner}.${node.property.name}`;
|
|
@@ -8493,7 +8761,7 @@ function refKey(node) {
|
|
|
8493
8761
|
return null;
|
|
8494
8762
|
}
|
|
8495
8763
|
function strLiteral(node) {
|
|
8496
|
-
if (node.type ===
|
|
8764
|
+
if (node.type === AST_NODE_TYPES43.Literal && typeof node.value === "string") {
|
|
8497
8765
|
return node.value;
|
|
8498
8766
|
}
|
|
8499
8767
|
return null;
|
|
@@ -8646,7 +8914,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8646
8914
|
containersWithUnion.add(container);
|
|
8647
8915
|
return;
|
|
8648
8916
|
}
|
|
8649
|
-
if (typeNode?.type !==
|
|
8917
|
+
if (typeNode?.type !== AST_NODE_TYPES43.TSStringKeyword) {
|
|
8650
8918
|
return;
|
|
8651
8919
|
}
|
|
8652
8920
|
const name = keyName(key);
|
|
@@ -8734,10 +9002,10 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8734
9002
|
}
|
|
8735
9003
|
};
|
|
8736
9004
|
function refKeyText(node) {
|
|
8737
|
-
if (node.type ===
|
|
9005
|
+
if (node.type === AST_NODE_TYPES43.BinaryExpression) {
|
|
8738
9006
|
return refKey(node.left) ?? refKey(node.right) ?? "value";
|
|
8739
9007
|
}
|
|
8740
|
-
if (node.type ===
|
|
9008
|
+
if (node.type === AST_NODE_TYPES43.SwitchStatement) {
|
|
8741
9009
|
return refKey(node.discriminant) ?? "value";
|
|
8742
9010
|
}
|
|
8743
9011
|
return "value";
|
|
@@ -8746,7 +9014,7 @@ var prefer_string_literal_union_default = createRule({
|
|
|
8746
9014
|
});
|
|
8747
9015
|
|
|
8748
9016
|
// src/rules/prefer-whole-object-assertion.ts
|
|
8749
|
-
import { AST_NODE_TYPES as
|
|
9017
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES44 } from "@typescript-eslint/utils";
|
|
8750
9018
|
var MERGEABLE_MATCHERS = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
8751
9019
|
var ARRAY_MATCHERS = /* @__PURE__ */ new Set(["toEqual", "toStrictEqual"]);
|
|
8752
9020
|
var COLLECTION_PROPERTIES = /* @__PURE__ */ new Set(["length", "size"]);
|
|
@@ -8755,11 +9023,11 @@ var NUMERIC_SIGNS2 = /* @__PURE__ */ new Set(["-", "+"]);
|
|
|
8755
9023
|
var MIN_RUN_LENGTH = 2;
|
|
8756
9024
|
function literalText(node, getText) {
|
|
8757
9025
|
switch (node.type) {
|
|
8758
|
-
case
|
|
9026
|
+
case AST_NODE_TYPES44.Literal:
|
|
8759
9027
|
return "regex" in node ? null : getText(node);
|
|
8760
|
-
case
|
|
9028
|
+
case AST_NODE_TYPES44.TemplateLiteral:
|
|
8761
9029
|
return node.expressions.length === 0 ? getText(node) : null;
|
|
8762
|
-
case
|
|
9030
|
+
case AST_NODE_TYPES44.UnaryExpression:
|
|
8763
9031
|
return NUMERIC_SIGNS2.has(node.operator) && literalText(node.argument, getText) !== null ? getText(node) : null;
|
|
8764
9032
|
default:
|
|
8765
9033
|
return null;
|
|
@@ -8767,15 +9035,15 @@ function literalText(node, getText) {
|
|
|
8767
9035
|
}
|
|
8768
9036
|
function isPureReceiver(node) {
|
|
8769
9037
|
switch (node.type) {
|
|
8770
|
-
case
|
|
8771
|
-
case
|
|
9038
|
+
case AST_NODE_TYPES44.Identifier:
|
|
9039
|
+
case AST_NODE_TYPES44.ThisExpression:
|
|
8772
9040
|
return true;
|
|
8773
|
-
case
|
|
9041
|
+
case AST_NODE_TYPES44.MemberExpression:
|
|
8774
9042
|
if (node.optional) {
|
|
8775
9043
|
return false;
|
|
8776
9044
|
}
|
|
8777
9045
|
if (node.computed) {
|
|
8778
|
-
return node.property.type ===
|
|
9046
|
+
return node.property.type === AST_NODE_TYPES44.Literal && isPureReceiver(node.object);
|
|
8779
9047
|
}
|
|
8780
9048
|
return isPureReceiver(node.object);
|
|
8781
9049
|
default:
|
|
@@ -8783,7 +9051,7 @@ function isPureReceiver(node) {
|
|
|
8783
9051
|
}
|
|
8784
9052
|
}
|
|
8785
9053
|
function literalIndex(node) {
|
|
8786
|
-
if (node.type !==
|
|
9054
|
+
if (node.type !== AST_NODE_TYPES44.Literal || typeof node.value !== "number") {
|
|
8787
9055
|
return null;
|
|
8788
9056
|
}
|
|
8789
9057
|
return Number.isInteger(node.value) && node.value >= 0 ? node.value : null;
|
|
@@ -8809,24 +9077,24 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8809
9077
|
}
|
|
8810
9078
|
const { sourceCode } = context;
|
|
8811
9079
|
function parseAssertion(statement) {
|
|
8812
|
-
if (statement.type !==
|
|
9080
|
+
if (statement.type !== AST_NODE_TYPES44.ExpressionStatement) {
|
|
8813
9081
|
return null;
|
|
8814
9082
|
}
|
|
8815
9083
|
const call = statement.expression;
|
|
8816
|
-
if (call.type !==
|
|
9084
|
+
if (call.type !== AST_NODE_TYPES44.CallExpression) {
|
|
8817
9085
|
return null;
|
|
8818
9086
|
}
|
|
8819
9087
|
const callee = call.callee;
|
|
8820
|
-
if (callee.type !==
|
|
9088
|
+
if (callee.type !== AST_NODE_TYPES44.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES44.Identifier) {
|
|
8821
9089
|
return null;
|
|
8822
9090
|
}
|
|
8823
9091
|
const matcher = callee.property.name;
|
|
8824
9092
|
const expectCall = callee.object;
|
|
8825
|
-
if (expectCall.type !==
|
|
9093
|
+
if (expectCall.type !== AST_NODE_TYPES44.CallExpression || expectCall.callee.type !== AST_NODE_TYPES44.Identifier || expectCall.callee.name !== "expect" || expectCall.arguments.length !== 1) {
|
|
8826
9094
|
return null;
|
|
8827
9095
|
}
|
|
8828
9096
|
const actual = expectCall.arguments[0];
|
|
8829
|
-
if (actual === void 0 || actual.type !==
|
|
9097
|
+
if (actual === void 0 || actual.type !== AST_NODE_TYPES44.MemberExpression || actual.optional) {
|
|
8830
9098
|
return null;
|
|
8831
9099
|
}
|
|
8832
9100
|
if (!isPureReceiver(actual.object)) {
|
|
@@ -8840,7 +9108,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8840
9108
|
}
|
|
8841
9109
|
key = { kind: "index", index };
|
|
8842
9110
|
} else {
|
|
8843
|
-
if (actual.property.type !==
|
|
9111
|
+
if (actual.property.type !== AST_NODE_TYPES44.Identifier || COLLECTION_PROPERTIES.has(actual.property.name) || LITERAL_KEY_HAZARDS.has(actual.property.name)) {
|
|
8844
9112
|
return null;
|
|
8845
9113
|
}
|
|
8846
9114
|
key = { kind: "property", name: actual.property.name };
|
|
@@ -8852,7 +9120,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8852
9120
|
return null;
|
|
8853
9121
|
}
|
|
8854
9122
|
const expected = call.arguments[0];
|
|
8855
|
-
if (call.arguments.length !== 1 || expected === void 0 || expected.type ===
|
|
9123
|
+
if (call.arguments.length !== 1 || expected === void 0 || expected.type === AST_NODE_TYPES44.SpreadElement) {
|
|
8856
9124
|
return null;
|
|
8857
9125
|
}
|
|
8858
9126
|
const literal = literalText(expected, (node) => sourceCode.getText(node));
|
|
@@ -8967,7 +9235,7 @@ var prefer_whole_object_assertion_default = createRule({
|
|
|
8967
9235
|
});
|
|
8968
9236
|
|
|
8969
9237
|
// src/rules/prefer-zod-enum.ts
|
|
8970
|
-
import { AST_NODE_TYPES as
|
|
9238
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES45 } from "@typescript-eslint/utils";
|
|
8971
9239
|
var prefer_zod_enum_default = createRule({
|
|
8972
9240
|
name: "prefer-zod-enum",
|
|
8973
9241
|
meta: {
|
|
@@ -8987,25 +9255,25 @@ var prefer_zod_enum_default = createRule({
|
|
|
8987
9255
|
const zodNamespaces = /* @__PURE__ */ new Set();
|
|
8988
9256
|
function enumValues(node) {
|
|
8989
9257
|
const callee = node.callee;
|
|
8990
|
-
if (callee.type !==
|
|
9258
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.computed || callee.object.type !== AST_NODE_TYPES45.Identifier || !zodNamespaces.has(callee.object.name) || callee.property.type !== AST_NODE_TYPES45.Identifier || callee.property.name !== "union" || node.arguments.length !== 1) {
|
|
8991
9259
|
return null;
|
|
8992
9260
|
}
|
|
8993
9261
|
const argument = node.arguments[0];
|
|
8994
|
-
if (argument === void 0 || argument.type !==
|
|
9262
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES45.ArrayExpression || argument.elements.length === 0) {
|
|
8995
9263
|
return null;
|
|
8996
9264
|
}
|
|
8997
9265
|
const values = [];
|
|
8998
9266
|
let canFix = true;
|
|
8999
9267
|
for (const element of argument.elements) {
|
|
9000
|
-
if (element?.type ===
|
|
9268
|
+
if (element?.type === AST_NODE_TYPES45.SpreadElement) {
|
|
9001
9269
|
canFix = false;
|
|
9002
9270
|
continue;
|
|
9003
9271
|
}
|
|
9004
|
-
if (element === null || element.type !==
|
|
9272
|
+
if (element === null || element.type !== AST_NODE_TYPES45.CallExpression || element.callee.type !== AST_NODE_TYPES45.MemberExpression || element.callee.computed || element.callee.object.type !== AST_NODE_TYPES45.Identifier || !zodNamespaces.has(element.callee.object.name) || element.callee.property.type !== AST_NODE_TYPES45.Identifier || element.callee.property.name !== "literal") {
|
|
9005
9273
|
return null;
|
|
9006
9274
|
}
|
|
9007
9275
|
const value = element.arguments[0];
|
|
9008
|
-
if (element.arguments.length !== 1 || value === void 0 || value.type !==
|
|
9276
|
+
if (element.arguments.length !== 1 || value === void 0 || value.type !== AST_NODE_TYPES45.Literal || typeof value.value !== "string") {
|
|
9009
9277
|
canFix = false;
|
|
9010
9278
|
continue;
|
|
9011
9279
|
}
|
|
@@ -9015,11 +9283,11 @@ var prefer_zod_enum_default = createRule({
|
|
|
9015
9283
|
}
|
|
9016
9284
|
function buildFix(node, values) {
|
|
9017
9285
|
const argument = node.arguments[0];
|
|
9018
|
-
if (argument === void 0 || argument.type !==
|
|
9286
|
+
if (argument === void 0 || argument.type !== AST_NODE_TYPES45.ArrayExpression || sourceCode.getCommentsInside(argument).length > 0) {
|
|
9019
9287
|
return void 0;
|
|
9020
9288
|
}
|
|
9021
9289
|
const callee = node.callee;
|
|
9022
|
-
if (callee.type !==
|
|
9290
|
+
if (callee.type !== AST_NODE_TYPES45.MemberExpression || callee.property.type !== AST_NODE_TYPES45.Identifier) {
|
|
9023
9291
|
return void 0;
|
|
9024
9292
|
}
|
|
9025
9293
|
return (fixer) => [
|
|
@@ -9036,7 +9304,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9036
9304
|
return;
|
|
9037
9305
|
}
|
|
9038
9306
|
for (const specifier of node.specifiers) {
|
|
9039
|
-
if (specifier.type ===
|
|
9307
|
+
if (specifier.type === AST_NODE_TYPES45.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES45.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES45.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES45.Identifier && specifier.imported.name === "z") {
|
|
9040
9308
|
zodNamespaces.add(specifier.local.name);
|
|
9041
9309
|
}
|
|
9042
9310
|
}
|
|
@@ -9058,7 +9326,7 @@ var prefer_zod_enum_default = createRule({
|
|
|
9058
9326
|
});
|
|
9059
9327
|
|
|
9060
9328
|
// src/rules/prefer-zod-infer.ts
|
|
9061
|
-
import { AST_NODE_TYPES as
|
|
9329
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES46 } from "@typescript-eslint/utils";
|
|
9062
9330
|
var SHAPE_PRESERVING_METHODS = /* @__PURE__ */ new Set([
|
|
9063
9331
|
"describe",
|
|
9064
9332
|
"refine",
|
|
@@ -9095,44 +9363,44 @@ var ZOD_TYPE_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
9095
9363
|
"Schema"
|
|
9096
9364
|
]);
|
|
9097
9365
|
var LEAF_NODE_TYPES = {
|
|
9098
|
-
string: [
|
|
9099
|
-
email: [
|
|
9100
|
-
url: [
|
|
9101
|
-
uuid: [
|
|
9102
|
-
ulid: [
|
|
9103
|
-
cuid: [
|
|
9104
|
-
cuid2: [
|
|
9105
|
-
nanoid: [
|
|
9106
|
-
iso: [
|
|
9107
|
-
number: [
|
|
9108
|
-
int: [
|
|
9109
|
-
float32: [
|
|
9110
|
-
float64: [
|
|
9111
|
-
boolean: [
|
|
9112
|
-
bigint: [
|
|
9113
|
-
symbol: [
|
|
9114
|
-
any: [
|
|
9115
|
-
unknown: [
|
|
9116
|
-
never: [
|
|
9117
|
-
void: [
|
|
9118
|
-
null: [
|
|
9119
|
-
undefined: [
|
|
9120
|
-
literal: [
|
|
9121
|
-
date: [
|
|
9122
|
-
array: [
|
|
9123
|
-
tuple: [
|
|
9124
|
-
object: [
|
|
9125
|
-
strictObject: [
|
|
9126
|
-
looseObject: [
|
|
9127
|
-
record: [
|
|
9128
|
-
map: [
|
|
9129
|
-
set: [
|
|
9130
|
-
promise: [
|
|
9131
|
-
enum: [
|
|
9132
|
-
nativeEnum: [
|
|
9133
|
-
union: [
|
|
9134
|
-
discriminatedUnion: [
|
|
9135
|
-
intersection: [
|
|
9366
|
+
string: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9367
|
+
email: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9368
|
+
url: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9369
|
+
uuid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9370
|
+
ulid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9371
|
+
cuid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9372
|
+
cuid2: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9373
|
+
nanoid: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9374
|
+
iso: [AST_NODE_TYPES46.TSStringKeyword],
|
|
9375
|
+
number: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9376
|
+
int: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9377
|
+
float32: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9378
|
+
float64: [AST_NODE_TYPES46.TSNumberKeyword],
|
|
9379
|
+
boolean: [AST_NODE_TYPES46.TSBooleanKeyword],
|
|
9380
|
+
bigint: [AST_NODE_TYPES46.TSBigIntKeyword],
|
|
9381
|
+
symbol: [AST_NODE_TYPES46.TSSymbolKeyword],
|
|
9382
|
+
any: [AST_NODE_TYPES46.TSAnyKeyword],
|
|
9383
|
+
unknown: [AST_NODE_TYPES46.TSUnknownKeyword],
|
|
9384
|
+
never: [AST_NODE_TYPES46.TSNeverKeyword],
|
|
9385
|
+
void: [AST_NODE_TYPES46.TSVoidKeyword],
|
|
9386
|
+
null: [AST_NODE_TYPES46.TSNullKeyword],
|
|
9387
|
+
undefined: [AST_NODE_TYPES46.TSUndefinedKeyword],
|
|
9388
|
+
literal: [AST_NODE_TYPES46.TSLiteralType],
|
|
9389
|
+
date: [AST_NODE_TYPES46.TSTypeReference],
|
|
9390
|
+
array: [AST_NODE_TYPES46.TSArrayType, AST_NODE_TYPES46.TSTypeReference],
|
|
9391
|
+
tuple: [AST_NODE_TYPES46.TSTupleType],
|
|
9392
|
+
object: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9393
|
+
strictObject: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9394
|
+
looseObject: [AST_NODE_TYPES46.TSTypeLiteral, AST_NODE_TYPES46.TSTypeReference],
|
|
9395
|
+
record: [AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSTypeLiteral],
|
|
9396
|
+
map: [AST_NODE_TYPES46.TSTypeReference],
|
|
9397
|
+
set: [AST_NODE_TYPES46.TSTypeReference],
|
|
9398
|
+
promise: [AST_NODE_TYPES46.TSTypeReference],
|
|
9399
|
+
enum: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSLiteralType],
|
|
9400
|
+
nativeEnum: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference, AST_NODE_TYPES46.TSLiteralType],
|
|
9401
|
+
union: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference],
|
|
9402
|
+
discriminatedUnion: [AST_NODE_TYPES46.TSUnionType, AST_NODE_TYPES46.TSTypeReference],
|
|
9403
|
+
intersection: [AST_NODE_TYPES46.TSIntersectionType, AST_NODE_TYPES46.TSTypeReference]
|
|
9136
9404
|
};
|
|
9137
9405
|
function normalizeSchemaName(name) {
|
|
9138
9406
|
return name.replace(/Schema$/i, "").replace(/^Z(?=[A-Z])/, "").toLowerCase();
|
|
@@ -9141,20 +9409,20 @@ function normalizeTypeName(name) {
|
|
|
9141
9409
|
return name.replace(/Type$/, "").toLowerCase();
|
|
9142
9410
|
}
|
|
9143
9411
|
function unwrapNullish(annotation) {
|
|
9144
|
-
if (annotation.type !==
|
|
9412
|
+
if (annotation.type !== AST_NODE_TYPES46.TSUnionType) {
|
|
9145
9413
|
return {
|
|
9146
9414
|
core: annotation,
|
|
9147
|
-
nullable: annotation.type ===
|
|
9415
|
+
nullable: annotation.type === AST_NODE_TYPES46.TSNullKeyword
|
|
9148
9416
|
};
|
|
9149
9417
|
}
|
|
9150
9418
|
const rest = [];
|
|
9151
9419
|
let nullable = false;
|
|
9152
9420
|
for (const member of annotation.types) {
|
|
9153
|
-
if (member.type ===
|
|
9421
|
+
if (member.type === AST_NODE_TYPES46.TSNullKeyword) {
|
|
9154
9422
|
nullable = true;
|
|
9155
9423
|
continue;
|
|
9156
9424
|
}
|
|
9157
|
-
if (member.type ===
|
|
9425
|
+
if (member.type === AST_NODE_TYPES46.TSUndefinedKeyword) {
|
|
9158
9426
|
continue;
|
|
9159
9427
|
}
|
|
9160
9428
|
rest.push(member);
|
|
@@ -9219,14 +9487,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9219
9487
|
function zodCallChain(node) {
|
|
9220
9488
|
const chain = [];
|
|
9221
9489
|
let current = node;
|
|
9222
|
-
while (current.type ===
|
|
9490
|
+
while (current.type === AST_NODE_TYPES46.CallExpression) {
|
|
9223
9491
|
const callee = current.callee;
|
|
9224
|
-
if (callee.type !==
|
|
9492
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9225
9493
|
return null;
|
|
9226
9494
|
}
|
|
9227
9495
|
chain.push(current);
|
|
9228
9496
|
const receiver = callee.object;
|
|
9229
|
-
if (receiver.type ===
|
|
9497
|
+
if (receiver.type === AST_NODE_TYPES46.Identifier) {
|
|
9230
9498
|
return zodNamespaces.has(receiver.name) ? chain.reverse() : null;
|
|
9231
9499
|
}
|
|
9232
9500
|
current = receiver;
|
|
@@ -9235,19 +9503,19 @@ var prefer_zod_infer_default = createRule({
|
|
|
9235
9503
|
}
|
|
9236
9504
|
function methodName(call) {
|
|
9237
9505
|
const callee = call.callee;
|
|
9238
|
-
return callee.type ===
|
|
9506
|
+
return callee.type === AST_NODE_TYPES46.MemberExpression && callee.property.type === AST_NODE_TYPES46.Identifier ? callee.property.name : "";
|
|
9239
9507
|
}
|
|
9240
9508
|
function schemaField(node) {
|
|
9241
9509
|
const modifiers = [];
|
|
9242
9510
|
let current = node;
|
|
9243
9511
|
let leaf = null;
|
|
9244
|
-
while (current.type ===
|
|
9512
|
+
while (current.type === AST_NODE_TYPES46.CallExpression) {
|
|
9245
9513
|
const callee = current.callee;
|
|
9246
|
-
if (callee.type !==
|
|
9514
|
+
if (callee.type !== AST_NODE_TYPES46.MemberExpression || callee.computed || callee.property.type !== AST_NODE_TYPES46.Identifier) {
|
|
9247
9515
|
break;
|
|
9248
9516
|
}
|
|
9249
9517
|
const receiver = callee.object;
|
|
9250
|
-
if (receiver.type ===
|
|
9518
|
+
if (receiver.type === AST_NODE_TYPES46.Identifier && zodNamespaces.has(receiver.name)) {
|
|
9251
9519
|
leaf = callee.property.name;
|
|
9252
9520
|
break;
|
|
9253
9521
|
}
|
|
@@ -9278,16 +9546,16 @@ var prefer_zod_infer_default = createRule({
|
|
|
9278
9546
|
return null;
|
|
9279
9547
|
}
|
|
9280
9548
|
const shape = base.arguments[0];
|
|
9281
|
-
if (shape === void 0 || shape.type !==
|
|
9549
|
+
if (shape === void 0 || shape.type !== AST_NODE_TYPES46.ObjectExpression) {
|
|
9282
9550
|
return null;
|
|
9283
9551
|
}
|
|
9284
9552
|
const fields = /* @__PURE__ */ new Map();
|
|
9285
9553
|
for (const property of shape.properties) {
|
|
9286
|
-
if (property.type !==
|
|
9554
|
+
if (property.type !== AST_NODE_TYPES46.Property || property.computed) {
|
|
9287
9555
|
return null;
|
|
9288
9556
|
}
|
|
9289
9557
|
const { key } = property;
|
|
9290
|
-
const name = key.type ===
|
|
9558
|
+
const name = key.type === AST_NODE_TYPES46.Identifier ? key.name : key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string" ? key.value : null;
|
|
9291
9559
|
if (name === null) {
|
|
9292
9560
|
return null;
|
|
9293
9561
|
}
|
|
@@ -9298,11 +9566,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9298
9566
|
function typeMembers(members) {
|
|
9299
9567
|
const result = /* @__PURE__ */ new Map();
|
|
9300
9568
|
for (const member of members) {
|
|
9301
|
-
if (member.type !==
|
|
9569
|
+
if (member.type !== AST_NODE_TYPES46.TSPropertySignature || member.computed) {
|
|
9302
9570
|
return null;
|
|
9303
9571
|
}
|
|
9304
9572
|
const { key } = member;
|
|
9305
|
-
const name = key.type ===
|
|
9573
|
+
const name = key.type === AST_NODE_TYPES46.Identifier ? key.name : key.type === AST_NODE_TYPES46.Literal && typeof key.value === "string" ? key.value : null;
|
|
9306
9574
|
if (name === null) {
|
|
9307
9575
|
return null;
|
|
9308
9576
|
}
|
|
@@ -9316,8 +9584,8 @@ var prefer_zod_infer_default = createRule({
|
|
|
9316
9584
|
return result.size === 0 ? null : result;
|
|
9317
9585
|
}
|
|
9318
9586
|
function collectConstrainedNames(node) {
|
|
9319
|
-
if (node.type ===
|
|
9320
|
-
if (node.typeName.type ===
|
|
9587
|
+
if (node.type === AST_NODE_TYPES46.TSTypeReference) {
|
|
9588
|
+
if (node.typeName.type === AST_NODE_TYPES46.Identifier) {
|
|
9321
9589
|
constrainedTypeNames.add(node.typeName.name);
|
|
9322
9590
|
}
|
|
9323
9591
|
for (const argument of node.typeArguments?.params ?? []) {
|
|
@@ -9325,11 +9593,11 @@ var prefer_zod_infer_default = createRule({
|
|
|
9325
9593
|
}
|
|
9326
9594
|
return;
|
|
9327
9595
|
}
|
|
9328
|
-
if (node.type ===
|
|
9596
|
+
if (node.type === AST_NODE_TYPES46.TSArrayType) {
|
|
9329
9597
|
collectConstrainedNames(node.elementType);
|
|
9330
9598
|
return;
|
|
9331
9599
|
}
|
|
9332
|
-
if (node.type ===
|
|
9600
|
+
if (node.type === AST_NODE_TYPES46.TSUnionType || node.type === AST_NODE_TYPES46.TSIntersectionType) {
|
|
9333
9601
|
for (const member of node.types) {
|
|
9334
9602
|
collectConstrainedNames(member);
|
|
9335
9603
|
}
|
|
@@ -9373,13 +9641,13 @@ var prefer_zod_infer_default = createRule({
|
|
|
9373
9641
|
return;
|
|
9374
9642
|
}
|
|
9375
9643
|
for (const specifier of node.specifiers) {
|
|
9376
|
-
if (specifier.type ===
|
|
9644
|
+
if (specifier.type === AST_NODE_TYPES46.ImportNamespaceSpecifier || specifier.type === AST_NODE_TYPES46.ImportDefaultSpecifier || specifier.type === AST_NODE_TYPES46.ImportSpecifier && specifier.imported.type === AST_NODE_TYPES46.Identifier && specifier.imported.name === "z") {
|
|
9377
9645
|
zodNamespaces.add(specifier.local.name);
|
|
9378
9646
|
}
|
|
9379
9647
|
}
|
|
9380
9648
|
},
|
|
9381
9649
|
VariableDeclarator(node) {
|
|
9382
|
-
if (node.id.type !==
|
|
9650
|
+
if (node.id.type !== AST_NODE_TYPES46.Identifier || node.init == null) {
|
|
9383
9651
|
return;
|
|
9384
9652
|
}
|
|
9385
9653
|
const fields = schemaFields(node.init);
|
|
@@ -9389,14 +9657,14 @@ var prefer_zod_infer_default = createRule({
|
|
|
9389
9657
|
},
|
|
9390
9658
|
/** Records `XSchema.transform(...)` and equivalent module-level reshaping. */
|
|
9391
9659
|
"MemberExpression[computed=false]"(node) {
|
|
9392
|
-
if (node.object.type ===
|
|
9660
|
+
if (node.object.type === AST_NODE_TYPES46.Identifier && node.property.type === AST_NODE_TYPES46.Identifier && MODULE_LEVEL_RESHAPERS.has(node.property.name)) {
|
|
9393
9661
|
reshapedSchemaNames.add(node.object.name);
|
|
9394
9662
|
}
|
|
9395
9663
|
},
|
|
9396
9664
|
/** Records every type argument carried by a Zod constraint. */
|
|
9397
9665
|
TSTypeReference(node) {
|
|
9398
9666
|
const { typeName } = node;
|
|
9399
|
-
const referenced = typeName.type ===
|
|
9667
|
+
const referenced = typeName.type === AST_NODE_TYPES46.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES46.TSQualifiedName && typeName.right.type === AST_NODE_TYPES46.Identifier ? typeName.right.name : null;
|
|
9400
9668
|
if (referenced === null || !ZOD_TYPE_CONSTRAINTS.has(referenced)) {
|
|
9401
9669
|
return;
|
|
9402
9670
|
}
|
|
@@ -9414,7 +9682,7 @@ var prefer_zod_infer_default = createRule({
|
|
|
9414
9682
|
}
|
|
9415
9683
|
},
|
|
9416
9684
|
TSTypeAliasDeclaration(node) {
|
|
9417
|
-
if (node.typeParameters !== void 0 || node.typeAnnotation.type !==
|
|
9685
|
+
if (node.typeParameters !== void 0 || node.typeAnnotation.type !== AST_NODE_TYPES46.TSTypeLiteral) {
|
|
9418
9686
|
return;
|
|
9419
9687
|
}
|
|
9420
9688
|
const members = typeMembers(node.typeAnnotation.members);
|
|
@@ -9459,10 +9727,10 @@ var prefer_zod_infer_default = createRule({
|
|
|
9459
9727
|
});
|
|
9460
9728
|
|
|
9461
9729
|
// src/rules/require-assert-never.ts
|
|
9462
|
-
import { AST_NODE_TYPES as
|
|
9730
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES47 } from "@typescript-eslint/utils";
|
|
9463
9731
|
var isRuntimeHandlingStatement = (statement) => {
|
|
9464
|
-
if (statement.type ===
|
|
9465
|
-
if (statement.type ===
|
|
9732
|
+
if (statement.type === AST_NODE_TYPES47.EmptyStatement) return false;
|
|
9733
|
+
if (statement.type === AST_NODE_TYPES47.BlockStatement) {
|
|
9466
9734
|
return statement.body.some(isRuntimeHandlingStatement);
|
|
9467
9735
|
}
|
|
9468
9736
|
return true;
|
|
@@ -9478,7 +9746,7 @@ var isCommentOnlyNoopDefault = (defaultCase, sourceCode) => {
|
|
|
9478
9746
|
return colonToken !== null && sourceCode.getCommentsAfter(colonToken).length > 0;
|
|
9479
9747
|
}
|
|
9480
9748
|
const only = defaultCase.consequent[0];
|
|
9481
|
-
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type ===
|
|
9749
|
+
if (only !== void 0 && defaultCase.consequent.length === 1 && only.type === AST_NODE_TYPES47.BlockStatement && only.body.length === 0) {
|
|
9482
9750
|
return sourceCode.getCommentsInside(only).length > 0;
|
|
9483
9751
|
}
|
|
9484
9752
|
return false;
|
|
@@ -9518,7 +9786,7 @@ var require_assert_never_default = createRule({
|
|
|
9518
9786
|
});
|
|
9519
9787
|
|
|
9520
9788
|
// src/rules/require-fetch-timeout.ts
|
|
9521
|
-
import { AST_NODE_TYPES as
|
|
9789
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES48, ASTUtils as ASTUtils4 } from "@typescript-eslint/utils";
|
|
9522
9790
|
var GLOBAL_OBJECTS2 = /* @__PURE__ */ new Set([
|
|
9523
9791
|
"globalThis",
|
|
9524
9792
|
"window",
|
|
@@ -9534,14 +9802,14 @@ function matchesAnyPattern3(filename, patterns) {
|
|
|
9534
9802
|
return false;
|
|
9535
9803
|
}
|
|
9536
9804
|
function initProvablyLacksSignal(init) {
|
|
9537
|
-
if (init.type !==
|
|
9805
|
+
if (init.type !== AST_NODE_TYPES48.ObjectExpression) {
|
|
9538
9806
|
return false;
|
|
9539
9807
|
}
|
|
9540
9808
|
for (const prop of init.properties) {
|
|
9541
|
-
if (prop.type ===
|
|
9809
|
+
if (prop.type === AST_NODE_TYPES48.SpreadElement) {
|
|
9542
9810
|
return false;
|
|
9543
9811
|
}
|
|
9544
|
-
if (prop.key.type ===
|
|
9812
|
+
if (prop.key.type === AST_NODE_TYPES48.Identifier && prop.key.name === "signal" || prop.key.type === AST_NODE_TYPES48.Literal && prop.key.value === "signal") {
|
|
9545
9813
|
return false;
|
|
9546
9814
|
}
|
|
9547
9815
|
if (prop.computed) {
|
|
@@ -9551,7 +9819,7 @@ function initProvablyLacksSignal(init) {
|
|
|
9551
9819
|
return true;
|
|
9552
9820
|
}
|
|
9553
9821
|
function isStringish(node) {
|
|
9554
|
-
return node.type ===
|
|
9822
|
+
return node.type === AST_NODE_TYPES48.Literal && typeof node.value === "string" || node.type === AST_NODE_TYPES48.TemplateLiteral;
|
|
9555
9823
|
}
|
|
9556
9824
|
var require_fetch_timeout_default = createRule({
|
|
9557
9825
|
name: "require-fetch-timeout",
|
|
@@ -9592,10 +9860,10 @@ var require_fetch_timeout_default = createRule({
|
|
|
9592
9860
|
return variable === null || variable.defs.length === 0;
|
|
9593
9861
|
}
|
|
9594
9862
|
function isGlobalFetchCall2(callee) {
|
|
9595
|
-
if (callee.type ===
|
|
9863
|
+
if (callee.type === AST_NODE_TYPES48.Identifier) {
|
|
9596
9864
|
return callee.name === "fetch" && resolvesToGlobal(callee);
|
|
9597
9865
|
}
|
|
9598
|
-
return callee.type ===
|
|
9866
|
+
return callee.type === AST_NODE_TYPES48.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES48.Identifier && callee.property.name === "fetch" && callee.object.type === AST_NODE_TYPES48.Identifier && GLOBAL_OBJECTS2.has(callee.object.name) && resolvesToGlobal(callee.object);
|
|
9599
9867
|
}
|
|
9600
9868
|
return {
|
|
9601
9869
|
CallExpression(node) {
|
|
@@ -9615,7 +9883,7 @@ var require_fetch_timeout_default = createRule({
|
|
|
9615
9883
|
});
|
|
9616
9884
|
|
|
9617
9885
|
// src/rules/require-interface-for-injected-service.ts
|
|
9618
|
-
import { AST_NODE_TYPES as
|
|
9886
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES49 } from "@typescript-eslint/utils";
|
|
9619
9887
|
var CONFIGISH_TYPE_RE = /(?:Options|Opts|Config|Configuration|Settings|Params|Props|Args|Env|Environment|Callbacks|Flags)$/;
|
|
9620
9888
|
var CONFIGISH_NAME_RE = /^(?:options|opts|config|configuration|settings|params|props|args|env|environment|callbacks|flags|logger|log|clock)$/i;
|
|
9621
9889
|
var HTTP_TRANSPORT_TYPE_RE = /^(?:KyInstance|AxiosInstance|Session)$/;
|
|
@@ -9623,20 +9891,20 @@ var BUILTIN_CONTAINER_TYPE_RE = /^(?:Record|Map|WeakMap|Set|WeakSet|Array|Readon
|
|
|
9623
9891
|
var TRANSPORT_WRAPPER_NAME_RE = /Client$/;
|
|
9624
9892
|
var ROUTER_FACTORY_NAME = "Router";
|
|
9625
9893
|
var FRAMEWORK_HTTP_TYPES = /* @__PURE__ */ new Set(["Request", "Response", "NextFunction"]);
|
|
9626
|
-
var isExportedClass = (node) => node.parent.type ===
|
|
9627
|
-
var qualifiedName = (name) => name.type ===
|
|
9894
|
+
var isExportedClass = (node) => node.parent.type === AST_NODE_TYPES49.ExportNamedDeclaration || node.parent.type === AST_NODE_TYPES49.ExportDefaultDeclaration;
|
|
9895
|
+
var qualifiedName = (name) => name.type === AST_NODE_TYPES49.Identifier ? name.name : name.type === AST_NODE_TYPES49.TSQualifiedName ? `${qualifiedName(name.left)}.${name.right.name}` : "";
|
|
9628
9896
|
var readTypeReference = (annotation) => {
|
|
9629
|
-
if (annotation === void 0 || annotation.type !==
|
|
9897
|
+
if (annotation === void 0 || annotation.type !== AST_NODE_TYPES49.TSTypeReference) return null;
|
|
9630
9898
|
const { typeName } = annotation;
|
|
9631
|
-
const rightmost = typeName.type ===
|
|
9899
|
+
const rightmost = typeName.type === AST_NODE_TYPES49.Identifier ? typeName.name : typeName.type === AST_NODE_TYPES49.TSQualifiedName ? typeName.right.name : null;
|
|
9632
9900
|
if (rightmost === null) return null;
|
|
9633
9901
|
return { typeName: rightmost, display: qualifiedName(typeName) };
|
|
9634
9902
|
};
|
|
9635
9903
|
var namedParameterCollaborator = (annotated) => {
|
|
9636
9904
|
let target = annotated;
|
|
9637
|
-
if (target.type ===
|
|
9638
|
-
if (target.type ===
|
|
9639
|
-
if (target.type !==
|
|
9905
|
+
if (target.type === AST_NODE_TYPES49.TSParameterProperty) target = target.parameter;
|
|
9906
|
+
if (target.type === AST_NODE_TYPES49.AssignmentPattern) target = target.left;
|
|
9907
|
+
if (target.type !== AST_NODE_TYPES49.Identifier) return null;
|
|
9640
9908
|
const reference = readTypeReference(target.typeAnnotation?.typeAnnotation);
|
|
9641
9909
|
if (reference === null) return null;
|
|
9642
9910
|
return { name: target.name, ...reference };
|
|
@@ -9644,8 +9912,8 @@ var namedParameterCollaborator = (annotated) => {
|
|
|
9644
9912
|
var propertySignatureTypes = (members) => {
|
|
9645
9913
|
const types = /* @__PURE__ */ new Map();
|
|
9646
9914
|
for (const member of members) {
|
|
9647
|
-
if (member.type !==
|
|
9648
|
-
if (member.computed || member.key.type !==
|
|
9915
|
+
if (member.type !== AST_NODE_TYPES49.TSPropertySignature) continue;
|
|
9916
|
+
if (member.computed || member.key.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9649
9917
|
const reference = readTypeReference(member.typeAnnotation?.typeAnnotation);
|
|
9650
9918
|
if (reference === null) continue;
|
|
9651
9919
|
types.set(member.key.name, reference);
|
|
@@ -9656,18 +9924,18 @@ var fileTypeIndex = (program) => {
|
|
|
9656
9924
|
const objects = /* @__PURE__ */ new Map();
|
|
9657
9925
|
const functionAliases = /* @__PURE__ */ new Set();
|
|
9658
9926
|
for (const statement of program.body) {
|
|
9659
|
-
const declaration = statement.type ===
|
|
9660
|
-
if (declaration?.type ===
|
|
9927
|
+
const declaration = statement.type === AST_NODE_TYPES49.ExportNamedDeclaration ? statement.declaration : statement;
|
|
9928
|
+
if (declaration?.type === AST_NODE_TYPES49.TSInterfaceDeclaration) {
|
|
9661
9929
|
objects.set(declaration.id.name, propertySignatureTypes(declaration.body.body));
|
|
9662
9930
|
continue;
|
|
9663
9931
|
}
|
|
9664
|
-
if (declaration?.type !==
|
|
9932
|
+
if (declaration?.type !== AST_NODE_TYPES49.TSTypeAliasDeclaration) continue;
|
|
9665
9933
|
const aliased = declaration.typeAnnotation;
|
|
9666
|
-
if (aliased.type ===
|
|
9934
|
+
if (aliased.type === AST_NODE_TYPES49.TSFunctionType || aliased.type === AST_NODE_TYPES49.TSConstructorType) {
|
|
9667
9935
|
functionAliases.add(declaration.id.name);
|
|
9668
9936
|
continue;
|
|
9669
9937
|
}
|
|
9670
|
-
const literals = aliased.type ===
|
|
9938
|
+
const literals = aliased.type === AST_NODE_TYPES49.TSTypeLiteral ? [aliased] : aliased.type === AST_NODE_TYPES49.TSIntersectionType ? aliased.types.filter((part) => part.type === AST_NODE_TYPES49.TSTypeLiteral) : [];
|
|
9671
9939
|
if (literals.length === 0) continue;
|
|
9672
9940
|
const merged = /* @__PURE__ */ new Map();
|
|
9673
9941
|
for (const literal of literals) {
|
|
@@ -9680,10 +9948,10 @@ var fileTypeIndex = (program) => {
|
|
|
9680
9948
|
return { objects, functionAliases };
|
|
9681
9949
|
};
|
|
9682
9950
|
var bagMemberTypes = (annotation, declared) => {
|
|
9683
|
-
if (annotation.type ===
|
|
9951
|
+
if (annotation.type === AST_NODE_TYPES49.TSTypeLiteral) {
|
|
9684
9952
|
return propertySignatureTypes(annotation.members);
|
|
9685
9953
|
}
|
|
9686
|
-
if (annotation.type !==
|
|
9954
|
+
if (annotation.type !== AST_NODE_TYPES49.TSTypeReference || annotation.typeName.type !== AST_NODE_TYPES49.Identifier) {
|
|
9687
9955
|
return null;
|
|
9688
9956
|
}
|
|
9689
9957
|
return declared().objects.get(annotation.typeName.name) ?? null;
|
|
@@ -9695,11 +9963,11 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9695
9963
|
if (members === null) return [];
|
|
9696
9964
|
const collaborators = [];
|
|
9697
9965
|
for (const property of pattern.properties) {
|
|
9698
|
-
if (property.type !==
|
|
9699
|
-
if (property.key.type !==
|
|
9966
|
+
if (property.type !== AST_NODE_TYPES49.Property || property.computed) continue;
|
|
9967
|
+
if (property.key.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9700
9968
|
const key = property.key.name;
|
|
9701
|
-
const bound = property.value.type ===
|
|
9702
|
-
if (bound.type !==
|
|
9969
|
+
const bound = property.value.type === AST_NODE_TYPES49.AssignmentPattern ? property.value.left : property.value;
|
|
9970
|
+
if (bound.type !== AST_NODE_TYPES49.Identifier) continue;
|
|
9703
9971
|
if (CONFIGISH_NAME_RE.test(key)) continue;
|
|
9704
9972
|
const reference = members.get(key);
|
|
9705
9973
|
if (reference === void 0) continue;
|
|
@@ -9709,8 +9977,8 @@ var objectPatternCollaborators = (pattern, declared) => {
|
|
|
9709
9977
|
};
|
|
9710
9978
|
var parameterCollaborators = (parameter, declared) => {
|
|
9711
9979
|
let target = parameter;
|
|
9712
|
-
if (target.type ===
|
|
9713
|
-
if (target.type ===
|
|
9980
|
+
if (target.type === AST_NODE_TYPES49.AssignmentPattern) target = target.left;
|
|
9981
|
+
if (target.type === AST_NODE_TYPES49.ObjectPattern) {
|
|
9714
9982
|
return objectPatternCollaborators(target, declared);
|
|
9715
9983
|
}
|
|
9716
9984
|
const named2 = namedParameterCollaborator(parameter);
|
|
@@ -9729,17 +9997,17 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9729
9997
|
let constructedFields = 0;
|
|
9730
9998
|
if (body2 !== null && body2 !== void 0) {
|
|
9731
9999
|
for (const statement of body2.body) {
|
|
9732
|
-
if (statement.type !==
|
|
10000
|
+
if (statement.type !== AST_NODE_TYPES49.ExpressionStatement) continue;
|
|
9733
10001
|
const expression = statement.expression;
|
|
9734
|
-
if (expression.type !==
|
|
10002
|
+
if (expression.type !== AST_NODE_TYPES49.AssignmentExpression || expression.operator !== "=" || expression.left.type !== AST_NODE_TYPES49.MemberExpression || expression.left.object.type !== AST_NODE_TYPES49.ThisExpression) {
|
|
9735
10003
|
continue;
|
|
9736
10004
|
}
|
|
9737
10005
|
const source = expression.right;
|
|
9738
|
-
if (source.type ===
|
|
10006
|
+
if (source.type === AST_NODE_TYPES49.NewExpression) {
|
|
9739
10007
|
constructedFields += 1;
|
|
9740
|
-
} else if (source.type ===
|
|
10008
|
+
} else if (source.type === AST_NODE_TYPES49.Identifier) {
|
|
9741
10009
|
storedFrom.add(source.name);
|
|
9742
|
-
} else if (source.type ===
|
|
10010
|
+
} else if (source.type === AST_NODE_TYPES49.MemberExpression && source.object.type === AST_NODE_TYPES49.Identifier) {
|
|
9743
10011
|
storedFrom.add(source.object.name);
|
|
9744
10012
|
}
|
|
9745
10013
|
}
|
|
@@ -9747,7 +10015,7 @@ var readConstructor = (ctor, declared, typeParameters) => {
|
|
|
9747
10015
|
const collaborators = [];
|
|
9748
10016
|
for (const parameter of ctor.value.params) {
|
|
9749
10017
|
for (const reference of parameterCollaborators(parameter, declared)) {
|
|
9750
|
-
const stored = parameter.type ===
|
|
10018
|
+
const stored = parameter.type === AST_NODE_TYPES49.TSParameterProperty || storedFrom.has(reference.name);
|
|
9751
10019
|
if (!stored) continue;
|
|
9752
10020
|
if (CONFIGISH_TYPE_RE.test(reference.typeName)) continue;
|
|
9753
10021
|
if (CONFIGISH_NAME_RE.test(reference.name)) continue;
|
|
@@ -9781,19 +10049,19 @@ var subtreeHas = (root, found) => {
|
|
|
9781
10049
|
return hit;
|
|
9782
10050
|
};
|
|
9783
10051
|
var isFrameworkWiring = (body2) => subtreeHas(body2, (node) => {
|
|
9784
|
-
if (node.type ===
|
|
10052
|
+
if (node.type === AST_NODE_TYPES49.CallExpression) {
|
|
9785
10053
|
const { callee } = node;
|
|
9786
|
-
if (callee.type ===
|
|
9787
|
-
return callee.type ===
|
|
10054
|
+
if (callee.type === AST_NODE_TYPES49.Identifier) return callee.name === ROUTER_FACTORY_NAME;
|
|
10055
|
+
return callee.type === AST_NODE_TYPES49.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES49.Identifier && callee.property.name === ROUTER_FACTORY_NAME;
|
|
9788
10056
|
}
|
|
9789
|
-
return node.type ===
|
|
10057
|
+
return node.type === AST_NODE_TYPES49.TSTypeReference && node.typeName.type === AST_NODE_TYPES49.TSQualifiedName && FRAMEWORK_HTTP_TYPES.has(node.typeName.right.name);
|
|
9790
10058
|
});
|
|
9791
10059
|
var stem2 = (name) => name.replace(/^I(?=[A-Z])/, "").replace(/Impl$/, "");
|
|
9792
10060
|
var fileInterfaceNames = (program) => {
|
|
9793
10061
|
const names = [];
|
|
9794
10062
|
for (const statement of program.body) {
|
|
9795
|
-
const declaration = statement.type ===
|
|
9796
|
-
if (declaration?.type ===
|
|
10063
|
+
const declaration = statement.type === AST_NODE_TYPES49.ExportNamedDeclaration ? statement.declaration : statement;
|
|
10064
|
+
if (declaration?.type === AST_NODE_TYPES49.TSInterfaceDeclaration) names.push(declaration.id.name);
|
|
9797
10065
|
}
|
|
9798
10066
|
return names;
|
|
9799
10067
|
};
|
|
@@ -9811,11 +10079,11 @@ var isTransportWrapper = (className, collaborators, program) => {
|
|
|
9811
10079
|
var publicMethodNames = (body2) => {
|
|
9812
10080
|
const names = [];
|
|
9813
10081
|
for (const member of body2.body) {
|
|
9814
|
-
if (member.type !==
|
|
10082
|
+
if (member.type !== AST_NODE_TYPES49.MethodDefinition) continue;
|
|
9815
10083
|
if (member.kind !== "method" || member.static) continue;
|
|
9816
10084
|
if (member.accessibility === "private" || member.accessibility === "protected") continue;
|
|
9817
|
-
if (member.key.type ===
|
|
9818
|
-
if (member.key.type ===
|
|
10085
|
+
if (member.key.type === AST_NODE_TYPES49.PrivateIdentifier) continue;
|
|
10086
|
+
if (member.key.type === AST_NODE_TYPES49.Identifier) names.push(member.key.name);
|
|
9819
10087
|
else names.push("\u2026");
|
|
9820
10088
|
}
|
|
9821
10089
|
return names;
|
|
@@ -9848,7 +10116,7 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9848
10116
|
if (node.implements.length > 0) return;
|
|
9849
10117
|
if (node.decorators.length > 0) return;
|
|
9850
10118
|
const ctor = node.body.body.find(
|
|
9851
|
-
(member) => member.type ===
|
|
10119
|
+
(member) => member.type === AST_NODE_TYPES49.MethodDefinition && member.kind === "constructor"
|
|
9852
10120
|
);
|
|
9853
10121
|
if (ctor === void 0) return;
|
|
9854
10122
|
const { collaborators, constructedFields } = readConstructor(
|
|
@@ -9877,37 +10145,37 @@ var require_interface_for_injected_service_default = createRule({
|
|
|
9877
10145
|
});
|
|
9878
10146
|
|
|
9879
10147
|
// src/rules/require-static-next-matcher.ts
|
|
9880
|
-
import { AST_NODE_TYPES as
|
|
10148
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES50 } from "@typescript-eslint/utils";
|
|
9881
10149
|
var NEXT_ENTRY_FILE = /(?:^|[/\\])(?:middleware|proxy)\.[cm]?[jt]sx?$/u;
|
|
9882
|
-
function
|
|
9883
|
-
if (node.type ===
|
|
9884
|
-
return
|
|
10150
|
+
function unwrapExpression2(node) {
|
|
10151
|
+
if (node.type === AST_NODE_TYPES50.TSAsExpression || node.type === AST_NODE_TYPES50.TSSatisfiesExpression || node.type === AST_NODE_TYPES50.TSNonNullExpression || node.type === AST_NODE_TYPES50.TSTypeAssertion) {
|
|
10152
|
+
return unwrapExpression2(node.expression);
|
|
9885
10153
|
}
|
|
9886
10154
|
return node;
|
|
9887
10155
|
}
|
|
9888
10156
|
function isStaticValue(node) {
|
|
9889
|
-
const value =
|
|
9890
|
-
if (value.type ===
|
|
10157
|
+
const value = unwrapExpression2(node);
|
|
10158
|
+
if (value.type === AST_NODE_TYPES50.Literal) {
|
|
9891
10159
|
return true;
|
|
9892
10160
|
}
|
|
9893
|
-
if (value.type ===
|
|
10161
|
+
if (value.type === AST_NODE_TYPES50.TemplateLiteral) {
|
|
9894
10162
|
return value.expressions.length === 0;
|
|
9895
10163
|
}
|
|
9896
|
-
if (value.type ===
|
|
10164
|
+
if (value.type === AST_NODE_TYPES50.ArrayExpression) {
|
|
9897
10165
|
return value.elements.every(
|
|
9898
|
-
(element) => element !== null && element.type !==
|
|
10166
|
+
(element) => element !== null && element.type !== AST_NODE_TYPES50.SpreadElement && isStaticValue(element)
|
|
9899
10167
|
);
|
|
9900
10168
|
}
|
|
9901
|
-
if (value.type ===
|
|
10169
|
+
if (value.type === AST_NODE_TYPES50.ObjectExpression) {
|
|
9902
10170
|
return value.properties.every(
|
|
9903
|
-
(property) => property.type ===
|
|
10171
|
+
(property) => property.type === AST_NODE_TYPES50.Property && property.kind === "init" && !property.computed && property.value.type !== AST_NODE_TYPES50.AssignmentPattern && isStaticValue(property.value)
|
|
9904
10172
|
);
|
|
9905
10173
|
}
|
|
9906
10174
|
return false;
|
|
9907
10175
|
}
|
|
9908
10176
|
function propertyName2(property) {
|
|
9909
10177
|
if (property.computed) return null;
|
|
9910
|
-
if (property.key.type ===
|
|
10178
|
+
if (property.key.type === AST_NODE_TYPES50.Identifier) return property.key.name;
|
|
9911
10179
|
return typeof property.key.value === "string" ? property.key.value : null;
|
|
9912
10180
|
}
|
|
9913
10181
|
var require_static_next_matcher_default = createRule({
|
|
@@ -9929,19 +10197,19 @@ var require_static_next_matcher_default = createRule({
|
|
|
9929
10197
|
}
|
|
9930
10198
|
return {
|
|
9931
10199
|
ExportNamedDeclaration(node) {
|
|
9932
|
-
if (node.declaration?.type !==
|
|
10200
|
+
if (node.declaration?.type !== AST_NODE_TYPES50.VariableDeclaration) {
|
|
9933
10201
|
return;
|
|
9934
10202
|
}
|
|
9935
10203
|
for (const declaration of node.declaration.declarations) {
|
|
9936
|
-
if (declaration.id.type !==
|
|
10204
|
+
if (declaration.id.type !== AST_NODE_TYPES50.Identifier || declaration.id.name !== "config" || declaration.init === null) {
|
|
9937
10205
|
continue;
|
|
9938
10206
|
}
|
|
9939
|
-
const config =
|
|
9940
|
-
if (config.type !==
|
|
10207
|
+
const config = unwrapExpression2(declaration.init);
|
|
10208
|
+
if (config.type !== AST_NODE_TYPES50.ObjectExpression) {
|
|
9941
10209
|
continue;
|
|
9942
10210
|
}
|
|
9943
10211
|
for (const property of config.properties) {
|
|
9944
|
-
if (property.type !==
|
|
10212
|
+
if (property.type !== AST_NODE_TYPES50.Property || propertyName2(property) !== "matcher" || property.value.type === AST_NODE_TYPES50.AssignmentPattern) {
|
|
9945
10213
|
continue;
|
|
9946
10214
|
}
|
|
9947
10215
|
if (!isStaticValue(property.value)) {
|
|
@@ -9955,18 +10223,18 @@ var require_static_next_matcher_default = createRule({
|
|
|
9955
10223
|
});
|
|
9956
10224
|
|
|
9957
10225
|
// src/rules/require-zod-form-validation.ts
|
|
9958
|
-
import { AST_NODE_TYPES as
|
|
10226
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES51 } from "@typescript-eslint/utils";
|
|
9959
10227
|
var looksLikeZodSchema = (node) => {
|
|
9960
10228
|
let current = node;
|
|
9961
10229
|
while (true) {
|
|
9962
|
-
if (current.type ===
|
|
10230
|
+
if (current.type === AST_NODE_TYPES51.Identifier) {
|
|
9963
10231
|
return current.name === "z" || ZOD_SCHEMA_NAME_RE.test(current.name);
|
|
9964
10232
|
}
|
|
9965
|
-
if (current.type ===
|
|
10233
|
+
if (current.type === AST_NODE_TYPES51.CallExpression) {
|
|
9966
10234
|
current = current.callee;
|
|
9967
10235
|
continue;
|
|
9968
10236
|
}
|
|
9969
|
-
if (current.type ===
|
|
10237
|
+
if (current.type === AST_NODE_TYPES51.MemberExpression) {
|
|
9970
10238
|
current = current.object;
|
|
9971
10239
|
continue;
|
|
9972
10240
|
}
|
|
@@ -9974,23 +10242,23 @@ var looksLikeZodSchema = (node) => {
|
|
|
9974
10242
|
}
|
|
9975
10243
|
};
|
|
9976
10244
|
var isZodParseCall = (node) => {
|
|
9977
|
-
if (node.type !==
|
|
10245
|
+
if (node.type !== AST_NODE_TYPES51.CallExpression) return false;
|
|
9978
10246
|
const callee = node.callee;
|
|
9979
|
-
if (callee.type !==
|
|
10247
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return false;
|
|
9980
10248
|
if (callee.computed) return false;
|
|
9981
|
-
if (callee.property.type !==
|
|
10249
|
+
if (callee.property.type !== AST_NODE_TYPES51.Identifier) return false;
|
|
9982
10250
|
const method = callee.property.name;
|
|
9983
10251
|
if (method !== "parse" && method !== "safeParse") return false;
|
|
9984
10252
|
return looksLikeZodSchema(callee.object);
|
|
9985
10253
|
};
|
|
9986
10254
|
var isFormDataMethodCall = (node) => {
|
|
9987
10255
|
let current = node;
|
|
9988
|
-
if (current.type ===
|
|
10256
|
+
if (current.type === AST_NODE_TYPES51.AwaitExpression) {
|
|
9989
10257
|
current = current.argument;
|
|
9990
10258
|
}
|
|
9991
|
-
if (current.type !==
|
|
10259
|
+
if (current.type !== AST_NODE_TYPES51.CallExpression) return false;
|
|
9992
10260
|
const callee = current.callee;
|
|
9993
|
-
return callee.type ===
|
|
10261
|
+
return callee.type === AST_NODE_TYPES51.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES51.Identifier && callee.property.name === "formData";
|
|
9994
10262
|
};
|
|
9995
10263
|
var require_zod_form_validation_default = createRule({
|
|
9996
10264
|
name: "require-zod-form-validation",
|
|
@@ -10010,14 +10278,14 @@ var require_zod_form_validation_default = createRule({
|
|
|
10010
10278
|
return {};
|
|
10011
10279
|
}
|
|
10012
10280
|
const isFormSourceIdentifier = (node) => {
|
|
10013
|
-
if (node.type !==
|
|
10281
|
+
if (node.type !== AST_NODE_TYPES51.Identifier) return false;
|
|
10014
10282
|
if (/formdata/i.test(node.name)) return true;
|
|
10015
10283
|
let scope = context.sourceCode.getScope(node);
|
|
10016
10284
|
while (scope !== null) {
|
|
10017
10285
|
const variable = scope.set.get(node.name);
|
|
10018
10286
|
if (variable !== void 0 && variable.defs.length === 1) {
|
|
10019
10287
|
const def = variable.defs[0];
|
|
10020
|
-
if (def !== void 0 && def.type === "Variable" && def.node.type ===
|
|
10288
|
+
if (def !== void 0 && def.type === "Variable" && def.node.type === AST_NODE_TYPES51.VariableDeclarator && def.node.init !== null) {
|
|
10021
10289
|
return isFormDataMethodCall(def.node.init);
|
|
10022
10290
|
}
|
|
10023
10291
|
return false;
|
|
@@ -10028,8 +10296,8 @@ var require_zod_form_validation_default = createRule({
|
|
|
10028
10296
|
};
|
|
10029
10297
|
const isFormDataGetCall = (node) => {
|
|
10030
10298
|
const callee = node.callee;
|
|
10031
|
-
if (callee.type !==
|
|
10032
|
-
if (callee.property.type !==
|
|
10299
|
+
if (callee.type !== AST_NODE_TYPES51.MemberExpression) return false;
|
|
10300
|
+
if (callee.property.type !== AST_NODE_TYPES51.Identifier || callee.property.name !== "get") {
|
|
10033
10301
|
return false;
|
|
10034
10302
|
}
|
|
10035
10303
|
return isFormSourceIdentifier(callee.object);
|
|
@@ -10044,11 +10312,11 @@ var require_zod_form_validation_default = createRule({
|
|
|
10044
10312
|
};
|
|
10045
10313
|
const isInstanceofNarrowing = (node) => {
|
|
10046
10314
|
const parent = node.parent;
|
|
10047
|
-
return parent !== null && parent !== void 0 && parent.type ===
|
|
10315
|
+
return parent !== null && parent !== void 0 && parent.type === AST_NODE_TYPES51.BinaryExpression && parent.operator === "instanceof" && parent.left === node && parent.right.type === AST_NODE_TYPES51.Identifier && (parent.right.name === "File" || parent.right.name === "Blob");
|
|
10048
10316
|
};
|
|
10049
10317
|
const boundDeclarator = (node) => {
|
|
10050
10318
|
const parent = node.parent;
|
|
10051
|
-
if (parent.type ===
|
|
10319
|
+
if (parent.type === AST_NODE_TYPES51.VariableDeclarator && parent.init === node && parent.id.type === AST_NODE_TYPES51.Identifier) {
|
|
10052
10320
|
return parent;
|
|
10053
10321
|
}
|
|
10054
10322
|
return null;
|
|
@@ -10107,7 +10375,7 @@ var store_insert_requires_on_conflict_default = createRule({
|
|
|
10107
10375
|
});
|
|
10108
10376
|
|
|
10109
10377
|
// src/rules/zod-naming-convention.ts
|
|
10110
|
-
import { AST_NODE_TYPES as
|
|
10378
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES52 } from "@typescript-eslint/utils";
|
|
10111
10379
|
var CONVENTIONS = {
|
|
10112
10380
|
prefix: { test: ZOD_PREFIX_RE, messageId: "zPrefix" },
|
|
10113
10381
|
suffix: { test: ZOD_SUFFIX_RE, messageId: "schemaSuffix" },
|
|
@@ -10132,15 +10400,15 @@ var NON_SCHEMA_TERMINALS = /* @__PURE__ */ new Set([
|
|
|
10132
10400
|
"registry",
|
|
10133
10401
|
"implement"
|
|
10134
10402
|
]);
|
|
10135
|
-
var terminalMethodName = (callee) => !callee.computed && callee.property.type ===
|
|
10403
|
+
var terminalMethodName = (callee) => !callee.computed && callee.property.type === AST_NODE_TYPES52.Identifier ? callee.property.name : null;
|
|
10136
10404
|
var calleeChainStartsWithZ = (node) => {
|
|
10137
10405
|
let current = node;
|
|
10138
|
-
while (current.type ===
|
|
10406
|
+
while (current.type === AST_NODE_TYPES52.MemberExpression) {
|
|
10139
10407
|
const receiver = current.object;
|
|
10140
|
-
if (receiver.type ===
|
|
10408
|
+
if (receiver.type === AST_NODE_TYPES52.Identifier && receiver.name === "z") {
|
|
10141
10409
|
return true;
|
|
10142
10410
|
}
|
|
10143
|
-
if (receiver.type ===
|
|
10411
|
+
if (receiver.type === AST_NODE_TYPES52.CallExpression) {
|
|
10144
10412
|
current = receiver.callee;
|
|
10145
10413
|
continue;
|
|
10146
10414
|
}
|
|
@@ -10185,13 +10453,13 @@ var zod_naming_convention_default = createRule({
|
|
|
10185
10453
|
VariableDeclarator(node) {
|
|
10186
10454
|
const init = node.init;
|
|
10187
10455
|
if (init === null || init === void 0) return;
|
|
10188
|
-
if (init.type !==
|
|
10456
|
+
if (init.type !== AST_NODE_TYPES52.CallExpression) return;
|
|
10189
10457
|
const callee = init.callee;
|
|
10190
|
-
if (callee.type !==
|
|
10458
|
+
if (callee.type !== AST_NODE_TYPES52.MemberExpression) return;
|
|
10191
10459
|
if (!calleeChainStartsWithZ(callee)) return;
|
|
10192
10460
|
const terminal = terminalMethodName(callee);
|
|
10193
10461
|
if (terminal !== null && NON_SCHEMA_TERMINALS.has(terminal)) return;
|
|
10194
|
-
if (node.id.type !==
|
|
10462
|
+
if (node.id.type !== AST_NODE_TYPES52.Identifier) return;
|
|
10195
10463
|
if (test.test(node.id.name)) return;
|
|
10196
10464
|
if (acceptsSchemaWord && CONTAINS_SCHEMA_RE.test(node.id.name)) return;
|
|
10197
10465
|
context.report({
|
|
@@ -10239,7 +10507,7 @@ var retiredRules = {
|
|
|
10239
10507
|
},
|
|
10240
10508
|
"prefer-shadcn": {
|
|
10241
10509
|
removedIn: "3.0.0",
|
|
10242
|
-
reason: "Delete the entry;
|
|
10510
|
+
reason: "Delete the retired entry; application-profile consumers can separately adopt `@sarj/prefer-shadcn-primitives`."
|
|
10243
10511
|
},
|
|
10244
10512
|
"primary-export-file-name": {
|
|
10245
10513
|
removedIn: "4.0.0",
|
|
@@ -10303,6 +10571,8 @@ var rules = {
|
|
|
10303
10571
|
"prefer-constant-time-secret-compare": prefer_constant_time_secret_compare_default,
|
|
10304
10572
|
"prefer-discriminated-union": prefer_discriminated_union_default,
|
|
10305
10573
|
"prefer-input-group-search": prefer_input_group_search_default,
|
|
10574
|
+
"prefer-immutable-module-constant": prefer_immutable_module_constant_default,
|
|
10575
|
+
"prefer-shadcn-primitives": prefer_shadcn_primitives_default,
|
|
10306
10576
|
"prefer-module-level-constant": prefer_module_level_constant_default,
|
|
10307
10577
|
"prefer-module-level-schema": prefer_module_level_schema_default,
|
|
10308
10578
|
"prefer-native-random-uuid": prefer_native_random_uuid_default,
|
|
@@ -10325,11 +10595,12 @@ var rules = {
|
|
|
10325
10595
|
};
|
|
10326
10596
|
var meta = {
|
|
10327
10597
|
name: "@sarj/eslint-plugin",
|
|
10328
|
-
version: "9.
|
|
10598
|
+
version: "9.13.0"
|
|
10329
10599
|
};
|
|
10330
10600
|
var applicationOnlyRules = [
|
|
10331
10601
|
"no-restricted-library-load",
|
|
10332
|
-
"prefer-native-random-uuid"
|
|
10602
|
+
"prefer-native-random-uuid",
|
|
10603
|
+
"prefer-shadcn-primitives"
|
|
10333
10604
|
];
|
|
10334
10605
|
var recommendedRules = {
|
|
10335
10606
|
"@sarj/enforce-file-structure": "warn",
|
|
@@ -10369,6 +10640,7 @@ var recommendedRules = {
|
|
|
10369
10640
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10370
10641
|
"@sarj/prefer-discriminated-union": "warn",
|
|
10371
10642
|
"@sarj/prefer-input-group-search": "error",
|
|
10643
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10372
10644
|
"@sarj/prefer-module-level-constant": "warn",
|
|
10373
10645
|
"@sarj/prefer-module-level-schema": "warn",
|
|
10374
10646
|
"@sarj/prefer-non-nullable-collection": "warn",
|
|
@@ -10430,6 +10702,7 @@ var strictRules = {
|
|
|
10430
10702
|
"@sarj/prefer-constant-time-secret-compare": "error",
|
|
10431
10703
|
"@sarj/prefer-discriminated-union": "error",
|
|
10432
10704
|
"@sarj/prefer-input-group-search": "error",
|
|
10705
|
+
"@sarj/prefer-immutable-module-constant": "warn",
|
|
10433
10706
|
"@sarj/prefer-module-level-constant": "error",
|
|
10434
10707
|
"@sarj/prefer-module-level-schema": "error",
|
|
10435
10708
|
"@sarj/prefer-non-nullable-collection": "error",
|
|
@@ -10480,4 +10753,3 @@ export {
|
|
|
10480
10753
|
rules,
|
|
10481
10754
|
strictRules
|
|
10482
10755
|
};
|
|
10483
|
-
//# sourceMappingURL=index.js.map
|