build: Update linters

Bug: T202739
Change-Id: Ie3f68977598f46f7e12b216f8381b2e9dc6d83ad
This commit is contained in:
Ed Sanders 2018-09-11 12:53:15 +01:00 committed by jdlrobson
parent 5635d8863b
commit c74d2e5313
16 changed files with 17 additions and 90 deletions

View file

@ -7,8 +7,7 @@
"env": {
"browser": true,
"jquery": true,
"commonjs": true,
"qunit": true
"commonjs": true
},
"globals": {
"mediaWiki": false,

View file

@ -24,13 +24,14 @@
"babel-register": "6.24.1",
"bundlesize": "0.15.3",
"clean-webpack-plugin": "0.1.19",
"eslint-config-wikimedia": "0.6.0",
"grunt": "1.0.2",
"eslint-config-wikimedia": "0.8.1",
"eslint-plugin-qunit": "3.3.1",
"grunt": "1.0.3",
"grunt-banana-checker": "0.6.0",
"grunt-contrib-watch": "1.0.1",
"grunt-eslint": "20.1.0",
"grunt-eslint": "21.0.0",
"grunt-jsonlint": "1.1.0",
"grunt-stylelint": "0.10.0",
"grunt-stylelint": "0.10.1",
"grunt-svgmin": "5.0.0",
"husky": "0.13.3",
"jsdoc": "3.5.5",

View file

@ -0,0 +1,6 @@
{
"extends": [
"wikimedia/qunit",
"../../.eslintrc.json"
]
}

View file

@ -28,8 +28,6 @@ QUnit.test( '#boot', ( assert ) => {
}
};
assert.expect( 1, 'All assertions are executed.' );
const action = actions.boot(
false,
stubUser,
@ -106,8 +104,6 @@ QUnit.test( '#linkDwell', function ( assert ) {
const event = {},
dispatch = this.sandbox.spy();
assert.expect( 2, 'All assertions are executed.' );
this.sandbox.stub( mw, 'now' ).returns( new Date() );
this.sandbox.stub( actions, 'fetch' );
@ -159,8 +155,6 @@ QUnit.test( '#linkDwell doesn\'t continue when previews are disabled', function
const event = {},
dispatch = this.sandbox.spy();
assert.expect( 2, 'All assertions are executed.' );
// Stub the state tree being updated by the LINK_DWELL action.
this.state.preview = {
enabled: false,
@ -194,8 +188,6 @@ QUnit.test( '#linkDwell doesn\'t continue if the token has changed', function (
const event = {},
dispatch = this.sandbox.spy();
assert.expect( 1, 'All assertions are executed.' );
// Stub the state tree being updated by a LINK_DWELL action.
this.state.preview = {
enabled: true,
@ -235,8 +227,6 @@ QUnit.test( '#linkDwell dispatches the fetch action', function ( assert ) {
const event = {},
dispatch = this.sandbox.spy();
assert.expect( 1, 'All assertions are executed.' );
this.state.preview = {
enabled: true,
activeToken: generateToken()
@ -286,8 +276,6 @@ QUnit.module( 'ext.popups/actions#fetch', {
} );
QUnit.test( 'it should fetch data from the gateway immediately', function ( assert ) {
assert.expect( 3, 'All assertions are executed.' );
this.fetch();
assert.ok(
@ -311,8 +299,6 @@ QUnit.test( 'it should fetch data from the gateway immediately', function ( asse
} );
QUnit.test( 'it should dispatch the FETCH_END action when the API request ends', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const fetched = this.fetch();
this.now += 115;
@ -335,8 +321,6 @@ QUnit.test( 'it should delay dispatching the FETCH_COMPLETE action', function (
const result = {},
fetched = this.fetch();
assert.expect( 2, 'All assertions are executed.' );
assert.strictEqual(
this.wait.getCall( 0 ).args[ 0 ],
350,
@ -361,8 +345,6 @@ QUnit.test( 'it should delay dispatching the FETCH_COMPLETE action', function (
QUnit.test( 'it should dispatch the FETCH_FAILED action when the request fails', function ( assert ) {
const fetched = this.fetch();
assert.expect( 2, 'All assertions are executed.' );
this.gatewayDeferred.reject( new Error( 'API req failed' ) );
this.now += 115;
@ -384,8 +366,6 @@ QUnit.test( 'it should dispatch the FETCH_FAILED action when the request fails',
} );
QUnit.test( 'it should dispatch the FETCH_FAILED action when the request fails even after the wait timeout', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
// After the wait interval happens, resolve the gateway request
return this.waitPromise.then( () => {
this.gatewayDeferred.reject( new Error( 'API req failed' ) );
@ -452,8 +432,6 @@ QUnit.test( 'it should dispatch start and end actions', function ( assert ) {
}
} );
assert.expect( 3, 'All assertions are executed.' );
this.sandbox.stub( mw, 'now' ).returns( new Date() );
const abandoned = actions.abandon()( dispatch, getState );

View file

@ -17,11 +17,11 @@ QUnit.test( 'returns a bracketed pixel ratio', ( assert ) => {
[ 3, 2, 'when 3 returns 2' ]
];
function test( given, expected, msg ) {
function runTest( given, expected, msg ) {
assert.strictEqual( bracketedPixelRatio( given ), expected, msg );
}
cases.forEach( ( case_ ) => {
test( case_[ 0 ], case_[ 1 ], case_[ 2 ] );
runTest( case_[ 0 ], case_[ 1 ], case_[ 2 ] );
} );
} );

View file

@ -25,8 +25,6 @@ QUnit.test( 'it should only call the callback when the state has changed', funct
registerChangeListener( stubStore, spy );
assert.expect( 4, 'All assertions are executed.' );
stubStore.setState( {} );
if ( !boundChangeListener ) {

View file

@ -42,8 +42,6 @@ QUnit.module( 'ext.popups/changeListeners/footerLink @integration', {
} );
QUnit.test( 'it should append the link to the footer menu', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
this.whenLinkPreviewsBoots();
const $link = this.getLink();
@ -57,8 +55,6 @@ QUnit.test( 'it should append the link to the footer menu', function ( assert )
} );
QUnit.test( 'it should show and hide the link', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
this.whenLinkPreviewsBoots();
const $link = this.getLink();
@ -84,8 +80,6 @@ QUnit.test( 'it should show and hide the link', function ( assert ) {
} );
QUnit.test( 'it should call the showSettings bound action creator', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
this.whenLinkPreviewsBoots();
const $link = this.getLink();

View file

@ -11,8 +11,6 @@ QUnit.module( 'ext.popups/changeListeners/statsv', {
} );
QUnit.test( 'it should log the queued event', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
const state = {
statsv: {
action: 'myAction',
@ -34,8 +32,6 @@ QUnit.test( 'it should log the queued event', function ( assert ) {
} );
QUnit.test( 'it should not log when no action is given', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
const state = {
statsv: {
data: 123

View file

@ -14,8 +14,6 @@ QUnit.module( 'ext.popups/changeListeners/syncUserSettings', {
QUnit.test(
'it shouldn\'t update the storage if the preview count hasn\'t changed',
function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const state = {
eventLogging: {
previewCount: 222
@ -38,8 +36,6 @@ QUnit.test(
);
QUnit.test( 'it should update the storage if the previewCount has changed', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const prevState = {
eventLogging: {
previewCount: 222
@ -60,8 +56,6 @@ QUnit.test( 'it should update the storage if the previewCount has changed', func
QUnit.test(
'it shouldn\'t update the storage if the enabled state hasn\'t changed',
function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const state = {
preview: {
enabled: true
@ -84,8 +78,6 @@ QUnit.test(
);
QUnit.test( 'it should update the storage if the enabled flag has changed', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const prevState = {
preview: {
enabled: true

View file

@ -49,8 +49,8 @@ QUnit.test( '#get should handle values, not just functions', function ( assert )
this.container.set( 'foo', 'bar' );
assert.strictEqual(
'bar',
this.container.get( 'foo' ),
'bar',
'The container understands string values.'
);
} );

View file

@ -54,7 +54,7 @@ QUnit.test( 'Title is bold', ( assert ) => {
]
];
function test( extract, title, expected, msg ) {
function runTest( extract, title, expected, msg ) {
const $div = $( '<div>' ).append(
formatter.formatPlainTextExtract( extract, title )
);
@ -62,6 +62,6 @@ QUnit.test( 'Title is bold', ( assert ) => {
}
cases.forEach( ( case_ ) => {
test( case_[ 0 ], case_[ 1 ], case_[ 2 ], case_[ 3 ] );
runTest( case_[ 0 ], case_[ 1 ], case_[ 2 ], case_[ 3 ] );
} );
} );

View file

@ -132,11 +132,6 @@ QUnit.test( 'MediaWiki API gateway is correctly extracting the page data from th
]
];
assert.expect(
errorCases.length + successCases.length,
'All assertions are executed.'
);
errorCases.forEach( ( data, i ) => {
assert.throws(
() => { gateway.extractPageFromResponse( data ); },
@ -236,8 +231,6 @@ QUnit.test( 'MediaWiki API gateway handles missing pages', function ( assert ) {
} );
QUnit.test( 'MediaWiki API gateway is abortable', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const
deferred = $.Deferred(),
api = {

View file

@ -427,8 +427,6 @@ QUnit.test( 'RESTBase gateway handles no content success responses', function (
} );
QUnit.test( 'RESTBase gateway is abortable', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const
deferred = $.Deferred(),
api = this.sandbox.stub().returns(

View file

@ -10,14 +10,10 @@ QUnit.module( 'ext.popups/reducers#eventLogging', {
} );
QUnit.test( '@@INIT', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
assert.deepEqual( this.initialState, {}, 'The initial state is empty.' );
} );
QUnit.test( 'FETCH_START', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const action = {
type: actionTypes.FETCH_START,
timestamp: 123
@ -34,8 +30,6 @@ QUnit.test( 'FETCH_START', function ( assert ) {
} );
QUnit.test( 'FETCH_END', ( assert ) => {
assert.expect( 1, 'All assertions are executed.' );
const startedAt = 200;
const endedAt = 500;
const action = {
@ -56,8 +50,6 @@ QUnit.test( 'FETCH_END', ( assert ) => {
} );
QUnit.test( 'FETCH_FAILED', ( assert ) => {
assert.expect( 1, 'All assertions are executed.' );
const action = {
type: actionTypes.FETCH_FAILED
};
@ -74,8 +66,6 @@ QUnit.test( 'FETCH_FAILED', ( assert ) => {
} );
QUnit.test( 'LINK_DWELL', ( assert ) => {
assert.expect( 1, 'All assertions are executed.' );
const timestamp = 100;
const action = {
type: actionTypes.LINK_DWELL,
@ -93,8 +83,6 @@ QUnit.test( 'LINK_DWELL', ( assert ) => {
} );
QUnit.test( 'PREVIEW_SHOW', ( assert ) => {
assert.expect( 1, 'All assertions are executed.' );
const startedAt = 100;
const endedAt = 300;
const action = {
@ -115,8 +103,6 @@ QUnit.test( 'PREVIEW_SHOW', ( assert ) => {
} );
QUnit.test( 'STATSV_LOGGED', ( assert ) => {
assert.expect( 1, 'All assertions are executed.' );
const action = {
type: actionTypes.STATSV_LOGGED
};

View file

@ -9,8 +9,6 @@ QUnit.module( 'ext.popups/userSettings', {
} );
QUnit.test( '#getIsEnabled should return false if Page Previews have been disabled', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
this.userSettings.setIsEnabled( false );
assert.notOk(
@ -29,8 +27,6 @@ QUnit.test( '#getIsEnabled should return false if Page Previews have been disabl
} );
QUnit.test( '#hasIsEnabled', function ( assert ) {
assert.expect( 3, 'All assertions are executed.' );
assert.notOk(
this.userSettings.hasIsEnabled(),
'#hasIsEnabled should return false if the storage is empty.'
@ -58,8 +54,6 @@ QUnit.test( '#hasIsEnabled', function ( assert ) {
} );
QUnit.test( '#getPreviewCount should return the count as a number', function ( assert ) {
assert.expect( 3, 'All assertions are executed.' );
assert.strictEqual(
this.userSettings.getPreviewCount(),
0,

View file

@ -3,8 +3,6 @@ import wait from '../../src/wait';
QUnit.module( 'ext.popups/wait' );
QUnit.test( 'it should resolve after waiting', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const then = Date.now();
return wait( 150 ).then( () => {
assert.strictEqual(
@ -16,8 +14,6 @@ QUnit.test( 'it should resolve after waiting', function ( assert ) {
} );
QUnit.test( 'it should not catch after resolving', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
return wait( 0 ).catch( () => {
assert.ok( false, 'It never calls a catchable after resolution' );
} ).then( () => {
@ -26,8 +22,6 @@ QUnit.test( 'it should not catch after resolving', function ( assert ) {
} );
QUnit.test( 'it should not resolve after aborting', function ( assert ) {
assert.expect( 1, 'All assertions are executed.' );
const deferred = wait( 0 );
const chain = deferred.then( () => {
@ -42,8 +36,6 @@ QUnit.test( 'it should not resolve after aborting', function ( assert ) {
} );
QUnit.test( 'it should catch after resolving and aborting', function ( assert ) {
assert.expect( 2, 'All assertions are executed.' );
const deferred = wait( 0 );
const chain = deferred.catch( () => {