wxt-dev / wxt-dev/wxt

ESLint 9 flat config: WXT auto-import globals not respected when using @antfu/eslint-config (no-undef + Config Layering Failures)

Open
#1,948 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending-triage
Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Summary

When integrating WXT’s generated ESLint auto-import globals (imports.eslintrc.enabled: 9) with @antfu/eslint-config under ESLint 9 flat config mode, the global identifiers provided by WXT are not recognized by ESLint (resulting in no-undef errors for browser, defineBackground, defineContentScript). Attempts to compose / layer the generated flat-config with @antfu/eslint-config either have no effect or produce structural errors (e.g. TypeError: antfuConfigs is not iterable, ConfigError: Unexpected key "0"). The only stable workaround is to reintroduce explicit imports — which defeats the purpose of WXT auto-imports.

What I expected

A documented, stable pattern to compose WXT-generated ESLint flat-config (languageOptions.globals) with @antfu/eslint-config so that WXT globals are recognized without adding explicit imports.

What actually happens

  • Removing explicit imports produces ESLint no-undef errors for WXT globals, while TypeScript build OK.
  • Attempts to merge/compose configs either do not add globals or break flat config validation / composition with @antfu/eslint-config.
Reproduction
Minimal reproduction layout

The issue can be reproduced using these minimal files:

wxt.config.ts
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'wxt';

export default defineConfig({
  modules: ['@wxt-dev/module-vue'],
  imports: {
    eslintrc: {
      enabled: 9,
    },
  },
});
src/background.ts
// Removing these imports causes ESLint no-undef errors
import { browser } from 'wxt/browser';
import { defineBackground } from 'wxt/utils/define-background';

export default defineBackground({
  /* ... */
});
eslint-auto-imports.mjs (generated by WXT)
const globals = {
  browser: true,
  defineBackground: true,
  defineContentScript: true
};

export default {
  name: 'wxt/auto-imports',
  languageOptions: {
    globals,
    sourceType: 'module'
  }
};

eslint.config.js
import antfu from '@antfu/eslint-config';
import oxlint from 'eslint-plugin-oxlint';

export default antfu({
  ignores: ['dist/**', 'node_modules/**'],
  vue: { a11y: true },
  typescript: { tsconfigPath: 'tsconfig.json' },
  rules: {
    'antfu/no-top-level-await': 'off',
    'no-console': 'off'
  }
},
...oxlint.buildFromOxlintConfigFile('./.oxlintrc.json'));

Steps to reproduce

No response

System Info
System:
    OS: macOS 26.0.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 71.42 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.0.0 
    npm: 11.6.2 
    bun: 1.3.1 
  Browsers:
    Brave Browser: 141.1.83.120
    Chrome: 141.0.7390.108
    Edge: 140.0.3485.94
    Firefox Developer Edition: 145.0
    Safari: 26.0.1
  npmPackages:
    wxt: 0.20.11 => 0.20.11
Used Package Manager

bun

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduced wxt.config.ts, generated eslint-auto-imports.mjs, eslint.config.js, and src/background.ts. Trace how the generated flat config is composed with @antfu/eslint-config and oxlint, then verify the WXT globals no longer trigger no-undef without explicit imports. Done means a documented, stable composition pattern that passes ESLint flat-config validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.