-
-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Labels
Description
The rule is obviously meant for promises but it's firing even for the zod's .catch() method which is used to catch a value if no value is provided, completely unrelated to what the rule is created to do.
unicorn/prefer-top-level-await
constschema = z.object({
searchQuery: z.string().catch(""),
// Prefer top-level await over using a promise chain.eslint[unicorn/prefer-top-level-await](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-top-level-await.md)
type: z
.union([z.literal("v1"), z.literal("v2"), z.literal("both")])
.catch("both"),
// Prefer top-level await over using a promise chain.eslint[unicorn/prefer-top-level-await](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-top-level-await.md)
onlyIncentivized: z.boolean().catch(false),
// Prefer top-level await over using a promise chain.eslint[unicorn/prefer-top-level-await](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-top-level-await.md)
});This schema is a very common theme with Tanstack Router's route schemas, so for any project using tanstack router this rule is unusable, or for most projects that use zod.