-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
New rule: Prevent/warn about the usage of window in favor of self. #8229
Comments
Thanks for the rule suggestion. To continue the Gitter discussion that led to this issue, you can already use |
I'm entirely for that and indeed it seems to be the best course of action. After all the intent here is to enforce a best practice, if this enhancement would allow for that I see no reason for not doing it, plus the obvious added benefit is that it can be used in other similar scenarios. 👍 Should this issue be kept open to move this effort forward or would a new one be required? |
@dryajov If you wouldn't mind editing the first post and title to conform with your new proposal, we can keep using this issue. Thanks! 😄 |
Oops, I thought the issue was already edited, but it hasn't been. 😄 |
@platinumazure , I think there is no confusion, im going to enhance |
@dryajov Haha, that's my mistake then, I thought you had already edited the issue. Sorry about that! |
closing in favor of #8315 |
Please describe what the rule should do:
Prevent/warn about the usage of
window
in favor ofself
, withself
being a proxy to the current global context and should work across all environments in the browser.What category of rule is this? (place an "X" next to just one item)
[ ] Enforces code style
[x] Warns about a potential error
[x] Suggests an alternate way of doing something
[x] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
Why should this rule be included in ESLint (instead of a plugin)?
There is a large surface of non DOM related APIs being added to browsers that work across DOM and non DOM (WebWorker/ServiceWorker) environments. In many cases
window
is used as a reference to the global context to test for the presence of those features which makes it non-portable across non DOM environments. As we move towards browsers with more and more capabilities beyond the DOM, this is going to become more of a problem. An eslint rule should alleviate the transition and enforce a very important best practice, having it as a plugin would mean less penetration and adoption across the board.The text was updated successfully, but these errors were encountered: