An overview of ESLint shareable configurations for building UI extensions on HubSpot with React.
For security and reliability, UI extensions run in a sandboxed web worker environment with restricted APIs. This can cause issues or unexpected behavior when developing UI extensions, especially if you’re not fully familiar with the UI extensions environment.The @hubspot/eslint-config-ui-extensions package provides ESLint rules specifically designed for HubSpot UI extensions, and catches common issues like using unavailable browser APIs, incorrect imports, and other patterns that won’t work in the sandboxed web worker context.It’s recommended to set up ESLint with this configuration when starting a new UI extensions project, but can be implemented at any time.
If you don’t yet have linting configured and want to set it up automatically, you can run the hs project lint command from the root of your project to set up the necessary configuration files and dependencies.
The basic config above only includes HubSpot UI extensions-specific rules. For a production-ready setup, it’s recommended that you add standard ESLint rules, TypeScript support, React Hooks linting, Prettier compatibility, and unused import detection.
The rules included in the shared config from @hubspot/eslint-config-ui-extensions are enabled by default, and should always be enabled when building UI extensions.
Prevent usage of browser storage APIs (localStorage and sessionStorage) in UI extensions, which run in a sandboxed web worker environment where these APIs are not available.