build: Updating eslint-config-wikimedia to 0.27.0

The following rules are failing and were disabled:
* modules:
  * prefer-const

Change-Id: I318c62b99290c67f0d04d26aad12379c0da0b944
这个提交包含在:
libraryupgrader 2024-04-19 08:37:25 +00:00
父节点 d3890d0041
当前提交 17b410c6ec
共有 10 个文件被更改,包括 417 次插入431 次删除

查看文件

@ -9,6 +9,7 @@
"rules": {
"no-var": "warn",
"max-len": "off",
"no-jquery/no-global-selector": "off"
"no-jquery/no-global-selector": "off",
"prefer-const": "warn"
}
}

查看文件

@ -1,11 +1,11 @@
( function () {
'use strict';
var attrName = 'data-revision-id';
const attrName = 'data-revision-id';
function reloadThankedState() {
$( 'a.mw-thanks-thank-link' ).each( function ( idx, el ) {
var $thankLink = $( el );
const $thankLink = $( el );
if ( mw.thanks.thanked.contains( $thankLink.attr( attrName ) ) ) {
$thankLink.before(
$( '<span>' ).addClass( 'mw-thanks-thank-confirmation' ).text(
@ -29,7 +29,7 @@
}
$thankLink.data( 'clickDisabled', true );
var source;
let source;
// Determine the thank source (history, diff, or log).
if ( mw.config.get( 'wgAction' ) === 'history' ) {
source = 'history';
@ -40,7 +40,7 @@
}
// Construct the API parameters.
var apiParams = {
const apiParams = {
action: 'thank',
source: source
};
@ -63,7 +63,7 @@
function ( errorCode ) {
// If error occurred, enable attempting to thank again
$thankLink.data( 'clickDisabled', false );
var msg;
let msg;
switch ( errorCode ) {
case 'invalidrevision':
msg = mw.msg( 'thanks-error-invalidrevision' );
@ -88,10 +88,10 @@
* @param {jQuery} $content
*/
function addActionToLinks( $content ) {
var $thankLinks = $content.find( 'a.mw-thanks-thank-link' );
const $thankLinks = $content.find( 'a.mw-thanks-thank-link' );
if ( mw.config.get( 'thanks-confirmation-required' ) ) {
$thankLinks.each( function () {
var $thankLink = $( this );
const $thankLink = $( this );
$thankLink.confirmable( {
i18n: {
confirm: mw.msg( 'thanks-confirmation2', mw.user ),
@ -108,7 +108,7 @@
} );
} else {
$thankLinks.on( 'click', function ( e ) {
var $thankLink = $( this );
const $thankLink = $( this );
e.preventDefault();
sendThanks( $thankLink, $thankLink );
} );

查看文件

@ -1,8 +1,8 @@
( function () {
var $thankedLabel = $( '<span>' ).addClass( 'mw-thanks-flow-thanked mw-ui-quiet' );
const $thankedLabel = $( '<span>' ).addClass( 'mw-thanks-flow-thanked mw-ui-quiet' );
var attrName = 'data-flow-id';
var cookieName = 'flow-thanked';
const attrName = 'data-flow-id';
const cookieName = 'flow-thanked';
function findPostAuthorFromThankLink( $thankLink ) {
// We can't use 'closest' directly because .flow-author is a cousin
@ -12,9 +12,9 @@
function reloadThankedState() {
$( 'a.mw-thanks-flow-thank-link' ).each( function ( idx, el ) {
var $thankLink = $( el );
const $thankLink = $( el );
if ( mw.thanks.thanked.contains( $thankLink.closest( '.flow-post' ).attr( attrName ), cookieName ) ) {
var author = findPostAuthorFromThankLink( $thankLink );
const author = findPostAuthorFromThankLink( $thankLink );
mw.thanks.getUserGender( author )
.done( function ( recipientGender ) {
$thankLink.before(
@ -38,7 +38,7 @@
.then(
// Success
function () {
var author = findPostAuthorFromThankLink( $thankLink );
const author = findPostAuthorFromThankLink( $thankLink );
// Get the user who was thanked (for gender purposes)
return mw.thanks.getUserGender( author );
},
@ -54,7 +54,7 @@
}
)
.then( function ( recipientGender ) {
var $thankUserLabel = $thankedLabel.clone();
const $thankUserLabel = $thankedLabel.clone();
$thankUserLabel.append(
mw.msg( 'thanks-button-thanked', mw.user, recipientGender )
);
@ -74,7 +74,7 @@
// .on() is needed to make the button work for dynamically loaded posts
$( '.flow-board' ).on( 'click', 'a.mw-thanks-flow-thank-link', function ( e ) {
var $thankLink = $( this );
const $thankLink = $( this );
e.preventDefault();
sendFlowThanks( $thankLink );
} );

查看文件

@ -1,6 +1,6 @@
( function () {
// To allow users to cancel a thanks in the event of an accident, the action is delayed.
var THANKS_DELAY = 2000,
const THANKS_DELAY = 2000,
msgOptions = {
// tag ensures that only one message in workflow is shown at any time
tag: 'thanks'
@ -22,7 +22,7 @@
mw.notify( mw.msg( 'thanks-button-action-completed', name, recipientGender, mw.user ),
msgOptions );
}, function ( errorCode ) {
var msg;
let msg;
switch ( errorCode ) {
case 'invalidrevision':
msg = mw.msg( 'thanks-error-invalidrevision' );
@ -100,7 +100,7 @@
}
function queueThanks( $btn ) {
var $msg = $( '<div>' ).addClass( 'mw-thanks-notification' )
const $msg = $( '<div>' ).addClass( 'mw-thanks-notification' )
.text( mw.msg( 'thanks-button-action-queued', name, gender ) )
.append( $( '<a>' ).text( mw.msg( 'thanks-button-action-cancel' ) )
.on( 'click', function () {
@ -117,7 +117,7 @@
}
return $button.on( 'click', function () {
var $this = $( this );
const $this = $( this );
$this.prop( 'disabled', true );
// eslint-disable-next-line no-jquery/no-class-state
if ( !$this.hasClass( 'thanked' ) && !timeout ) {
@ -133,11 +133,11 @@
* @param {jQuery} $container to render button in
*/
function init( $user, $container ) {
var username = $user.data( 'user-name' ),
const username = $user.data( 'user-name' ),
rev = $user.data( 'revision-id' ),
gender = $user.data( 'user-gender' );
var $thankBtn = createThankLink( username, rev, gender );
const $thankBtn = createThankLink( username, rev, gender );
if ( $thankBtn ) {
$thankBtn.prependTo( $container );
}

查看文件

@ -12,7 +12,7 @@
* @return {string[]} Thanks IDs
*/
load: function ( cookieName ) {
var cookie = mw.cookie.get( cookieName || this.cookieName );
const cookie = mw.cookie.get( cookieName || this.cookieName );
if ( cookie === null ) {
return [];
}
@ -26,7 +26,7 @@
* @param {string} [cookieName] Cookie name to use, defaults to this.cookieName
*/
push: function ( id, cookieName ) {
var saved = this.load();
let saved = this.load();
saved.push( id );
if ( saved.length > this.maxHistory ) { // prevent forever growing
saved = saved.slice( saved.length - this.maxHistory );

查看文件

@ -16,7 +16,7 @@
$context = $( $context );
selector = selector.trim();
var matches;
let matches;
while ( selector && ( matches = selector.match( /(.*?(?:^|[>\s+~]))(<\s*[^>\s+~]+)(.*?)$/ ) ) ) {
if ( matches[ 1 ].trim() ) {
$context = $context.find( matches[ 1 ] );
@ -43,7 +43,7 @@
* @see jQuery#findWithParent
*/
$.fn.findWithParent = function ( selector ) {
var selectors = selector.split( ',' ),
let selectors = selector.split( ',' ),
$elements = $(),
self = this;

773
package-lock.json 自动生成的

文件差异内容过多而无法显示 加载差异

查看文件

@ -6,7 +6,7 @@
"test": "grunt test"
},
"devDependencies": {
"eslint-config-wikimedia": "0.26.0",
"eslint-config-wikimedia": "0.27.0",
"grunt": "1.6.1",
"grunt-banana-checker": "0.11.1",
"grunt-contrib-watch": "1.1.0",

查看文件

@ -1,8 +1,8 @@
QUnit.module( 'Thanks mobilediff', function () {
QUnit.test( 'render button for logged in users', function ( assert ) {
var $container = $( '<div>' );
var $user = $( '<div>' )
const $container = $( '<div>' );
const $user = $( '<div>' )
.data( 'user-name', 'jon' )
.data( 'revision-id', 1 )
.data( 'user-gender', 'male' );

查看文件

@ -6,14 +6,14 @@ QUnit.module( 'Thanks thank', QUnit.newMwEnvironment( {
} ) );
QUnit.test( 'thanked cookie', function ( assert ) {
var thankId = '8';
var thankIdNonExisting = '13';
const thankId = '8';
const thankIdNonExisting = '13';
mw.cookie.set( mw.thanks.thanked.cookieName, escape( '17,11' ) );
assert.deepEqual( mw.thanks.thanked.load(), [ '17', '11' ], 'cookie with two values' );
// Add a 0 the 100th element
// eslint-disable-next-line es-x/no-string-prototype-repeat
mw.cookie.set( mw.thanks.thanked.cookieName, escape( '9,'.repeat( mw.thanks.thanked.maxHistory - 1 ) + '0' ) );
assert.strictEqual( mw.thanks.thanked.load()[ mw.thanks.thanked.maxHistory - 1 ], '0', 'load ids from a cookie' );
@ -42,10 +42,10 @@ QUnit.test( 'gets user gender', function ( assert ) {
);
} );
var maleUser = mw.thanks.getUserGender( 'user1' );
var unknownGenderUser = mw.thanks.getUserGender( 'user2' );
var nonExistingUser = mw.thanks.getUserGender( 'user3' );
var done = assert.async( 3 );
const maleUser = mw.thanks.getUserGender( 'user1' );
const unknownGenderUser = mw.thanks.getUserGender( 'user2' );
const nonExistingUser = mw.thanks.getUserGender( 'user3' );
const done = assert.async( 3 );
maleUser.then( function ( recipientGender ) {
assert.strictEqual( recipientGender, 'male', 'gender for male user' );