sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules
MIT License
4.2k stars 363 forks source link

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

Open fregante opened 6 days ago

fregante commented 6 days ago

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 https://github.com/sindresorhus/eslint-plugin-unicorn/pull/2410#discussion_r1779954389_

sindresorhus commented 6 days ago

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

Agreed 👍