From 31b0bfa76786625f430a8fcebe9137977cbfdd78 Mon Sep 17 00:00:00 2001 From: alistair3149 Date: Thu, 12 Nov 2026 16:29:36 -0500 Subject: [PATCH] Move to ESLint 9 and flat config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eslint-config-wikimedia 0.33.1 supports ESLint 9 and flat config (T364065). This moves the extension onto them. Lint reports the same 24 warnings as before. - Bump eslint-config-wikimedia 0.20.0 → 0.33.1 and grunt-eslint 23.0.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 and the eslintIgnore list in package.json with one eslint.config.js. `wikimedia/client-es6` is now `client/es6`. - 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 a `/* eslint-env node */` comment ESLint 9 ignores. - Drop the `mediawiki/msg-doc: warn` override, which is now the default. - Fix what the newer config reports in resources/ext.wikibase.rdf.js: callbacks become arrow functions (none uses `this`), and `.done().fail()` becomes `.then()` with both handlers. Co-Authored-By: Claude Opus 5.5 --- .eslintrc.json | 18 ------------------ Gruntfile.js | 3 ++- eslint.config.js | 26 ++++++++++++++++++++++++++ package.json | 11 ++++------- resources/ext.wikibase.rdf.js | 13 ++++++------- 5 files changed, 38 insertions(+), 33 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 935f967..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "root": true, - "extends": [ - "wikimedia/client-es6", - "wikimedia/mediawiki", - "wikimedia/jquery" - ], - "env": { - "browser": true, - "es6": true - }, - "rules": { - "no-jquery/no-parse-html-literal": "warn", - "no-jquery/no-global-selector": "warn", - "no-jquery/no-class-state": "warn", - "mediawiki/msg-doc": "warn" - } -} diff --git a/Gruntfile.js b/Gruntfile.js index 3c05588..6c24689 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,5 @@ -/* eslint-env node */ +'use strict'; + module.exports = function ( grunt ) { const conf = grunt.file.readJSON( 'extension.json' ); diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..112e9ab --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,26 @@ +'use strict'; + +const { defineConfig, globalIgnores } = require( 'eslint/config' ); +const wikimedia = require( 'eslint-config-wikimedia/flat' ); + +module.exports = defineConfig( [ + globalIgnores( [ + 'coverage/', + 'vendor/' + ] ), + + // These run in Node and have their own config below + { + ignores: [ 'Gruntfile.js', 'eslint.config.js' ], + extends: [ wikimedia( 'client/es6', 'mediawiki', 'jquery' ) ], + rules: { + 'no-jquery/no-parse-html-literal': 'warn', + 'no-jquery/no-global-selector': 'warn', + 'no-jquery/no-class-state': 'warn' + } + }, + { + files: [ 'Gruntfile.js', 'eslint.config.js' ], + extends: [ wikimedia( 'server' ) ] + } +] ); diff --git a/package.json b/package.json index 1c55b0e..e88b95c 100644 --- a/package.json +++ b/package.json @@ -5,15 +5,12 @@ }, "devDependencies": { "api-testing": "^1.4.2", - "eslint-config-wikimedia": "0.20.0", + "eslint": "9.39.5", + "eslint-config-wikimedia": "0.33.1", "grunt": "1.4.0", "grunt-banana-checker": "0.9.0", - "grunt-eslint": "23.0.0", + "grunt-eslint": "26.0.0", "grunt-stylelint": "0.16.0", "stylelint-config-wikimedia": "0.11.1" - }, - "eslintIgnore": [ - "coverage", - "vendor" - ] + } } diff --git a/resources/ext.wikibase.rdf.js b/resources/ext.wikibase.rdf.js index bb8c5e4..106b33d 100644 --- a/resources/ext.wikibase.rdf.js +++ b/resources/ext.wikibase.rdf.js @@ -2,7 +2,7 @@ * JavaScript for WikibaseRDF */ -$( function () { +$( () => { 'use strict'; function moveSection() { @@ -56,7 +56,7 @@ $( function () { $anchor: $anchor } ); - $hideMessage.on( 'click', function ( event ) { + $hideMessage.on( 'click', ( event ) => { event.preventDefault(); $messageAnchor.data( 'wbtooltip' ).degrade( true ); $( window ).off( '.wikibase-rdf-property-warning' ); @@ -72,7 +72,7 @@ $( function () { $( window ).one( 'scroll.wikibase-rdf-property-warning touchmove.wikibase-rdf-property-warning resize.wikibase-rdf-property-warning', - function () { + () => { const tooltip = $messageAnchor.data( 'wbtooltip' ); if ( tooltip ) { $messageAnchor.data( 'wbtooltip' ).hide(); @@ -155,7 +155,7 @@ $( function () { findRow( trigger ).addClass( 'wikibase-rdf-row-editing-saving' ); - $( '.wikibase-rdf-rows .wikibase-rdf-row' ).each( function ( index, row ) { + $( '.wikibase-rdf-rows .wikibase-rdf-row' ).each( ( index, row ) => { const mapping = { predicate: '', object: '' }; const $row = $( row ); @@ -187,7 +187,7 @@ $( function () { { mappings: mappings }, { authorization: 'token' } ) - .done( function () { + .then( () => { hideError(); const isSave = $( trigger ).hasClass( 'wikibase-rdf-action-save' ); const isRemove = $( trigger ).hasClass( 'wikibase-rdf-action-remove' ); @@ -197,8 +197,7 @@ $( function () { onSuccessfulRemove( trigger ); } enableActions(); - } ) - .fail( function ( data, response ) { + }, ( data, response ) => { const userLang = mw.config.get( 'wgUserLanguage' ); const siteLang = mw.config.get( 'wgContentLanguage' ); if ( Object.prototype.hasOwnProperty.call( response.xhr.responseJSON, 'messageTranslations' ) ) {