mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-12 01:08:39 +00:00
build: Update eslint and other linters
Change-Id: I0a20ad5d16d46afbc2a328f8e254295972f58ab0
This commit is contained in:
parent
867e75f9a0
commit
7f4dd1159b
|
@ -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",
|
||||
|
|
BIN
resources/dist/index.js.json
vendored
BIN
resources/dist/index.js.json
vendored
Binary file not shown.
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -22,7 +22,7 @@ var mw = mediaWiki,
|
|||
* @function
|
||||
* @name Gateway#getPageSummary
|
||||
* @param {String} title The title of the page
|
||||
* @returns {jQuery.Promise<PreviewModel>}
|
||||
* @return {jQuery.Promise<PreviewModel>}
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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*/
|
||||
|
|
|
@ -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\"',
|
||||
'<b>\"Heroes\"</b> is a David Bowie album',
|
||||
'"Heroes" is a David Bowie album', '"Heroes"',
|
||||
'<b>"Heroes"</b> 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 ];
|
||||
|
|
|
@ -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' );
|
||||
} )
|
||||
};
|
||||
},
|
||||
|
|
|
@ -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' );
|
||||
} )
|
||||
};
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue