build: Switch eslint to ES6 mode, and make pass

Change-Id: Ic29ad198519a7455909b8ee32fa891c7881e4bb5
This commit is contained in:
James D. Forrester 2023-09-20 09:27:51 +01:00
parent 003fd5778f
commit 2f9beac0fa
7 changed files with 22 additions and 25 deletions

View file

@ -1,7 +1,7 @@
{ {
"root": true, "root": true,
"extends": [ "extends": [
"wikimedia/client-es5", "wikimedia/client",
"wikimedia/jquery", "wikimedia/jquery",
"wikimedia/mediawiki" "wikimedia/mediawiki"
] ]

View file

@ -1,6 +1,6 @@
/* eslint-disable no-jquery/no-global-selector */ /* eslint-disable no-jquery/no-global-selector */
$( document ).on( 'click', '.fancycaptcha-reload', function () { $( document ).on( 'click', '.fancycaptcha-reload', function () {
var $this = $( this ), const $this = $( this ),
$root = $this.closest( '.fancycaptcha-captcha-container' ), $root = $this.closest( '.fancycaptcha-captcha-container' ),
$captchaImage = $root.find( '.fancycaptcha-image' ); $captchaImage = $root.find( '.fancycaptcha-image' );
@ -8,8 +8,8 @@ $( document ).on( 'click', '.fancycaptcha-reload', function () {
// AJAX request to get captcha index key // AJAX request to get captcha index key
new mw.Api().post( { action: 'fancycaptchareload' } ).done( function ( data ) { new mw.Api().post( { action: 'fancycaptchareload' } ).done( function ( data ) {
var captchaIndex = data.fancycaptchareload.index, const captchaIndex = data.fancycaptchareload.index;
imgSrc; let imgSrc;
if ( typeof captchaIndex === 'string' ) { if ( typeof captchaIndex === 'string' ) {
// replace index key with a new one for captcha image // replace index key with a new one for captcha image
imgSrc = $captchaImage.attr( 'src' ).replace( /(wpCaptchaId=)\w+/, '$1' + captchaIndex ); imgSrc = $captchaImage.attr( 'src' ).replace( /(wpCaptchaId=)\w+/, '$1' + captchaIndex );

View file

@ -1,8 +1,8 @@
/* eslint-env node */ /* eslint-env node */
module.exports = function ( grunt ) { module.exports = function ( grunt ) {
var messagesDirs = grunt.file.readJSON( 'extension.json' ).MessagesDirs; const messagesDirs = grunt.file.readJSON( 'extension.json' ).MessagesDirs;
var subExtensions = [ const subExtensions = [
'QuestyCaptcha', 'QuestyCaptcha',
'ReCaptchaNoCaptcha', 'ReCaptchaNoCaptcha',
'FancyCaptcha', 'FancyCaptcha',

View file

@ -8,8 +8,8 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.name = 'confirmEditNoCaptchaReCaptcha'; ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.name = 'confirmEditNoCaptchaReCaptcha';
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.getReadyPromise = function () { ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.getReadyPromise = function () {
var onLoadFn = 'onRecaptchaLoadCallback' + Date.now(), const onLoadFn = 'onRecaptchaLoadCallback' + Date.now();
deferred, config, scriptURL, params; let deferred, config, scriptURL, params;
if ( !this.readyPromise ) { if ( !this.readyPromise ) {
deferred = $.Deferred(); deferred = $.Deferred();
@ -27,13 +27,13 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
}; };
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.matchFunction = function ( data ) { ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.matchFunction = function ( data ) {
var captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' ); const captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
return !!( captchaData && captchaData.type === 'recaptchanocaptcha' ); return !!( captchaData && captchaData.type === 'recaptchanocaptcha' );
}; };
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.process = function ( data, target ) { ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.process = function ( data, target ) {
var self = this, const self = this,
config = mw.config.get( 'wgConfirmEditConfig' ), config = mw.config.get( 'wgConfirmEditConfig' ),
siteKey = config.reCaptchaSiteKey, siteKey = config.reCaptchaSiteKey,
$container = $( '<div>' ); $container = $( '<div>' );

View file

@ -7,8 +7,8 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
ve.init.mw.HCaptchaSaveErrorHandler.static.name = 'confirmEditHCaptcha'; ve.init.mw.HCaptchaSaveErrorHandler.static.name = 'confirmEditHCaptcha';
ve.init.mw.HCaptchaSaveErrorHandler.static.getReadyPromise = function () { ve.init.mw.HCaptchaSaveErrorHandler.static.getReadyPromise = function () {
var onLoadFn = 'onHcaptchaLoadCallback' + Date.now(), const onLoadFn = 'onHcaptchaLoadCallback' + Date.now();
deferred, scriptURL, params; let deferred, scriptURL, params;
if ( !this.readyPromise ) { if ( !this.readyPromise ) {
deferred = $.Deferred(); deferred = $.Deferred();
@ -25,13 +25,13 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
}; };
ve.init.mw.HCaptchaSaveErrorHandler.static.matchFunction = function ( data ) { ve.init.mw.HCaptchaSaveErrorHandler.static.matchFunction = function ( data ) {
var captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' ); const captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
return !!( captchaData && captchaData.type === 'hcaptcha' ); return !!( captchaData && captchaData.type === 'hcaptcha' );
}; };
ve.init.mw.HCaptchaSaveErrorHandler.static.process = function ( data, target ) { ve.init.mw.HCaptchaSaveErrorHandler.static.process = function ( data, target ) {
var self = this, const self = this,
siteKey = require( './config.json' ).hCaptchaSiteKey, siteKey = require( './config.json' ).hCaptchaSiteKey,
$container = $( '<div>' ); $container = $( '<div>' );

View file

@ -38,14 +38,13 @@ OO.inheritClass( mw.libs.confirmEdit.CaptchaInputWidget, OO.ui.TextInputWidget )
/* Methods */ /* Methods */
mw.libs.confirmEdit.CaptchaInputWidget.prototype.makeCaptchaInterface = function ( captchaData ) { mw.libs.confirmEdit.CaptchaInputWidget.prototype.makeCaptchaInterface = function ( captchaData ) {
var $captchaImg, msg, question, let $captchaImg, msg, question;
$captchaDiv, $captchaParagraph;
$captchaParagraph = $( '<div>' ).append( const $captchaParagraph = $( '<div>' ).append(
$( '<strong>' ).text( mw.msg( 'captcha-label' ) ), $( '<strong>' ).text( mw.msg( 'captcha-label' ) ),
document.createTextNode( mw.msg( 'colon-separator' ) ) document.createTextNode( mw.msg( 'colon-separator' ) )
); );
$captchaDiv = $( '<div>' ).append( $captchaParagraph ); const $captchaDiv = $( '<div>' ).append( $captchaParagraph );
if ( captchaData.url ) { if ( captchaData.url ) {
// FancyCaptcha // FancyCaptcha

View file

@ -15,7 +15,7 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
ve.init.mw.CaptchaSaveErrorHandler.static.name = 'confirmEditCaptchas'; ve.init.mw.CaptchaSaveErrorHandler.static.name = 'confirmEditCaptchas';
ve.init.mw.CaptchaSaveErrorHandler.static.matchFunction = function ( data ) { ve.init.mw.CaptchaSaveErrorHandler.static.matchFunction = function ( data ) {
var captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' ); const captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
return !!( captchaData && ( return !!( captchaData && (
captchaData.url || captchaData.url ||
@ -26,7 +26,10 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
}; };
ve.init.mw.CaptchaSaveErrorHandler.static.process = function ( data, target ) { ve.init.mw.CaptchaSaveErrorHandler.static.process = function ( data, target ) {
var captchaInput; const captchaInput = new mw.libs.confirmEdit.CaptchaInputWidget(
ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' )
);
ve.targetLinksToNewWindow( captchaInput.$element[ 0 ] );
function onCaptchaLoad() { function onCaptchaLoad() {
target.saveDialog.updateSize(); target.saveDialog.updateSize();
@ -34,11 +37,6 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
captchaInput.scrollElementIntoView(); captchaInput.scrollElementIntoView();
} }
captchaInput = new mw.libs.confirmEdit.CaptchaInputWidget(
ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' )
);
ve.targetLinksToNewWindow( captchaInput.$element[ 0 ] );
captchaInput.on( 'load', onCaptchaLoad ); captchaInput.on( 'load', onCaptchaLoad );
// Save when pressing 'Enter' in captcha field as it is single line. // Save when pressing 'Enter' in captcha field as it is single line.
captchaInput.on( 'enter', function () { captchaInput.on( 'enter', function () {