-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
Rule proposal: prefer-global-this
#978
Comments
This is now accepted. |
Can this auto fix to Also it should exclude |
In what situations are they the same?
Yes, good catch. A list can be found here: http://developer.mozilla.org/en-US/docs/Web/API/Window For those, it should enforce |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Changed my mind. |
Also: Object.assign(window, {something: true});
Object.defineProperty(window, 'something', {
value: true,
writable: true,
});
Object.defineProperties(window, {
something: {
value: true,
writable: true,
},
}); |
globalThis
is the unified way to access the "global" object.This has the benefit of making code more cross-platform and more consistent.
globalThis
requires Node.js 12, so we cannot add it to the recommended preset until April 2021 (date of Node.js 10 obsoletion).Fail
Pass
The text was updated successfully, but these errors were encountered: