Skip to content

Move to ESLint 9 and flat config - #11

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 the extension onto them. Lint now passes with three warnings; on master it failed on a test fixture's indentation.

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.

Outcome: not reviewed by a human yet. Left for you: the ES5 call below, and a try of the page name suggestions, which no test covers.

Claude's calls

  • Not discussed with @alistair3149:
    • Linting modules/ as ES5 with client/common, rather than moving the code to client/es6.
    • Keeping Grunt's ESLint task, on grunt-eslint 26, rather than a plain eslint npm script.
    • The server config for Gruntfile.js and eslint.config.js.
    • Reindenting the JSON test fixture rather than leaving it out of linting.
    • Keeping the opensearch request in a variable for .then(), rather than keeping .done() with a disable comment.
  • Not verified: the page name suggestions in a browser. CI does not run npm test (NODE_JS is commented out in the Makefile), so it does not check this change either.
  • Where your judgment helps:
    • Whether to keep supporting ES5 browsers on MediaWiki 1.40. Requiring MediaWiki 1.41 would allow client/es6 and ES2015 syntax. Keeping 1.40, eslint-plugin-es-x's restrict-to-es5 preset would bring back the 139 checks for newer built-ins this PR loses.
    • With .then(), the suggestions callback runs one tick later, and an exception inside it is logged by jQuery as a console warning instead of surfacing as an uncaught error.

Changes

  • Bump eslint-config-wikimedia 0.28.2 → 0.33.1 and grunt-eslint 24.3.0 → 26.0.0, and declare eslint 9.39.5, which eslint.config.js loads directly. grunt-eslint 27 bundles ESLint 10, which eslint-config-wikimedia does not support yet.
  • Replace .eslintrc.json with eslint.config.js.
  • eslint-config-wikimedia no longer has an ES5 browser config (client-es5), and MediaWiki 1.40, which this extension supports, still serves JavaScript to ES5 browsers. modules/ now gets the shared client rules (client/common) with ecmaVersion 5: ES2015+ syntax and globals are still errors, but ES2015+ methods such as Object.assign or String.prototype.includes are no longer reported.
  • Gruntfile.js and eslint.config.js run in Node, so they get the server config instead of the client one. Gruntfile.js gets the 'use strict' that config requires, in place of an /* eslint-env */ comment ESLint 9 ignores, and const for its one variable.
  • Drop the jQuery global, which the jquery config now defines.
  • Keep the opensearch request in a variable and attach its handler with .then(), as no-jquery/no-done-fail asks. Chaining .then() would store a new promise without the abort() that cancel needs.
  • Reindent the JSON test fixture with tabs and add codecov.yml's final newline. The fixture's JSON is unchanged.

Not in this PR: running npm test in CI, and the PHPUnit fatal error CI hits on master and here: SMW now declares getTestCaseLocation(): string, which JsonTestCaseScriptRunnerTest does not match.

Verification evidence
  • master (grunt-eslint 24.3.0, ESLint 8.57.0, config 0.28.2): npm test fails. 130 files, 90 errors (88 indent in the fixture, 1 no-mixed-spaces-and-tabs in composer.json, 1 eol-last in codecov.yml), 3 warnings (2 max-len, 1 no-jquery/no-global-selector).
  • Config 0.33.1 alone, on ESLint 8 with .eslintrc.json and modules/ on client/common at ES5: the same, plus 1 no-jquery/no-done-fail.
  • This branch: npm test passes. ESLint lints the same 130 files, with eslint.config.js in place of .eslintrc.json: 0 errors, the same 3 warnings. The composer.json error is gone because ESLint 9 dropped no-mixed-spaces-and-tabs.
  • --print-config from ESLint 8 (config bump alone) and ESLint 9:
    • modules/createPage.searchSuggest.js: rules, globals, ecmaVersion, sourceType, parser and settings match, apart from ESLint 9's own eslint:recommended changes (added no-empty-static-block, no-new-native-nonconstructor, no-unused-private-class-members; dropped no-extra-semi, no-mixed-spaces-and-tabs, no-new-symbol);
    • Gruntfile.js: client → server config;
    • JSON and YAML files: ES2015+ globals now defined, from their ecmaVersion; no effect.
  • master's client-es5 against this branch, for modules/createPage.searchSuggest.js: ecmaVersion 5 in both; dropped 139 es-x rules, no-restricted-properties (parentElement) and no-restricted-syntax (Array keys()/values()); added 13 rules from the newer config.
  • The fixture parses to the same JSON before and after. The SMW JSONScript runner decodes it rather than comparing text.
  • npm ci from the new lockfile: one ESLint copy (9.39.5), no invalid dependencies.
  • CI: both PHPUnit jobs fail with that fatal error in JsonTestCaseScriptRunnerTest.php, which this PR does not touch. master's last run, on 31 August, hit the same error in its MediaWiki 1.44 job.

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 the extension onto them. Lint now passes with
three warnings; on master it failed on a test fixture's indentation.

- Bump eslint-config-wikimedia 0.28.2 → 0.33.1 and grunt-eslint
  24.3.0 → 26.0.0, and declare eslint 9.39.5, which eslint.config.js
  loads directly. grunt-eslint 27 bundles ESLint 10, which
  eslint-config-wikimedia does not support yet.
- Replace .eslintrc.json with eslint.config.js.
- eslint-config-wikimedia no longer has an ES5 browser config
  (`client-es5`), and MediaWiki 1.40, which this extension supports,
  still serves JavaScript to ES5 browsers. modules/ now gets the shared
  client rules (`client/common`) with ecmaVersion 5: ES2015+ syntax and
  globals are still errors, but ES2015+ methods such as Object.assign or
  String.prototype.includes are no longer reported.
- Gruntfile.js and eslint.config.js run in Node, so they get the server
  config instead of the client one. Gruntfile.js gets the 'use strict'
  that config requires, in place of an `/* eslint-env */` comment
  ESLint 9 ignores, and `const` for its one variable.
- Drop the `jQuery` global, which the jquery config now defines.
- Keep the opensearch request in a variable and attach its handler with
  .then(), as no-jquery/no-done-fail asks. Chaining .then() would store
  a new promise without the abort() that cancel needs.
- Reindent the JSON test fixture with tabs and add codecov.yml's final
  newline. The fixture's JSON is unchanged.

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