Skip to content
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 also reject self in service workers #2458

Open
fregante opened this issue Sep 29, 2024 · 2 comments
Open

prefer-global-this should also reject self in service workers #2458

fregante opened this issue Sep 29, 2024 · 2 comments

Comments

@fregante
Copy link
Collaborator

fregante commented Sep 29, 2024

Worker APIs should use self

I think self was chosen because there's no window, but globalThis should still be preferred there I think.

  • Service workers introduction: 2014
  • globalThis introduction: 2019

I think using self in service workers is more of a historical artifact rather than a necessity.

Originally posted by @fregante in #2410 (comment)

@sindresorhus
Copy link
Owner

I think self was chosen because there's no window, but globalThis should still be preferred there I think.

Agreed 👍

@zanminkian
Copy link
Contributor

zanminkian commented Oct 8, 2024

self and global are not standard in browser and node. So I still believe we don't need self and global completely, including computed members like global[foo]. Computed members like global[foo] and self[foo] can be replaced with globalThis[foo].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants