build: Update eslint and other linters

Change-Id: I0a20ad5d16d46afbc2a328f8e254295972f58ab0
This commit is contained in:
Ed Sanders 2017-10-09 15:56:15 +01:00
parent 867e75f9a0
commit 7f4dd1159b
17 changed files with 51 additions and 50 deletions

View file

@ -15,13 +15,13 @@
"devDependencies": { "devDependencies": {
"babel-preset-env": "^1.6.0", "babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1", "babel-register": "^6.24.1",
"eslint-config-wikimedia": "0.4.0", "eslint-config-wikimedia": "0.5.0",
"grunt": "1.0.1", "grunt": "1.0.1",
"grunt-banana-checker": "0.5.0", "grunt-banana-checker": "0.6.0",
"grunt-contrib-watch": "^1.0.0", "grunt-contrib-watch": "^1.0.0",
"grunt-eslint": "19.0.0", "grunt-eslint": "20.0.0",
"grunt-jsonlint": "1.1.0", "grunt-jsonlint": "1.1.0",
"grunt-stylelint": "^0.6.0", "grunt-stylelint": "0.8.0",
"husky": "^0.13.3", "husky": "^0.13.3",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"jsdoc": "^3.4.3", "jsdoc": "^3.4.3",

Binary file not shown.

View file

@ -56,7 +56,7 @@ function timedAction( baseAction ) {
* @param {Function} generateToken * @param {Function} generateToken
* @param {mw.Map} config The config of the MediaWiki client-side application, * @param {mw.Map} config The config of the MediaWiki client-side application,
* i.e. `mw.config` * i.e. `mw.config`
* @returns {Object} * @return {Object}
*/ */
export function boot( export function boot(
isEnabled, isEnabled,

View file

@ -20,7 +20,7 @@ export default function render( previewBehavior ) {
state.preview.activeEvent, state.preview.activeEvent,
previewBehavior, previewBehavior,
state.preview.activeToken state.preview.activeToken
); );
} else if ( !state.preview.shouldShow && preview ) { } else if ( !state.preview.shouldShow && preview ) {
preview.hide(); preview.hide();
preview = undefined; preview = undefined;

View file

@ -5,7 +5,7 @@ var $ = jQuery,
* Improves the plain text extracts * Improves the plain text extracts
* @param {String} plainTextExtract * @param {String} plainTextExtract
* @param {String} title * @param {String} title
* @returns {Array} * @return {Array}
*/ */
export function formatPlainTextExtract( plainTextExtract, title ) { export function formatPlainTextExtract( plainTextExtract, title ) {
var extract = plainTextExtract; var extract = plainTextExtract;

View file

@ -22,7 +22,7 @@ var mw = mediaWiki,
* @function * @function
* @name Gateway#getPageSummary * @name Gateway#getPageSummary
* @param {String} title The title of the page * @param {String} title The title of the page
* @returns {jQuery.Promise<PreviewModel>} * @return {jQuery.Promise<PreviewModel>}
*/ */
/** /**

View file

@ -28,7 +28,7 @@ var CACHE_LIFETIME = 300,
* the thumbnail. * the thumbnail.
* @param {Number} config.EXTRACT_LENGTH The maximum length, in characters, * @param {Number} config.EXTRACT_LENGTH The maximum length, in characters,
* of the extract. * of the extract.
* @returns {MediaWikiGateway} * @return {MediaWikiGateway}
*/ */
export default function createMediaWikiApiGateway( api, config ) { export default function createMediaWikiApiGateway( api, config ) {
@ -93,7 +93,7 @@ export default function createMediaWikiApiGateway( api, config ) {
* @param {Object} data The response * @param {Object} data The response
* @throws {Error} If the response is empty or doesn't contain data about the * @throws {Error} If the response is empty or doesn't contain data about the
* page * page
* @returns {Object} * @return {Object}
*/ */
function extractPageFromResponse( data ) { function extractPageFromResponse( data ) {
if ( if (
@ -113,7 +113,7 @@ function extractPageFromResponse( data ) {
* @function * @function
* @name MediaWikiGateway#formatPlainTextExtract * @name MediaWikiGateway#formatPlainTextExtract
* @param {Object} data The response * @param {Object} data The response
* @returns {Object} * @return {Object}
*/ */
function formatPlainTextExtract( data ) { function formatPlainTextExtract( data ) {
var result = $.extend( {}, data ); var result = $.extend( {}, data );
@ -127,7 +127,7 @@ function formatPlainTextExtract( data ) {
* @function * @function
* @name MediaWikiGateway#convertPageToModel * @name MediaWikiGateway#convertPageToModel
* @param {Object} page * @param {Object} page
* @returns {PreviewModel} * @return {PreviewModel}
*/ */
function convertPageToModel( page ) { function convertPageToModel( page ) {
return createModel( return createModel(

View file

@ -29,7 +29,7 @@ var RESTBASE_ENDPOINT = '/api/rest_v1/page/summary/',
* @param {Number} config.THUMBNAIL_SIZE The length of the major dimension of * @param {Number} config.THUMBNAIL_SIZE The length of the major dimension of
* the thumbnail. * the thumbnail.
* @param {Function} extractParser A function that takes response and returns parsed extract * @param {Function} extractParser A function that takes response and returns parsed extract
* @returns {RESTBaseGateway} * @return {RESTBaseGateway}
*/ */
export default function createRESTBaseGateway( ajax, config, extractParser ) { export default function createRESTBaseGateway( ajax, config, extractParser ) {
@ -97,7 +97,7 @@ export default function createRESTBaseGateway( ajax, config, extractParser ) {
* @param {Object} thumbnail The thumbnail image * @param {Object} thumbnail The thumbnail image
* @param {Object} original The original image * @param {Object} original The original image
* @param {Number} thumbSize The requested size * @param {Number} thumbSize The requested size
* @returns {Object} * @return {Object}
*/ */
function generateThumbnailData( thumbnail, original, thumbSize ) { function generateThumbnailData( thumbnail, original, thumbSize ) {
var parts = thumbnail.source.split( '/' ), var parts = thumbnail.source.split( '/' ),
@ -145,7 +145,7 @@ function generateThumbnailData( thumbnail, original, thumbSize ) {
* @param {Object} page * @param {Object} page
* @param {Number} thumbSize * @param {Number} thumbSize
* @param {Function} extractParser * @param {Function} extractParser
* @returns {PreviewModel} * @return {PreviewModel}
*/ */
function convertPageToModel( page, thumbSize, extractParser ) { function convertPageToModel( page, thumbSize, extractParser ) {
return createModel( return createModel(

View file

@ -3,7 +3,7 @@ import * as formatter from '../formatter';
/** /**
* Prepare extract * Prepare extract
* @param {Object} page Rest response * @param {Object} page Rest response
* @returns {Array} An array of DOM Elements * @return {Array} An array of DOM Elements
*/ */
export function parseHTMLResponse( page ) { export function parseHTMLResponse( page ) {
var extract = page.extract_html; var extract = page.extract_html;
@ -16,7 +16,7 @@ export function parseHTMLResponse( page ) {
/** /**
* Prepare extract * Prepare extract
* @param {Object} page Rest response * @param {Object} page Rest response
* @returns {Array} An array of DOM Elements * @return {Array} An array of DOM Elements
*/ */
export function parsePlainTextResponse( page ) { export function parsePlainTextResponse( page ) {
return formatter.formatPlainTextExtract( page.extract, page.title ); return formatter.formatPlainTextExtract( page.extract, page.title );

View file

@ -12,7 +12,7 @@
* @param {mw.user} user The `mw.user` singleton instance * @param {mw.user} user The `mw.user` singleton instance
* @param {mw.Map} config The `mw.config` singleton instance * @param {mw.Map} config The `mw.config` singleton instance
* @param {Experiments} experiments * @param {Experiments} experiments
* @returns {Boolean} * @return {Boolean}
*/ */
export function isEnabled( user, config, experiments ) { export function isEnabled( user, config, experiments ) {
var bucketingRate = config.get( 'wgPopupsStatsvSamplingRate', 0 ); var bucketingRate = config.get( 'wgPopupsStatsvSamplingRate', 0 );

View file

@ -51,7 +51,7 @@ export function getTitle( href, config ) {
* @param {String} title page title to check if it should show preview * @param {String} title page title to check if it should show preview
* @param {Number[]} contentNamespaces contentNamespaces as specified in * @param {Number[]} contentNamespaces contentNamespaces as specified in
* wgContentNamespaces * wgContentNamespaces
* @returns {mw.Title|null} * @return {mw.Title|null}
*/ */
export function isValid( title, contentNamespaces ) { export function isValid( title, contentNamespaces ) {
var mwTitle; var mwTitle;

View file

@ -344,7 +344,7 @@ export function createThumbnail( rawThumbnail ) {
( (
rawThumbnail.source.indexOf( '\\' ) > -1 || rawThumbnail.source.indexOf( '\\' ) > -1 ||
rawThumbnail.source.indexOf( '\'' ) > -1 || rawThumbnail.source.indexOf( '\'' ) > -1 ||
rawThumbnail.source.indexOf( '\"' ) > -1 rawThumbnail.source.indexOf( '"' ) > -1
) )
) { ) {
return null; return null;
@ -466,8 +466,8 @@ export function createThumbnailElement( className, url, x, y, thumbnailWidth, th
export function createLayout( isPreviewTall, eventData, linkData, windowData, pokeySize ) { export function createLayout( isPreviewTall, eventData, linkData, windowData, pokeySize ) {
var flippedX = false, var flippedX = false,
flippedY = false, flippedY = false,
offsetTop = ( eventData.pageY ) ? // If it was a mouse event offsetTop = eventData.pageY ?
// Position according to mouse // If it was a mouse event, position according to mouse
// Since client rectangles are relative to the viewport, // Since client rectangles are relative to the viewport,
// take scroll position into account. // take scroll position into account.
getClosestYPosition( getClosestYPosition(

View file

@ -8,7 +8,7 @@ var mw = window.mediaWiki,
/** /**
* Creates a render function that will create the settings dialog and return * Creates a render function that will create the settings dialog and return
* a set of methods to operate on it * a set of methods to operate on it
* @returns {Function} render function * @return {Function} render function
*/ */
export default function createSettingsDialogRenderer() { export default function createSettingsDialogRenderer() {
@ -28,7 +28,7 @@ export default function createSettingsDialogRenderer() {
/** /**
* Renders the relevant form and labels in the settings dialog * Renders the relevant form and labels in the settings dialog
* @param {Object} boundActions * @param {Object} boundActions
* @returns {Object} object with methods to affect the rendered UI * @return {Object} object with methods to affect the rendered UI
*/ */
return function ( boundActions ) { return function ( boundActions ) {
@ -198,7 +198,7 @@ function toggleHelp( $el, visible ) {
/** /**
* Checks if the NavigationPopups gadget is enabled by looking at the global * Checks if the NavigationPopups gadget is enabled by looking at the global
* variables * variables
* @returns {Boolean} if navpops was found to be enabled * @return {Boolean} if navpops was found to be enabled
*/ */
function isNavPopupsEnabled() { function isNavPopupsEnabled() {
/* global pg: false*/ /* global pg: false*/

View file

@ -6,7 +6,7 @@ QUnit.module( 'ext.popups.formatter', {
beforeEach: function () { beforeEach: function () {
window.mediaWiki.RegExp = { window.mediaWiki.RegExp = {
escape: this.sandbox.spy( function ( str ) { escape: this.sandbox.spy( function ( str ) {
return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); return str.replace( /([\\{}()|.?*+\-^$[\]])/g, '\\$1' );
} ) } )
}; };
}, },
@ -38,8 +38,8 @@ QUnit.test( 'Title is bold', function ( assert ) {
'Correct escaping' 'Correct escaping'
], ],
[ [
'\"Heroes\" is a David Bowie album', '\"Heroes\"', '"Heroes" is a David Bowie album', '"Heroes"',
'<b>\"Heroes\"</b> is a David Bowie album', '<b>"Heroes"</b> is a David Bowie album',
'Quotes in title' 'Quotes in title'
], ],
[ [
@ -67,21 +67,22 @@ QUnit.test( 'Title is bold', function ( assert ) {
} ); } );
QUnit.test( 'it strips ellipsis and parentheticals', function ( assert ) { QUnit.test( 'it strips ellipsis and parentheticals', function ( assert ) {
var i, testCase, cases = [ var i, testCase, $div,
// removeEllipsis cases = [
[ 'Extract...', 'Extract' ], // removeEllipsis
[ 'Extract.', 'Extract.' ], [ 'Extract...', 'Extract' ],
[ '..Extract..', '..Extract..' ], [ 'Extract.', 'Extract.' ],
[ '...', '' ], [ '..Extract..', '..Extract..' ],
[ '...', '' ],
// removeParentheticals // removeParentheticals
[ 'Foo', 'Foo' ], [ 'Foo', 'Foo' ],
[ 'Foo (', 'Foo (' ], [ 'Foo (', 'Foo (' ],
[ 'Foo (Bar)', 'Foo' ], [ 'Foo (Bar)', 'Foo' ],
[ 'Foo (Bar))', 'Foo (Bar))' ], [ 'Foo (Bar))', 'Foo (Bar))' ],
[ 'Foo )(Bar)', 'Foo )(Bar)' ], [ 'Foo )(Bar)', 'Foo )(Bar)' ],
[ '(Bar)', '' ] [ '(Bar)', '' ]
], $div; ];
for ( i = 0; i < cases.length; i++ ) { for ( i = 0; i < cases.length; i++ ) {
testCase = cases[ i ]; testCase = cases[ i ];

View file

@ -52,7 +52,7 @@ QUnit.module( 'ext.popups/gateway/mediawiki', {
beforeEach: function () { beforeEach: function () {
window.mediaWiki.RegExp = { window.mediaWiki.RegExp = {
escape: this.sandbox.spy( function ( str ) { escape: this.sandbox.spy( function ( str ) {
return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); return str.replace( /([\\{}()|.?*+\-^$[\]])/g, '\\$1' );
} ) } )
}; };
}, },

View file

@ -11,7 +11,7 @@ QUnit.module( 'title#getTitle', {
window.mediaWiki.RegExp = { window.mediaWiki.RegExp = {
escape: this.sandbox.spy( function ( str ) { escape: this.sandbox.spy( function ( str ) {
return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); return str.replace( /([\\{}()|.?*+\-^$[\]])/g, '\\$1' );
} ) } )
}; };

View file

@ -43,7 +43,7 @@ QUnit.module( 'ext.popups#renderer', {
window.mediaWiki.RegExp = { window.mediaWiki.RegExp = {
escape: this.sandbox.spy( function ( str ) { escape: this.sandbox.spy( function ( str ) {
return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); return str.replace( /([\\{}()|.?*+\-^$[\]])/g, '\\$1' );
} ) } )
}; };
@ -579,7 +579,7 @@ QUnit.test( 'createThumbnail - insecure URL', function ( assert ) {
var cases = [ var cases = [
'https://tall-ima\\ge.jpg', 'https://tall-ima\\ge.jpg',
'https://tall-ima\'ge.jpg', 'https://tall-ima\'ge.jpg',
'https://tall-ima\"ge.jpg' 'https://tall-ima"ge.jpg'
], ],
thumbnail; thumbnail;
@ -1087,7 +1087,7 @@ QUnit.test( '#layoutPreview - portrait preview, flipped X, has thumbnail, small
); );
assert.equal( assert.equal(
preview.el.find( '.mwe-popups-extract' ).css( 'margin-top' ), preview.el.find( '.mwe-popups-extract' ).css( 'margin-top' ),
( 199 - 8 ) + 'px', // thumb height - pokey size ( 199 - 8 ) + 'px', // thumb height - pokey size
'Extract margin top has been set when preview height is smaller than the predefined landscape image height.' 'Extract margin top has been set when preview height is smaller than the predefined landscape image height.'
); );
assert.equal( assert.equal(
@ -1161,7 +1161,7 @@ QUnit.test( '#layoutPreview - tall preview, has thumbnail, flipped Y', function
); );
assert.equal( assert.equal(
preview.el.css( 'top' ), preview.el.css( 'top' ),
( layout.offset.top - 20 ) + 'px', // - outer height ( layout.offset.top - 20 ) + 'px', // - outer height
'Top is correct.' 'Top is correct.'
); );
assert.equal( assert.equal(
@ -1199,7 +1199,7 @@ QUnit.test( '#layoutPreview - tall preview, has thumbnail, flipped X and Y', fun
); );
assert.equal( assert.equal(
preview.el.css( 'top' ), preview.el.css( 'top' ),
( layout.offset.top - 20 ) + 'px', // - outer height ( layout.offset.top - 20 ) + 'px', // - outer height
'Top is correct.' 'Top is correct.'
); );
assert.equal( assert.equal(
@ -1238,7 +1238,7 @@ QUnit.test( '#layoutPreview - portrait preview, has thumbnail, flipped X and Y',
); );
assert.equal( assert.equal(
preview.el.css( 'top' ), preview.el.css( 'top' ),
( layout.offset.top - 20 ) + 'px', // - outer height ( layout.offset.top - 20 ) + 'px', // - outer height
'Top is correct.' 'Top is correct.'
); );
assert.equal( assert.equal(