Files
OpenFrontIO/eslint-plugin-local/rules/no-z-array.js
T
Scott Anderson 2dfd39f316 Enable the @typescript-eslint/no-unsafe-assignment eslint rule (#1832)
## Description:

Enable the `@typescript-eslint/no-unsafe-assignment` eslint rule.

Fixes #1781

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
2025-08-15 21:57:25 -04:00

37 lines
966 B
JavaScript

/* eslint-disable @typescript-eslint/no-unsafe-assignment */
export default {
create(context) {
return {
CallExpression(node) {
if (
node.callee.type === "MemberExpression" &&
node.callee.object.name === "z" &&
node.callee.property.name === "array" &&
node.arguments.length === 1
) {
const argSource = context.sourceCode.getText(node.arguments[0]);
context.report({
data: { type: argSource },
fix(fixer) {
return fixer.replaceText(node, `${argSource}.array()`);
},
messageId: "noZArray",
node,
});
}
},
};
},
meta: {
docs: {
description: "Disallow z.array(type) in favor of type.array()",
},
fixable: "code",
messages: {
noZArray: "Use `{{type}}.array()` instead of `z.array({{type}})`.",
},
schema: [],
type: "suggestion",
},
};