Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #12847
Closed
Open
Issue created Nov 12, 2022 by Administrator@rootContributor

Remove `self` from confusing-browser-globals

Created by: JoshuaCWebDeveloper

Is your proposal related to a problem?

Yes.

When writing code for a service worker, the global variable self is used the same way window is used in web pages; however, eslint will report errors when writing worker code since self is banned via https://github.com/facebook/create-react-app/blob/main/packages/confusing-browser-globals/index.js.

Describe the solution you'd like

I believe we should remove self from the confusing-browser-globals list.

Describe alternatives you've considered

The workbox CRA template simply places:

/* eslint-disable no-restricted-globals */

at the top of the service-worker.ts file. This has the downside of removing all restricted global protections from your service worker code. Additionally, it is impractical for larger service worker codebases with many source files.

One can also use this and globalThis as an alternative to using self. However, I still believe that self should not be included in this list for the following reason:

  • self in a worker is the equivalent of window in a web page
  • window is not included in the list, so neither should self

Additional context

Assignee
Assign to
Time tracking