build: Updating npm dependencies

* eslint-config-wikimedia: 0.27.0 → 0.28.2
  The following rules are failing and were disabled:
  * modules:
    * no-mixed-spaces-and-tabs
    * implicit-arrow-linebreak
  * modules/ext.templateDataGenerator.editTemplatePage:
    * no-mixed-spaces-and-tabs
    * implicit-arrow-linebreak

* grunt-stylelint: 0.20.0 → 0.20.1
* stylelint-config-wikimedia: 0.17.1 → 0.17.2

Change-Id: Ibafc7bb747791b5e9337fdb153aab39aa7893273
This commit is contained in:
libraryupgrader 2024-06-20 18:56:23 +00:00 committed by DannyS712
parent ce02a3bb5a
commit e6794ad440
14 changed files with 600 additions and 403 deletions

View file

@ -10,6 +10,8 @@
],
"rules": {
"max-len": "off",
"no-var": "off"
"no-var": "off",
"no-mixed-spaces-and-tabs": "warn",
"implicit-arrow-linebreak": "warn"
}
}

View file

@ -219,7 +219,7 @@ Model.static.splitAndTrimArray = function ( str, delim ) {
delim = delim || mw.msg( 'comma-separator' );
var arr = [];
str.split( delim ).forEach( function ( part ) {
str.split( delim ).forEach( ( part ) => {
var trimmed = part.trim();
if ( trimmed ) {
arr.push( trimmed );
@ -240,9 +240,7 @@ Model.static.arrayUnionWithoutEmpty = function () {
var result = OO.simpleArrayUnion.apply( this, arguments );
// Trim and filter empty strings
return result.filter( function ( i ) {
return i.trim();
} );
return result.filter( ( i ) => i.trim() );
};
/**
@ -305,9 +303,7 @@ Model.prototype.getMissingParams = function () {
var allParamNames = this.getAllParamNames(),
sourceCodeParameters = this.sourceCodeParameters;
return sourceCodeParameters.filter( function ( sourceCodeParameter ) {
return allParamNames.indexOf( sourceCodeParameter ) === -1;
} );
return sourceCodeParameters.filter( ( sourceCodeParameter ) => allParamNames.indexOf( sourceCodeParameter ) === -1 );
};
/**
@ -323,14 +319,14 @@ Model.prototype.importSourceCodeParameters = function () {
skippedArray = [];
// Check existing params
allParamNames.forEach( function ( paramKey ) {
allParamNames.forEach( ( paramKey ) => {
if ( model.sourceCodeParameters.indexOf( paramKey ) !== -1 ) {
existingArray.push( paramKey );
}
} );
// Add sourceCodeParameters to the model
this.sourceCodeParameters.forEach( function ( sourceCodeParameter ) {
this.sourceCodeParameters.forEach( ( sourceCodeParameter ) => {
if ( existingArray.indexOf( sourceCodeParameter ) === -1 ) {
model.addParam( sourceCodeParameter );
importedArray.push( sourceCodeParameter );
@ -486,7 +482,7 @@ Model.prototype.setTemplateDescription = function ( desc, language ) {
if ( !this.constructor.static.compare( this.description[ language ], desc ) ) {
if ( typeof desc === 'object' ) {
$.extend( this.description, desc );
Object.assign( this.description, desc );
this.emit( 'change-description', desc[ language ], language );
} else {
this.description[ language ] = desc;

View file

@ -53,7 +53,7 @@ SourceHandler.prototype.getApi = function ( page, getTemplateData ) {
var config;
if ( type === 'query' ) {
config = $.extend( baseConfig, {
config = Object.assign( baseConfig, {
prop: 'revisions',
rvprop: 'content',
indexpageids: '1'
@ -92,12 +92,10 @@ SourceHandler.prototype.buildModel = function ( wikitext ) {
// Mostly used for the import option
return this.getParametersFromTemplateSource( wikitext )
// This is always successful by definition
.then( function ( templateSourceCodeParams ) {
return Model.static.newFromObject(
tdObject,
templateSourceCodeParams
);
} );
.then( ( templateSourceCodeParams ) => Model.static.newFromObject(
tdObject,
templateSourceCodeParams
) );
};
/**
@ -131,7 +129,7 @@ SourceHandler.prototype.getParametersFromTemplateSource = function ( wikitext )
} else if ( this.isPageSubLevel() && this.getParentPage() ) {
// Get the content of the parent
this.templateSourceCodePromise = this.getApi( this.getParentPage() ).then(
function ( resp ) {
( resp ) => {
var pageContent = '';
// Verify that we have a sane response from the API.
@ -145,10 +143,9 @@ SourceHandler.prototype.getParametersFromTemplateSource = function ( wikitext )
}
return sourceHandler.extractParametersFromTemplateCode( pageContent );
},
function () {
// Resolve an empty parameters array
return $.Deferred().resolve( [] );
}
// Resolve an empty parameters array
() => $.Deferred().resolve( [] )
);
} else {
// No template found. Resolve to empty array of parameters

View file

@ -4,5 +4,9 @@
"URL",
"URLSearchParams"
]
},
"rules": {
"no-mixed-spaces-and-tabs": "warn",
"implicit-arrow-linebreak": "warn"
}
}

View file

@ -499,11 +499,9 @@ Dialog.prototype.populateMapsItems = function ( mapsObject ) {
mapsObject = mapsObject || {};
var mapKeysList = Object.keys( mapsObject );
var items = mapKeysList.map( function ( mapKey ) {
return new OO.ui.OutlineOptionWidget( {
label: mapKey
} );
} );
var items = mapKeysList.map( ( mapKey ) => new OO.ui.OutlineOptionWidget( {
label: mapKey
} ) );
this.mapsGroup.clearItems();
this.mapsGroup.addItems( items );
@ -1089,10 +1087,10 @@ Dialog.prototype.changeParamPropertyInput = function ( paramKey, propName, value
break;
case 'array':
value = value || [];
propInput.setValue( value.map( function ( v ) {
propInput.setValue( value.map( ( v ) =>
// TagMultiselectWidget accepts nothing but strings or objects with a .data property
return v && v.data ? v : String( v );
} ) );
v && v.data ? v : String( v )
) );
break;
default:
if ( typeof value === 'object' ) {
@ -1380,12 +1378,10 @@ Dialog.prototype.getSetupProcess = function ( data ) {
if ( this.availableLanguages.indexOf( defaultLanguage ) === -1 ) {
this.availableLanguages.unshift( defaultLanguage );
}
var items = this.availableLanguages.map( function ( lang ) {
return new OO.ui.MenuOptionWidget( {
data: lang,
label: $.uls.data.getAutonym( lang )
} );
} );
var items = this.availableLanguages.map( ( lang ) => new OO.ui.MenuOptionWidget( {
data: lang,
label: $.uls.data.getAutonym( lang )
} ) );
this.languageDropdownWidget.getMenu()
.addItems( items )
// Trigger the initial language choice
@ -1547,7 +1543,7 @@ Dialog.prototype.getActionProcess = function ( action ) {
return new OO.ui.Process( function () {
var dialog = this;
return OO.ui.confirm( mw.msg( 'templatedata-modal-confirmcancel' ) )
.then( function ( result ) {
.then( ( result ) => {
if ( result ) {
dialog.close();
} else {

View file

@ -65,7 +65,7 @@ function Target( $textarea, config ) {
// Check if there's already a templatedata in a related page
var relatedPage = this.isDocPage ? this.parentPage : this.pageName + '/' + this.docSubpage;
this.sourceHandler.getApi( relatedPage )
.then( function ( result ) {
.then( ( result ) => {
var response = result.query.pages[ result.query.pageids[ 0 ] ];
// HACK: When checking whether a related page (parent for /doc page or
// vice versa) already has a templatedata string, we shouldn't
@ -162,11 +162,11 @@ Target.prototype.onEditOpenDialogButton = function () {
this.sourceHandler.buildModel( this.originalWikitext )
.then(
// Success
function ( model ) {
( model ) => {
target.openEditDialog( model );
},
// Failure
function () {
() => {
// Open a message dialog
OO.ui.getWindowManager().openWindow( 'message', {
title: mw.msg( 'templatedata-modal-title' ),
@ -184,7 +184,7 @@ Target.prototype.onEditOpenDialogButton = function () {
flags: 'safe'
}
]
} ).closed.then( function ( data ) {
} ).closed.then( ( data ) => {
if ( data && data.action === 'accept' ) {
// Open the dialog with an empty model
var model = Model.static.newFromObject(
@ -268,7 +268,7 @@ Target.prototype.onDialogApply = function ( templateData ) {
label: mw.msg( 'templatedata-modal-button-apply' )
}
]
} ).closed.then( function ( data ) {
} ).closed.then( ( data ) => {
if ( data && data.action === 'apply' ) {
target.replaceTemplateData( templateData );
}

View file

@ -10,7 +10,7 @@
'use strict';
new mw.Api().loadMessages( 'templatedata-doc-subpage', { amlang: mw.config.get( 'wgContentLanguage' ) } ).then( function () {
new mw.Api().loadMessages( 'templatedata-doc-subpage', { amlang: mw.config.get( 'wgContentLanguage' ) } ).then( () => {
var Target = require( './Target.js' ),
pageName = mw.config.get( 'wgPageName' ),
docSubpage = mw.msg( 'templatedata-doc-subpage' ),
@ -50,7 +50,7 @@ new mw.Api().loadMessages( 'templatedata-doc-subpage', { amlang: mw.config.get(
}
var veTarget;
// Visual editor source mode
mw.hook( 've.activationComplete' ).add( function () {
mw.hook( 've.activationComplete' ).add( () => {
var surface = ve.init.target.getSurface();
if ( surface.getMode() === 'source' ) {
// Source mode will have created a dummy textbox
@ -65,7 +65,7 @@ new mw.Api().loadMessages( 'templatedata-doc-subpage', { amlang: mw.config.get(
}
}
} );
mw.hook( 've.deactivationComplete' ).add( function () {
mw.hook( 've.deactivationComplete' ).add( () => {
if ( veTarget ) {
veTarget.destroy();
veTarget = null;

View file

@ -12,7 +12,7 @@ var LanguageResultWidget = require( './LanguageResultWidget.js' );
*/
function LanguageSearchWidget( config ) {
// Configuration initialization
config = $.extend( {
config = Object.assign( {
placeholder: mw.msg( 'templatedata-modal-search-input-placeholder' )
}, config );
@ -22,15 +22,13 @@ function LanguageSearchWidget( config ) {
// Properties
this.filteredLanguageResultWidgets = [];
var languageCodes = Object.keys( $.uls.data.getAutonyms() ).sort();
this.languageResultWidgets = languageCodes.map( function ( languageCode ) {
return new LanguageResultWidget( {
data: {
code: languageCode,
name: $.uls.data.getAutonym( languageCode ),
autonym: $.uls.data.getAutonym( languageCode )
}
} );
} );
this.languageResultWidgets = languageCodes.map( ( languageCode ) => new LanguageResultWidget( {
data: {
code: languageCode,
name: $.uls.data.getAutonym( languageCode ),
autonym: $.uls.data.getAutonym( languageCode )
}
} ) );
this.setAvailableLanguages();
// Initialization
@ -65,15 +63,13 @@ LanguageSearchWidget.prototype.setAvailableLanguages = function ( availableLangu
return;
}
this.filteredLanguageResultWidgets = this.languageResultWidgets.map( function ( languageResult ) {
this.filteredLanguageResultWidgets = this.languageResultWidgets.map( ( languageResult ) => {
var data = languageResult.getData();
if ( availableLanguages.indexOf( data.code ) !== -1 ) {
return languageResult;
}
return null;
} ).filter( function ( languageResult ) {
return languageResult;
} );
} ).filter( ( languageResult ) => languageResult );
};
/**
@ -93,11 +89,11 @@ LanguageSearchWidget.prototype.addResults = function () {
var results = this.getResults();
results.clearItems();
this.filteredLanguageResultWidgets.forEach( function ( languageResult ) {
this.filteredLanguageResultWidgets.forEach( ( languageResult ) => {
var data = languageResult.getData();
var matchedProperty = null;
matchProperties.some( function ( prop ) {
matchProperties.some( ( prop ) => {
if ( data[ prop ] && compare( data[ prop ].slice( 0, query.length ), query ) === 0 ) {
matchedProperty = prop;
return true;

View file

@ -9,7 +9,7 @@ function ParamImportWidget( config ) {
config = config || {};
// Parent constructor
ParamImportWidget.parent.call( this, $.extend( {
ParamImportWidget.parent.call( this, Object.assign( {
icon: 'parameter-set'
}, config ) );

View file

@ -12,7 +12,7 @@ function ParamSelectWidget( config ) {
ParamSelectWidget.parent.call( this, config );
// Mixin constructors
OO.ui.mixin.DraggableGroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) );
OO.ui.mixin.DraggableGroupElement.call( this, Object.assign( {}, config, { $group: this.$element } ) );
// Initialize
this.$element.addClass( 'tdg-templateDataParamSelectWidget' );

View file

@ -12,7 +12,7 @@ function ParamWidget( data, config ) {
config = config || {};
// Parent constructor
ParamWidget.parent.call( this, $.extend( {}, config, { data: data.key, icon: 'menu' } ) );
ParamWidget.parent.call( this, Object.assign( {}, config, { data: data.key, icon: 'menu' } ) );
// Mixin constructors
OO.ui.mixin.DraggableElement.call( this, $.extend( { $handle: this.$icon } ) );
@ -65,7 +65,7 @@ ParamWidget.prototype.buildParamLabel = function () {
$paramLabel.text( this.label || this.key );
$description.text( this.description );
keys.forEach( function ( key ) {
keys.forEach( ( key ) => {
$aliases.append(
$( '<span>' )
.addClass( 'tdg-templateDataParamWidget-param-alias' )

836
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,13 +6,13 @@
"test": "grunt test"
},
"devDependencies": {
"eslint-config-wikimedia": "0.27.0",
"eslint-config-wikimedia": "0.28.2",
"grunt": "1.6.1",
"grunt-banana-checker": "0.13.0",
"grunt-contrib-watch": "1.1.0",
"grunt-eslint": "24.3.0",
"grunt-stylelint": "0.20.0",
"grunt-stylelint": "0.20.1",
"jsdoc": "4.0.2",
"stylelint-config-wikimedia": "0.17.1"
"stylelint-config-wikimedia": "0.17.2"
}
}

View file

@ -68,7 +68,7 @@ originalWikitext = 'Some text here that is not templatedata information.' +
// Prepare description language objects
resultDescCurrLang[ currLanguage ] = 'Some string here in ' + currLanguage + ' language.';
resultDescMockLang.blah = 'Some string here in blah language.';
resultDescBothLang = $.extend( {}, resultDescCurrLang, resultDescMockLang );
resultDescBothLang = Object.assign( {}, resultDescCurrLang, resultDescMockLang );
finalJsonParams = {
user: {
label: 'Username',
@ -151,7 +151,7 @@ finalJson = {
finalJson.description[ currLanguage ] = 'Label unsigned comments in a conversation.';
// Test validation tools
QUnit.test( 'Validation tools', function ( assert ) {
QUnit.test( 'Validation tools', ( assert ) => {
var i, testVars,
tests = {
compare: [
@ -387,7 +387,7 @@ QUnit.test( 'Validation tools', function ( assert ) {
} );
// Test model load
QUnit.test( 'TemplateData model', function ( assert ) {
QUnit.test( 'TemplateData model', ( assert ) => {
var i, testVars,
sourceHandler = new SourceHandler(),
paramAddTest = [
@ -435,7 +435,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
property: 'description',
language: currLanguage,
value: resultDescCurrLang[ currLanguage ],
result: $.extend( {}, paramAddTest[ 0 ].result, {
result: Object.assign( {}, paramAddTest[ 0 ].result, {
description: resultDescCurrLang
} ),
msg: 'Adding description in current language.'
@ -445,8 +445,8 @@ QUnit.test( 'TemplateData model', function ( assert ) {
property: 'description',
language: 'blah',
value: resultDescMockLang.blah,
result: $.extend( {}, paramAddTest[ 0 ].result, {
description: $.extend( {}, resultDescCurrLang, resultDescMockLang )
result: Object.assign( {}, paramAddTest[ 0 ].result, {
description: Object.assign( {}, resultDescCurrLang, resultDescMockLang )
} ),
msg: 'Adding description in mock language.'
},
@ -466,7 +466,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
property: 'description',
language: 'blah',
value: '',
result: $.extend( {}, paramAddTest[ 1 ].result, {
result: Object.assign( {}, paramAddTest[ 1 ].result, {
description: { blah: '' }
} ),
msg: 'Adding empty description in mock language.'
@ -475,7 +475,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
key: 'newParam3',
property: 'deprecated',
value: true,
result: $.extend( {}, paramAddTest[ 2 ].result, {
result: Object.assign( {}, paramAddTest[ 2 ].result, {
deprecated: true
} ),
msg: 'Adding deprecated property (boolean).'
@ -484,7 +484,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
key: 'newParam3',
property: 'deprecatedValue',
value: 'This is deprecated.',
result: $.extend( {}, paramAddTest[ 2 ].result, {
result: Object.assign( {}, paramAddTest[ 2 ].result, {
deprecated: true,
deprecatedValue: 'This is deprecated.'
} ),
@ -493,7 +493,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
];
return sourceHandler.buildModel( originalWikitext )
.done( function ( model ) {
.done( ( model ) => {
// Check description
assert.strictEqual(
model.getTemplateDescription(),
@ -560,7 +560,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
null,
'block',
'inline'
].forEach( function ( f ) {
].forEach( ( f ) => {
model.setTemplateFormat( f );
assert.deepEqual(
model.getTemplateFormat(),
@ -595,7 +595,7 @@ QUnit.test( 'TemplateData model', function ( assert ) {
} );
// Test model with maps in wikitext
QUnit.test( 'TemplateData sourceHandler with maps', function ( assert ) {
QUnit.test( 'TemplateData sourceHandler with maps', ( assert ) => {
var sourceHandler = new SourceHandler(),
wikitextWithMaps = 'Some text here that is not templatedata information.' +
'<templatedata>' +
@ -708,7 +708,7 @@ QUnit.test( 'TemplateData sourceHandler with maps', function ( assert ) {
};
return sourceHandler.buildModel( wikitextWithMaps )
.done( function ( model ) {
.done( ( model ) => {
assert.deepEqual(
model.outputTemplateData(),
jsonWithMaps,
@ -718,7 +718,7 @@ QUnit.test( 'TemplateData sourceHandler with maps', function ( assert ) {
} );
// Test model fail
QUnit.test( 'TemplateData sourceHandler failure', function ( assert ) {
QUnit.test( 'TemplateData sourceHandler failure', ( assert ) => {
var sourceHandler = new SourceHandler(),
erronousString = '<templatedata>{\n' +
'"params": {\n' +
@ -746,14 +746,14 @@ QUnit.test( 'TemplateData sourceHandler failure', function ( assert ) {
promise;
promise = sourceHandler.buildModel( erronousString );
promise.always( function () {
promise.always( () => {
assert.strictEqual( promise.state(), 'rejected', 'Promise rejected on erronous json string.' );
done();
} );
} );
// Test model gets default format
QUnit.test( 'TemplateData sourceHandler adding default format', function ( assert ) {
QUnit.test( 'TemplateData sourceHandler adding default format', ( assert ) => {
var sourceHandler = new SourceHandler(),
simpleTemplateDataNoFormat = '<templatedata>{\n' +
'"params": {}\n' +
@ -763,7 +763,7 @@ QUnit.test( 'TemplateData sourceHandler adding default format', function ( asser
};
return sourceHandler.buildModel( simpleTemplateDataNoFormat )
.done( function ( model ) {
.done( ( model ) => {
assert.deepEqual(
model.outputTemplateData(),
simpleTemplateDataDefaultFormat,
@ -772,7 +772,7 @@ QUnit.test( 'TemplateData sourceHandler adding default format', function ( asser
} );
} );
QUnit.test( 'Duplicate parameter names', function ( assert ) {
QUnit.test( 'Duplicate parameter names', ( assert ) => {
var model = new Model();
model.addParam( 'color' );
assert.deepEqual( model.getParams(), {
@ -803,7 +803,7 @@ QUnit.test( 'Duplicate parameter names', function ( assert ) {
assert.deepEqual( model.getTemplateParamOrder(), [ '1-3', '1' ] );
} );
QUnit.test( 'safesubst: hack with an unnamed parameter', function ( assert ) {
QUnit.test( 'safesubst: hack with an unnamed parameter', ( assert ) => {
var handler = new SourceHandler(),
wikitext = '{{ {{{|safesubst:}}}#invoke:…|{{{1}}}|{{{ 1 }}}}}';