no-restricted-globals rule prevents usage of browser globals that are not available in the sandboxed web worker environment.
Rule details
This rule blocks usage of the following globals:importScripts(): a worker function that doesn’t work in the UI extensions environment.addEventListener()/removeEventListener(): global event listeners don’t work for DOM events.location: not available in workers.history: not available in workers.navigator:WorkerNavigatorin workers, missing most browserNavigatorAPIs.
Examples
importScripts()
Instead of usingimportScripts():
Event listeners
Instead of using global event listeners:location and history
Instead of accessinglocation or history:
context for location information:
actions and <Link> for navigation:
navigator
In the sandboxed web worker,navigator is WorkerNavigator, not the full browser Navigator. Properties like navigator.language return worker-context values instead of the HubSpot user’s locale, and most other Navigator properties (clipboard, geolocation, mediaDevices, etc.) are missing entirely.
Instead of accessing navigator:
context for locale information: