ESLint: Manually enforce prefer-const

Change-Id: I91bd16ebbd2ef6056c025aaaa6b488488e31f50d
This commit is contained in:
Ed Sanders 2024-11-15 11:07:08 +00:00
parent 796d82a7ab
commit 24dd704bb0
4 changed files with 14 additions and 19 deletions

View file

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

View file

@ -476,7 +476,7 @@ module.exports = {
}
},
open: function () {
let magicWordsI18N = configData.magicWords,
const magicWordsI18N = configData.magicWords,
fileData = {
pre: '',
post: '',
@ -550,7 +550,7 @@ module.exports = {
// Pre-fill the text fields based on the current selection
if ( selection !== '' ) {
fileData = Object.assign( fileData, parseFileSyntax( selection ) );
Object.assign( fileData, parseFileSyntax( selection ) );
}
// Initialize the form fields
@ -831,7 +831,6 @@ module.exports = {
$( this ).data( 'offset', 0 );
} else {
let start, end;
if ( mode === 'replace' ) {
let actualReplacement;
@ -871,8 +870,8 @@ module.exports = {
match = { index: 0, 0: { length: 0 } };
}
}
start = offset + match.index;
end = start + match[ 0 ].length;
const start = offset + match.index;
const end = start + match[ 0 ].length;
$( this ).data( 'matchIndex', start );

View file

@ -3,10 +3,9 @@
*
* @private
*/
let configData = require( './data.json' ),
const configData = require( './data.json' ),
fileNamespace = mw.config.get( 'wgFormattedNamespaces' )[ 6 ],
specialCharacterGroups = require( 'mediawiki.language.specialCharacters' ),
toolbarConfig;
specialCharacterGroups = require( 'mediawiki.language.specialCharacters' );
/**
* Replace link targets from example messages with hash
@ -26,7 +25,7 @@ function delink( $message ) {
return $div.html();
}
toolbarConfig = {
const toolbarConfig = {
toolbar: {
// Main section
main: {

View file

@ -13,7 +13,6 @@ const toolbarModule = {
addToToolbar: function ( context, data ) {
for ( const type in data ) {
let i;
switch ( type ) {
case 'sections': {
const $sections = context.modules.toolbar.$toolbar.find( 'div.sections' );
@ -98,7 +97,7 @@ const toolbarModule = {
'div[rel="' + data.section + '"].section ' +
'div[rel="' + data.page + '"].page table'
);
for ( i = 0; i < data.rows.length; i++ ) {
for ( let i = 0; i < data.rows.length; i++ ) {
// Row
$table.append( toolbarModule.fn.buildRow( context, data.rows[ i ] ) );
}
@ -113,7 +112,7 @@ const toolbarModule = {
'div[rel="' + data.page + '"].page div'
);
const actions = $characters.data( 'actions' );
for ( i = 0; i < data.characters.length; i++ ) {
for ( let i = 0; i < data.characters.length; i++ ) {
// Character
$characters.append(
$( toolbarModule.fn.buildCharacter( data.characters[ i ], actions ) )
@ -502,7 +501,6 @@ const toolbarModule = {
return $page;
},
reallyBuildPage: function ( context, id, page, $page ) {
let i;
switch ( page.layout ) {
case 'table': {
$page.addClass( 'page-table' );
@ -511,7 +509,7 @@ const toolbarModule = {
html += toolbarModule.fn.buildHeading( context, page.headings );
}
if ( 'rows' in page ) {
for ( i = 0; i < page.rows.length; i++ ) {
for ( let i = 0; i < page.rows.length; i++ ) {
html += toolbarModule.fn.buildRow( context, page.rows[ i ] );
}
}
@ -535,7 +533,7 @@ const toolbarModule = {
}
if ( 'characters' in page ) {
let html = '';
for ( i = 0; i < page.characters.length; i++ ) {
for ( let i = 0; i < page.characters.length; i++ ) {
html += toolbarModule.fn.buildCharacter( page.characters[ i ], actions );
}
$characters
@ -769,8 +767,8 @@ const toolbarModule = {
}
},
updateBookletSelection: function ( context, id, $pages, $index ) {
let cookie = 'wikiEditor-' + context.instance + '-booklet-' + id + '-page',
selected = $.cookie( cookie );
const cookie = 'wikiEditor-' + context.instance + '-booklet-' + id + '-page';
let selected = $.cookie( cookie );
// Re-save cookie
if ( selected !== null ) {
$.cookie( cookie, selected, { expires: 30, path: '/' } );