-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[New] : Avoid unsafe global window use #2692
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good start :-)
a7bfeca
to
6e436a9
Compare
Thanks for your initial review @ljharb. I think it is ready now 🙂 |
6e436a9
to
988eaf1
Compare
i'm interested in this rule or something like it getting published - anything that needs to be done to help it along? |
FYI currently this errors incorrectly:
Alternatively,
Also shadowing
though just giving it a different name works fine. |
also would probably make sense to check for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this also needs handling for hooks in SFCs, to ensure window and whatnot is only used in effects?
I'm not stoked on the use of a class and this
, or all the loops, in the implementation, but that's something we can worry about later.
59af733
to
865ed16
Compare
069314a
to
181c68f
Compare
380e32c
to
51d342b
Compare
This rule will prevent the unsafe use on
window
resulting from rendering React apps in environments where the global is not available.I'll be grateful for getting all your comments and suggestions before summiting the final version.
Tested Conditions
Considerations
The issue talks about disabling the use of various globals variables aside from
window
. I think an easier solution would be to use the rule no-restricted-globals to force the use ofwindow
in the variables that we want.Another solution would be to have the option of setting what globals will be disabled directly in this plugin with
window
as default. And to change the name of the rule to something like:no-unsafe-globals-use
.Let me know your opinion about this or if you have other ideas
Closes #2057