From 7f4dd1159b46e1f4ee28d598d42f907d1ad47cf6 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 9 Oct 2017 15:56:15 +0100 Subject: [PATCH] build: Update eslint and other linters Change-Id: I0a20ad5d16d46afbc2a328f8e254295972f58ab0 --- package.json | 8 ++--- resources/dist/index.js.json | Bin 306921 -> 306870 bytes src/actions.js | 2 +- src/changeListeners/render.js | 2 +- src/formatter.js | 2 +- src/gateway/index.js | 2 +- src/gateway/mediawiki.js | 8 ++--- src/gateway/rest.js | 6 ++-- src/gateway/restFormatters.js | 4 +-- src/instrumentation/statsv.js | 2 +- src/title.js | 2 +- src/ui/renderer.js | 6 ++-- src/ui/settingsDialog.js | 6 ++-- tests/node-qunit/formatter.test.js | 35 +++++++++++---------- tests/node-qunit/gateway/mediawiki.test.js | 2 +- tests/node-qunit/title.test.js | 2 +- tests/node-qunit/ui/renderer.test.js | 12 +++---- 17 files changed, 51 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index b80a828a0..9c6f6c9fe 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "devDependencies": { "babel-preset-env": "^1.6.0", "babel-register": "^6.24.1", - "eslint-config-wikimedia": "0.4.0", + "eslint-config-wikimedia": "0.5.0", "grunt": "1.0.1", - "grunt-banana-checker": "0.5.0", + "grunt-banana-checker": "0.6.0", "grunt-contrib-watch": "^1.0.0", - "grunt-eslint": "19.0.0", + "grunt-eslint": "20.0.0", "grunt-jsonlint": "1.1.0", - "grunt-stylelint": "^0.6.0", + "grunt-stylelint": "0.8.0", "husky": "^0.13.3", "istanbul": "^0.4.5", "jsdoc": "^3.4.3", diff --git a/resources/dist/index.js.json b/resources/dist/index.js.json index c25dfbf6889702dbeee82dc61f1fa58127d3fa13..756c184de9b4f8a8413daee742609dd97ac27707 100644 GIT binary patch delta 715 zcma)(Ur3W-6o)zQ`S#bCHdAwfsEOj5qD?kdS!i15h?Yha8g1F9ja|T6*M2agj zJ1Z+wtcVD-k>^5;?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F|ixZ`?u*0*j63+PJTAJdNiqspQ>r2hh%Dd^__ diff --git a/src/actions.js b/src/actions.js index 9be1cf391..39b05fd1a 100644 --- a/src/actions.js +++ b/src/actions.js @@ -56,7 +56,7 @@ function timedAction( baseAction ) { * @param {Function} generateToken * @param {mw.Map} config The config of the MediaWiki client-side application, * i.e. `mw.config` - * @returns {Object} + * @return {Object} */ export function boot( isEnabled, diff --git a/src/changeListeners/render.js b/src/changeListeners/render.js index b08b7e386..93eedb33f 100644 --- a/src/changeListeners/render.js +++ b/src/changeListeners/render.js @@ -20,7 +20,7 @@ export default function render( previewBehavior ) { state.preview.activeEvent, previewBehavior, state.preview.activeToken - ); + ); } else if ( !state.preview.shouldShow && preview ) { preview.hide(); preview = undefined; diff --git a/src/formatter.js b/src/formatter.js index a6604afda..9fef4ed8e 100644 --- a/src/formatter.js +++ b/src/formatter.js @@ -5,7 +5,7 @@ var $ = jQuery, * Improves the plain text extracts * @param {String} plainTextExtract * @param {String} title - * @returns {Array} + * @return {Array} */ export function formatPlainTextExtract( plainTextExtract, title ) { var extract = plainTextExtract; diff --git a/src/gateway/index.js b/src/gateway/index.js index 0dfad250c..699d5a8ef 100644 --- a/src/gateway/index.js +++ b/src/gateway/index.js @@ -22,7 +22,7 @@ var mw = mediaWiki, * @function * @name Gateway#getPageSummary * @param {String} title The title of the page - * @returns {jQuery.Promise} + * @return {jQuery.Promise} */ /** diff --git a/src/gateway/mediawiki.js b/src/gateway/mediawiki.js index bd8765a43..f565489f5 100644 --- a/src/gateway/mediawiki.js +++ b/src/gateway/mediawiki.js @@ -28,7 +28,7 @@ var CACHE_LIFETIME = 300, * the thumbnail. * @param {Number} config.EXTRACT_LENGTH The maximum length, in characters, * of the extract. - * @returns {MediaWikiGateway} + * @return {MediaWikiGateway} */ export default function createMediaWikiApiGateway( api, config ) { @@ -93,7 +93,7 @@ export default function createMediaWikiApiGateway( api, config ) { * @param {Object} data The response * @throws {Error} If the response is empty or doesn't contain data about the * page - * @returns {Object} + * @return {Object} */ function extractPageFromResponse( data ) { if ( @@ -113,7 +113,7 @@ function extractPageFromResponse( data ) { * @function * @name MediaWikiGateway#formatPlainTextExtract * @param {Object} data The response - * @returns {Object} + * @return {Object} */ function formatPlainTextExtract( data ) { var result = $.extend( {}, data ); @@ -127,7 +127,7 @@ function formatPlainTextExtract( data ) { * @function * @name MediaWikiGateway#convertPageToModel * @param {Object} page - * @returns {PreviewModel} + * @return {PreviewModel} */ function convertPageToModel( page ) { return createModel( diff --git a/src/gateway/rest.js b/src/gateway/rest.js index 7624bf7cc..ece8e1805 100644 --- a/src/gateway/rest.js +++ b/src/gateway/rest.js @@ -29,7 +29,7 @@ var RESTBASE_ENDPOINT = '/api/rest_v1/page/summary/', * @param {Number} config.THUMBNAIL_SIZE The length of the major dimension of * the thumbnail. * @param {Function} extractParser A function that takes response and returns parsed extract - * @returns {RESTBaseGateway} + * @return {RESTBaseGateway} */ 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} original The original image * @param {Number} thumbSize The requested size - * @returns {Object} + * @return {Object} */ function generateThumbnailData( thumbnail, original, thumbSize ) { var parts = thumbnail.source.split( '/' ), @@ -145,7 +145,7 @@ function generateThumbnailData( thumbnail, original, thumbSize ) { * @param {Object} page * @param {Number} thumbSize * @param {Function} extractParser - * @returns {PreviewModel} + * @return {PreviewModel} */ function convertPageToModel( page, thumbSize, extractParser ) { return createModel( diff --git a/src/gateway/restFormatters.js b/src/gateway/restFormatters.js index a18794097..5822d5dbd 100644 --- a/src/gateway/restFormatters.js +++ b/src/gateway/restFormatters.js @@ -3,7 +3,7 @@ import * as formatter from '../formatter'; /** * Prepare extract * @param {Object} page Rest response - * @returns {Array} An array of DOM Elements + * @return {Array} An array of DOM Elements */ export function parseHTMLResponse( page ) { var extract = page.extract_html; @@ -16,7 +16,7 @@ export function parseHTMLResponse( page ) { /** * Prepare extract * @param {Object} page Rest response - * @returns {Array} An array of DOM Elements + * @return {Array} An array of DOM Elements */ export function parsePlainTextResponse( page ) { return formatter.formatPlainTextExtract( page.extract, page.title ); diff --git a/src/instrumentation/statsv.js b/src/instrumentation/statsv.js index 8f8de8c5a..72c354d37 100644 --- a/src/instrumentation/statsv.js +++ b/src/instrumentation/statsv.js @@ -12,7 +12,7 @@ * @param {mw.user} user The `mw.user` singleton instance * @param {mw.Map} config The `mw.config` singleton instance * @param {Experiments} experiments - * @returns {Boolean} + * @return {Boolean} */ export function isEnabled( user, config, experiments ) { var bucketingRate = config.get( 'wgPopupsStatsvSamplingRate', 0 ); diff --git a/src/title.js b/src/title.js index 9d2c1556e..4b2720d44 100644 --- a/src/title.js +++ b/src/title.js @@ -51,7 +51,7 @@ export function getTitle( href, config ) { * @param {String} title page title to check if it should show preview * @param {Number[]} contentNamespaces contentNamespaces as specified in * wgContentNamespaces - * @returns {mw.Title|null} + * @return {mw.Title|null} */ export function isValid( title, contentNamespaces ) { var mwTitle; diff --git a/src/ui/renderer.js b/src/ui/renderer.js index 7d84e8817..2429b3f42 100644 --- a/src/ui/renderer.js +++ b/src/ui/renderer.js @@ -344,7 +344,7 @@ export function createThumbnail( rawThumbnail ) { ( rawThumbnail.source.indexOf( '\\' ) > -1 || rawThumbnail.source.indexOf( '\'' ) > -1 || - rawThumbnail.source.indexOf( '\"' ) > -1 + rawThumbnail.source.indexOf( '"' ) > -1 ) ) { return null; @@ -466,8 +466,8 @@ export function createThumbnailElement( className, url, x, y, thumbnailWidth, th export function createLayout( isPreviewTall, eventData, linkData, windowData, pokeySize ) { var flippedX = false, flippedY = false, - offsetTop = ( eventData.pageY ) ? // If it was a mouse event - // Position according to mouse + offsetTop = eventData.pageY ? + // If it was a mouse event, position according to mouse // Since client rectangles are relative to the viewport, // take scroll position into account. getClosestYPosition( diff --git a/src/ui/settingsDialog.js b/src/ui/settingsDialog.js index 873701cee..bf13b1193 100644 --- a/src/ui/settingsDialog.js +++ b/src/ui/settingsDialog.js @@ -8,7 +8,7 @@ var mw = window.mediaWiki, /** * Creates a render function that will create the settings dialog and return * a set of methods to operate on it - * @returns {Function} render function + * @return {Function} render function */ export default function createSettingsDialogRenderer() { @@ -28,7 +28,7 @@ export default function createSettingsDialogRenderer() { /** * Renders the relevant form and labels in the settings dialog * @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 ) { @@ -198,7 +198,7 @@ function toggleHelp( $el, visible ) { /** * Checks if the NavigationPopups gadget is enabled by looking at the global * variables - * @returns {Boolean} if navpops was found to be enabled + * @return {Boolean} if navpops was found to be enabled */ function isNavPopupsEnabled() { /* global pg: false*/ diff --git a/tests/node-qunit/formatter.test.js b/tests/node-qunit/formatter.test.js index 3c3d29807..27dc543d4 100644 --- a/tests/node-qunit/formatter.test.js +++ b/tests/node-qunit/formatter.test.js @@ -6,7 +6,7 @@ QUnit.module( 'ext.popups.formatter', { beforeEach: function () { window.mediaWiki.RegExp = { 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' ], [ - '\"Heroes\" is a David Bowie album', '\"Heroes\"', - '\"Heroes\" is a David Bowie album', + '"Heroes" is a David Bowie album', '"Heroes"', + '"Heroes" is a David Bowie album', 'Quotes in title' ], [ @@ -67,21 +67,22 @@ QUnit.test( 'Title is bold', function ( assert ) { } ); QUnit.test( 'it strips ellipsis and parentheticals', function ( assert ) { - var i, testCase, cases = [ - // removeEllipsis - [ 'Extract...', 'Extract' ], - [ 'Extract.', 'Extract.' ], - [ '..Extract..', '..Extract..' ], - [ '...', '' ], + var i, testCase, $div, + cases = [ + // removeEllipsis + [ 'Extract...', 'Extract' ], + [ 'Extract.', 'Extract.' ], + [ '..Extract..', '..Extract..' ], + [ '...', '' ], - // removeParentheticals - [ 'Foo', 'Foo' ], - [ 'Foo (', 'Foo (' ], - [ 'Foo (Bar)', 'Foo' ], - [ 'Foo (Bar))', 'Foo (Bar))' ], - [ 'Foo )(Bar)', 'Foo )(Bar)' ], - [ '(Bar)', '' ] - ], $div; + // removeParentheticals + [ 'Foo', 'Foo' ], + [ 'Foo (', 'Foo (' ], + [ 'Foo (Bar)', 'Foo' ], + [ 'Foo (Bar))', 'Foo (Bar))' ], + [ 'Foo )(Bar)', 'Foo )(Bar)' ], + [ '(Bar)', '' ] + ]; for ( i = 0; i < cases.length; i++ ) { testCase = cases[ i ]; diff --git a/tests/node-qunit/gateway/mediawiki.test.js b/tests/node-qunit/gateway/mediawiki.test.js index f60cb132f..c63d3f505 100644 --- a/tests/node-qunit/gateway/mediawiki.test.js +++ b/tests/node-qunit/gateway/mediawiki.test.js @@ -52,7 +52,7 @@ QUnit.module( 'ext.popups/gateway/mediawiki', { beforeEach: function () { window.mediaWiki.RegExp = { escape: this.sandbox.spy( function ( str ) { - return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); + return str.replace( /([\\{}()|.?*+\-^$[\]])/g, '\\$1' ); } ) }; }, diff --git a/tests/node-qunit/title.test.js b/tests/node-qunit/title.test.js index 0333a911b..fb4faeca5 100644 --- a/tests/node-qunit/title.test.js +++ b/tests/node-qunit/title.test.js @@ -11,7 +11,7 @@ QUnit.module( 'title#getTitle', { window.mediaWiki.RegExp = { escape: this.sandbox.spy( function ( str ) { - return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); + return str.replace( /([\\{}()|.?*+\-^$[\]])/g, '\\$1' ); } ) }; diff --git a/tests/node-qunit/ui/renderer.test.js b/tests/node-qunit/ui/renderer.test.js index 051322e71..3bdfb8129 100644 --- a/tests/node-qunit/ui/renderer.test.js +++ b/tests/node-qunit/ui/renderer.test.js @@ -43,7 +43,7 @@ QUnit.module( 'ext.popups#renderer', { window.mediaWiki.RegExp = { 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 = [ 'https://tall-ima\\ge.jpg', 'https://tall-ima\'ge.jpg', - 'https://tall-ima\"ge.jpg' + 'https://tall-ima"ge.jpg' ], thumbnail; @@ -1087,7 +1087,7 @@ QUnit.test( '#layoutPreview - portrait preview, flipped X, has thumbnail, small ); assert.equal( 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.' ); assert.equal( @@ -1161,7 +1161,7 @@ QUnit.test( '#layoutPreview - tall preview, has thumbnail, flipped Y', function ); assert.equal( preview.el.css( 'top' ), - ( layout.offset.top - 20 ) + 'px', // - outer height + ( layout.offset.top - 20 ) + 'px', // - outer height 'Top is correct.' ); assert.equal( @@ -1199,7 +1199,7 @@ QUnit.test( '#layoutPreview - tall preview, has thumbnail, flipped X and Y', fun ); assert.equal( preview.el.css( 'top' ), - ( layout.offset.top - 20 ) + 'px', // - outer height + ( layout.offset.top - 20 ) + 'px', // - outer height 'Top is correct.' ); assert.equal( @@ -1238,7 +1238,7 @@ QUnit.test( '#layoutPreview - portrait preview, has thumbnail, flipped X and Y', ); assert.equal( preview.el.css( 'top' ), - ( layout.offset.top - 20 ) + 'px', // - outer height + ( layout.offset.top - 20 ) + 'px', // - outer height 'Top is correct.' ); assert.equal(