-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prefer-global-this
should allow window.setTimeout()
and setInterval()
#2482
Comments
…tores/routeUpdating.ts` * allow using `<script lang="tsx">` in rule `vue/block-lang` for `<WidgetSelectForum>` @ eslint.config.js $ yarn eslint --fix @ fe
I disagree. The correct way to handle it is: const id: ReturnType<typeof setTimeout> = window.setTimeout(console.log, 100); |
I had this exact issue yesterday 😅 I wish there was a way to instruct the user on how to proceed in cases like this. Should this specific scenario be handled differently? For example:
I also had issues regarding |
prefer-global-this
: should allow window.setTimeout()
and setInterval()
prefer-global-this
should allow window.setTimeout()
and setInterval()
In my scenario I'm storing the let id = import.meta.client ? 0 : import.meta.server ? new NodeJS.Timeout() : ...; for preventing let id: ReturnType<typeof setTimeout> | undefined = undefined; but this will also violates the eslint rule |
You don't need any of that. Just call setTimeout normally. As for the let, the lint rule is right. This is correct: let id: ReturnType<typeof setTimeout> | undefined;
// and then
id = setTimeout()
clearTimeout(id) |
Description
as it's a common workaround: 1, 2, for
globalThis.setTimeout()
andsetInterval()
returningNodeJS.Timeout
in@types/node
Fail
Pass
Additional Info
No response
The text was updated successfully, but these errors were encountered: