Skip to content

Move to ESLint 9 and flat config - #35

Draft
alistair3149 wants to merge 1 commit into
masterfrom
alistair3149/eslint-9
Draft

alistair3149 wants to merge 1 commit into
masterfrom
alistair3149/eslint-9

Conversation

@alistair3149

@alistair3149 alistair3149 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

eslint-config-wikimedia 0.33.1 supports ESLint 9 and flat config (T364065). This moves resources/visual-editor onto them, up from eslint-config-wikimedia 0.24 and typescript-eslint 5, and fixes the 95 problems the newer rules report.

Human input

Goal and shape: goal from @alistair3149; shape Claude's.

  • Directions: @alistair3149 asked to move our extensions on eslint-config-wikimedia to ESLint 9 and, after merging the first such PR, asked for the rest.
  • Choices: @alistair3149 decided the rebuilt dist/assets/index.js belongs in this PR.

Outcome: not reviewed by a human yet. Left for you: the hand-made source changes below.

Claude's calls

  • Not discussed with @alistair3149:
    • Node 22 instead of 19 in CI and in the Dockerfile.
    • A named function for the ve.activationComplete handler, rather than keeping the anonymous function behind an eslint-disable comment.
    • catch {} in getCommandLabel.
    • JSON and YAML stay unlinted, as before; eslint . would otherwise lint them.

Changes

One commit.

  • Bump eslint-config-wikimedia ^0.24.0 → ^0.33.1 and eslint ^8.41.0 → ^9.39.5. Drop @wmde/eslint-config-wikimedia-typescript, whose rules eslint-config-wikimedia now ships itself, the @typescript-eslint packages only it needed, and the unused eslint-import-resolver-typescript.
  • Replace .eslintrc.js with eslint.config.js. The lint scripts drop --ext and --ignore-path, which flat config does not support.
  • Fix the problems the newer rules report. 89 are fixed by --fix: trailing commas, spacing inside template literal placeholders, blank lines between class members, two arrow callbacks and one arrow body. By hand: the four constructor interfaces no longer extend Function, CommandsPopupWidget becomes a type alias, and getCommandLabel uses catch {}.
  • Move the ve.activationComplete handler into a named function. As the arrow function prefer-arrow-callback asks for, the build wraps the bundle in a CommonJS shim that ends in export, which ResourceLoader cannot load.
  • Run Node 22 instead of 19 in CI and in the Dockerfile behind make visual-editor-*. ESLint 9 does not support Node 19.
  • Rebuild dist/assets/index.js. It differs from the previous build only in the forEach callback in getCommandElTemplate and the hook handler, neither of which uses this.
Verification evidence
  • Baseline on master (ESLint 8.41.0, eslint-config-wikimedia 0.24.0): 16 files, 0 problems.
  • The same sources linted with eslint-config-wikimedia 0.33.1 on ESLint 8.57.1 with eslintrc (typescript-eslint 8, without the WMDE config), and on ESLint 9.39.5 with flat config: the same 95 messages, file, line, column and rule alike.
  • --print-config for src/Commands/CommandRegistry.ts, src/@types/globals.d.ts, vite.config.ts and env.d.ts matches between those two setups, apart from ESLint 9's own eslint:recommended changes. The config file itself is now linted as CommonJS with core rules, instead of with the TypeScript parser and rules.
  • After the fixes: npm run lint-no-fix reports nothing on the same 16 files, with eslint.config.js in place of .eslintrc.js. npm run build (type-check and Vite) passes.
  • Clean npm ci: one ESLint (9.39.5), no invalid dependencies.
  • Bundle: master's sources built with the new dependencies reproduce the committed dist/assets/index.js byte for byte. Built with the arrow-function handler, the bundle gained a CommonJS wrapper ending in export default B();; with the named function it has none, and differs from the previous build only at the two places above.
  • CI green on Node 22: Lint (visual-editor) and Test build (visual-editor).
  • Browser check (Playwright, headless Chromium) on MediaWiki 1.43 with its bundled VisualEditor, PR and master builds alike: the module loads, / opens the popup with the same 17 commands, typing bul leaves "Bullet list", Enter inserts a bullet list and closes the popup, / reopens it and Escape closes it. The resulting document is identical between the two builds; no JavaScript errors on either.

AI-authored — Claude Code, Opus 5.5, on a Professional Wiki account

eslint-config-wikimedia 0.33.1 supports ESLint 9 and flat config
(T364065). This moves resources/visual-editor onto them, up from
eslint-config-wikimedia 0.24 and typescript-eslint 5, and fixes the 95
problems the newer rules report.

- Bump eslint-config-wikimedia ^0.24.0 → ^0.33.1 and eslint ^8.41.0 →
  ^9.39.5. Drop @wmde/eslint-config-wikimedia-typescript, whose rules
  eslint-config-wikimedia now ships itself, the @typescript-eslint
  packages only it needed, and the unused
  eslint-import-resolver-typescript.
- Replace .eslintrc.js with eslint.config.js. The lint scripts drop
  --ext and --ignore-path, which flat config does not support.
- Fix the problems the newer rules report. 89 are fixed by --fix:
  trailing commas, spacing inside template literal placeholders, blank
  lines between class members, two arrow callbacks and one arrow body.
  By hand: the four constructor interfaces no longer extend `Function`,
  `CommandsPopupWidget` becomes a type alias, and `getCommandLabel` uses
  `catch {}`.
- Move the `ve.activationComplete` handler into a named function. As the
  arrow function prefer-arrow-callback asks for, the build wraps the
  bundle in a CommonJS shim that ends in `export`, which ResourceLoader
  cannot load.
- Run Node 22 instead of 19 in CI and in the Dockerfile behind
  `make visual-editor-*`. ESLint 9 does not support Node 19.
- Rebuild dist/assets/index.js. It differs from the previous build only
  in the forEach callback in `getCommandElTemplate` and the hook
  handler, neither of which uses `this`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant