mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 02:47:45 +00:00
2ed0cef65c
## Description: Prefer `type.array()` over `z.array(type)`. ## 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
36 lines
905 B
JavaScript
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",
|
|
},
|
|
};
|