ESLint

Keep extension code quality predictable before issues reach runtime. ESLint runs outside the build pipeline and is executed from your scripts or CI.

When ESLint is a good fit

  • You want consistent code standards across team contributions.
  • You need CI checks that catch common JS/TS mistakes early.
  • You are enforcing extension-specific quality rules before release.

ESLint capabilities

CapabilityWhat it gives you
JavaScript and TypeScript lintingCatch common mistakes and enforce project standards
Flat config supportUse modern eslint.config.mjs in new projects
CI-friendly executionRun lint checks in local scripts and pull request pipelines
Extension-specific rulesetsAdd browser-extension plugins/rules when your team needs stricter checks

Template examples

ESLint config template

Preconfigured lint setup you can use immediately.

new-config-eslint screenshot

npm
pnpm
yarn
npx extension@latest create my-extension --template=new-config-eslint

Repository: examples/new-config-eslint

Usage with an existing extension

Install the core packages:

npm
yarn
pnpm
bun
deno
npm install -D eslint @eslint/js globals typescript-eslint

Create eslint.config.mjs:

import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'

export default [
  {files: ['**/*.{js,mjs,cjs,ts,tsx,jsx}']},
  {
    languageOptions: {
      globals: globals.browser
    }
  },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended
]

Run lint commands from your scripts:

npm
pnpm
yarn
npm run lint

If no script exists yet, run:

npm
yarn
pnpm
bun
deno
npm eslint .

Best practices

  • Keep lint rules in source control and apply them in CI.
  • Use lint-staged or pre-commit hooks for faster local feedback.
  • Add framework-specific plugins (for example React) only when needed.

Next steps

  • Integrate Prettier to avoid formatting-rule conflicts.
  • Add Stylelint for stylesheet linting.