build: Update eslint-config-wikimedia to 0.16.2

Change-Id: Icb65074fe64993314bbb28f690ce3ce0f89fb57c
This commit is contained in:
Ed Sanders 2020-06-22 22:49:14 +01:00 committed by James D. Forrester
parent c0b7758ed2
commit 536470c01d
31 changed files with 433 additions and 501 deletions

View file

@ -1,23 +1,25 @@
{
"root": true,
"extends": [
"wikimedia/client",
"wikimedia/common",
"wikimedia/language/es6",
"wikimedia/jquery",
"wikimedia/language/es6"
"wikimedia/mediawiki"
],
"parserOptions": {
"sourceType": "module"
},
"env": {
"browser": true,
"jquery": true,
"commonjs": true
},
"globals": {
"mw": "readonly",
"OO": "readonly"
},
"rules": {
"no-use-before-define": "off"
"no-use-before-define": "off",
"jsdoc/no-undefined-types": "off"
},
"settings": {
"jsdoc": {
"mode": "typescript"
}
}
}

2
.gitattributes vendored
View file

@ -1,3 +1,3 @@
resources/dist/** -diff -whitespace
resources/dist/.eslintrc.js diff whitespace
resources/dist/.eslintrc.json diff whitespace
package-lock.json -diff -whitespace

View file

@ -15,7 +15,6 @@ module.exports = function ( grunt ) {
options: {
cache: true,
maxWarnings: 0,
extensions: [ '.js', '.json' ],
fix: grunt.option( 'fix' )
},
all: {

815
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -33,12 +33,12 @@
"bundlesize": "0.18.0",
"clean-webpack-plugin": "3.0.0",
"cssjanus": "1.3.1",
"eslint-config-wikimedia": "0.15.3",
"eslint-config-wikimedia": "0.16.2",
"expose-loader": "0.7.5",
"grunt": "1.0.4",
"grunt-banana-checker": "0.8.1",
"grunt-contrib-watch": "1.1.0",
"grunt-eslint": "22.0.0",
"grunt-eslint": "23.0.0",
"grunt-stylelint": "0.11.1",
"grunt-svgmin": "5.0.0",
"jquery": "3.4.1",

Binary file not shown.

7
resources/dist/.eslintrc.json vendored Normal file
View file

@ -0,0 +1,7 @@
{
"root": true,
"extends": "wikimedia/language/es5",
"rules": {
"es/no-object-getownpropertysymbols": "off"
}
}

Binary file not shown.

View file

@ -35,6 +35,7 @@ export default function syncUserSettings( userSettings ) {
/**
* Given a state tree, reducer and property, safely return the value of the
* property if the reducer and property exist
*
* @param {Object} state tree
* @param {string} reducer key to access on the state tree
* @param {string} prop key to access on the reducer key of the state tree
@ -47,6 +48,7 @@ function get( state, reducer, prop ) {
/**
* Calls a sync function if the property prop on the property reducer on
* the state trees has changed value.
*
* @param {Object} prevState
* @param {Object} state
* @param {string} reducer key to access on the state tree

View file

@ -1,5 +1,6 @@
/**
* Improves the plain text extracts
*
* @param {string} plainTextExtract
* @param {string} title
* @return {Array}

View file

@ -4,18 +4,20 @@
/**
* The interface implemented by all preview gateways.
*
* @typedef Gateway
* @prop {Function(string): JQuery.jqXHR} fetch
* @prop {FetchPreviewForTitle} fetchPreviewForTitle
* @prop {ConvertPageToModel} convertPageToModel
* @property {function(string): JQuery.jqXHR} fetch
* @property {FetchPreviewForTitle} fetchPreviewForTitle
* @property {ConvertPageToModel} convertPageToModel
*/
/**
* A Promise, usually for a long running or costly task such as an HTTP request,
* that is abortable.
*
* @template T
* @typedef {JQuery.Promise<T>} AbortPromise
* @prop {Function(): void} abort
* @property {function(): void} abort
*/
/**
@ -24,11 +26,11 @@
* If the underlying request is successful and contains data for the requested title,
* then the resulting promise will resolve. If not, then it will reject.
*
* @typedef {Function(mw.Title, Element): AbortPromise<PreviewModel>} FetchPreviewForTitle
* @typedef {function(mw.Title, Element): AbortPromise<PreviewModel>} FetchPreviewForTitle
*/
/**
* Converts the API response to a preview model. Exposed for testing only.
*
* @typedef {Function(object, ...any): PagePreviewModel} ConvertPageToModel
* @typedef {function(Object, ...any): PagePreviewModel} ConvertPageToModel
*/

View file

@ -12,8 +12,8 @@ const CACHE_LIFETIME = 300;
/**
* @typedef {Gateway} MediaWikiGateway
* @prop {Function(object): object} extractPageFromResponse
* @prop {Function(object): object} formatPlainTextExtract
* @property {function(Object): Object} extractPageFromResponse
* @property {function(Object): Object} formatPlainTextExtract
*/
/**

View file

@ -14,6 +14,7 @@ export default function createReferenceGateway() {
/**
* Same alternative selectors with and without mw- as in the RESTbased endpoint.
*
* @see https://phabricator.wikimedia.org/diffusion/GMOA/browse/master/lib/transformations/references/structureReferenceListContent.js$138
*/
return $( `${idSelector} .mw-reference-text, ${idSelector} .reference-text` );
@ -28,6 +29,7 @@ export default function createReferenceGateway() {
* returned as "web paywalled". Validation must be done in the code consuming this.
*
* This duplicates the strict type detection from
*
* @see https://phabricator.wikimedia.org/diffusion/GMOA/browse/master/lib/transformations/references/structureReferenceListContent.js$93
*
* @param {JQuery} $referenceText

View file

@ -6,7 +6,7 @@ import { createModel } from '../preview/model';
const RESTBASE_PROFILE = 'https://www.mediawiki.org/wiki/Specs/Summary/1.2.0';
/** @typedef {Function(JQuery.AjaxSettings=): JQuery.jqXHR} Ajax */
/** @typedef {function(JQuery.AjaxSettings=): JQuery.jqXHR} Ajax */
/**
* Creates an instance of the RESTBase gateway.

View file

@ -2,6 +2,7 @@ import * as formatter from '../formatter';
/**
* Prepare extract
*
* @param {Object} page Rest response
* @return {Array} An array of DOM Elements
*/
@ -13,6 +14,7 @@ export function parseHTMLResponse( page ) {
/**
* Prepare extract
*
* @param {Object} page Rest response
* @return {Array} An array of DOM Elements
*/

View file

@ -7,7 +7,7 @@
*
* Loads code from the server to the client on demand.
*
* @param {array} dependencies to load
* @param {Array} dependencies to load
* @return {JQuery.Deferred} resolving when the code is loaded and
* can be used by the client.
*

View file

@ -6,7 +6,7 @@
* Page Preview types as defined in Schema:Popups
* https://meta.wikimedia.org/wiki/Schema:Popups
*
* @constant {Object}
* @const {Object}
*/
const previewTypes = {
/** Empty preview used in error situations */

View file

@ -44,6 +44,7 @@ export function createPointerMasks( container ) {
/**
* Initializes the renderer.
*
* @return {void}
*/
export function init() {
@ -316,6 +317,8 @@ export function hide( preview ) {
'mwe-popups-fade-out-down' :
'mwe-popups-fade-out-up';
// Classes documented above
// eslint-disable-next-line mediawiki/class-doc
preview.el
.removeClass( fadeInClass )
.addClass( fadeOutClass );
@ -518,6 +521,7 @@ export function layoutPreview(
);
}
// eslint-disable-next-line mediawiki/class-doc
popup.addClass( classes.join( ' ' ) );
if ( flippedY ) {

View file

@ -7,6 +7,7 @@ import { createSettingsDialog } from './settingsDialog';
/**
* Creates a render function that will create the settings dialog and return
* a set of methods to operate on it
*
* @return {Function} render function
*/
export default function createSettingsDialogRenderer() {
@ -25,6 +26,7 @@ export default function createSettingsDialogRenderer() {
/**
* Renders the relevant form and labels in the settings dialog
*
* @param {Object} boundActions
* @return {Object} object with methods to affect the rendered UI
*/
@ -50,6 +52,7 @@ export default function createSettingsDialogRenderer() {
return {
/**
* Append the dialog and overlay to a DOM element
*
* @param {HTMLElement} el
* @return {void}
*/
@ -60,6 +63,7 @@ export default function createSettingsDialogRenderer() {
/**
* Show the settings element and position it correctly
*
* @return {void}
*/
show() {
@ -68,6 +72,7 @@ export default function createSettingsDialogRenderer() {
/**
* Hide the settings dialog.
*
* @return {void}
*/
hide() {
@ -76,6 +81,7 @@ export default function createSettingsDialogRenderer() {
/**
* Toggle the help dialog on or off
*
* @param {boolean} visible if you want to show or hide the help dialog
* @return {void}
*/
@ -123,6 +129,7 @@ function getSelectedSetting( $el ) {
/**
* Toggles the visibility between a form and the help
*
* @param {JQuery.Object} $el element that contains form and help
* @param {boolean} visible if the help should be visible, or the form
* @return {void}
@ -145,6 +152,7 @@ function toggleHelp( $el, visible ) {
/**
* Checks if the NavigationPopups gadget is enabled by looking at the global
* variables
*
* @return {boolean} if navpops was found to be enabled
*/
function isNavPopupsEnabled() {

View file

@ -29,13 +29,13 @@ export function renderReferencePreview(
model
) {
const type = KNOWN_TYPES.indexOf( model.referenceType ) < 0 ? 'generic' : model.referenceType,
// Messages:
// popups-refpreview-book
// popups-refpreview-journal
// popups-refpreview-news
// popups-refpreview-reference
// popups-refpreview-web
titleMsg = `popups-refpreview-${type === 'generic' ? 'reference' : type}`,
// The following messages are used here:
// * popups-refpreview-book
// * popups-refpreview-journal
// * popups-refpreview-news
// * popups-refpreview-reference
// * popups-refpreview-web
title = escapeHTML( mw.msg( titleMsg ) ),
url = escapeHTML( model.url ),
linkMsg = escapeHTML( mw.msg( 'popups-refpreview-jump-to-reference' ) );

View file

@ -151,6 +151,7 @@ export function createThumbnailElement(
const $thumbnailSVGImage = $( document.createElementNS( nsSvg, 'image' ) );
$thumbnailSVGImage[ 0 ].setAttributeNS( nsXlink, 'href', url );
// eslint-disable-next-line mediawiki/class-doc
$thumbnailSVGImage
.addClass( className )
.attr( {

View file

@ -1,7 +1,6 @@
{
"extends": [
"wikimedia/qunit",
"../../.eslintrc.json"
"wikimedia/qunit"
],
"rules": {
"no-jquery/no-class-state": "off"

View file

@ -9,6 +9,7 @@ import { previewTypes } from '../../src/preview/model';
/**
* Whether Gateway#fetchPreviewForTitle is resolved or rejected.
*
* @enum {number}
*/
const FETCH_RESOLUTION = { RESOLVE: 0, REJECT: 1 };

View file

@ -40,6 +40,7 @@ export function createStubMap() {
/**
* Creates a stub that can be used as a replacement to mw.experiements
*
* @param {string} bucket getBucket will respond with this bucket.
* @return {Object}
*/

View file

@ -1,14 +1,9 @@
{
"root": true,
"extends": [
"wikimedia/server"
"wikimedia/selenium"
],
"env": {
"mocha": true,
"browser": true
},
"globals": {
"browser": "readonly",
"mw": "readonly"
}
}

View file

@ -1,3 +1,7 @@
'use strict';
/* global document */
const
fs = require( 'fs' ),
Api = require( 'wdio-mediawiki/Api' ),

View file

@ -1,3 +1,5 @@
'use strict';
const assert = require( 'assert' ),
page = require( '../pageobjects/popups.page' );

View file

@ -1,3 +1,5 @@
'use strict';
const assert = require( 'assert' ),
page = require( '../pageobjects/popups.page' );

View file

@ -1,3 +1,5 @@
'use strict';
const fs = require( 'fs' ),
saveScreenshot = require( 'wdio-mediawiki' ).saveScreenshot,
logPath = process.env.LOG_DIR || `${__dirname}/log`;
@ -114,9 +116,8 @@ exports.config = {
*
*/
afterTest: function ( test ) {
let filePath;
if ( !test.passed ) {
filePath = saveScreenshot( test.title );
const filePath = saveScreenshot( test.title );
console.log( `\n\tScreenshot: ${filePath}\n` );
}
}

View file

@ -101,7 +101,7 @@ module.exports = ( env, argv ) => ( {
plugins: [
// Delete the output directory on each build.
new CleanWebpackPlugin( {
cleanOnceBeforeBuildPatterns: [ '**/*', '!.eslintrc.js' ]
cleanOnceBeforeBuildPatterns: [ '**/*', '!.eslintrc.json' ]
} )
],