Files
Scott Anderson 5aacf5b5be Enable the @typescript-eslint/no-unsafe-member-access eslint rule (#1833)
## Description:

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

Fixes #1783

## 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 22:11:09 -04:00

36 lines
905 B
JavaScript

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",
},
};