build: Update linters

Change-Id: I9747097fdf725992710f97d4ce4ea49fd611df1b
This commit is contained in:
Ed Sanders 2018-09-11 23:46:52 +01:00
parent 8fff5360d9
commit 2c089e075d
13 changed files with 64 additions and 56 deletions

View file

@ -10,6 +10,7 @@
"mediaWiki": false
},
"rules": {
"dot-notation": [ "error", { "allowKeywords": true } ]
"dot-notation": [ "error", { "allowKeywords": true } ],
"max-len": 0
}
}

View file

@ -262,7 +262,7 @@
var model;
for ( model in this.notificationModels ) {
if ( this.notificationModels.hasOwnProperty( model ) ) {
if ( Object.prototype.hasOwnProperty.call( this.notificationModels, model ) ) {
this.notificationModels[ model ].disconnect( this );
delete this.notificationModels[ model ];
}

View file

@ -83,7 +83,7 @@
this.reset();
for ( source in sourceData ) {
if ( sourceData.hasOwnProperty( source ) ) {
if ( Object.prototype.hasOwnProperty.call( sourceData, source ) ) {
this.setSourcePagesDetails( source, sourceData[ source ] );
}
}

View file

@ -10,16 +10,17 @@
"selenium-daily": "npm run selenium-test"
},
"devDependencies": {
"eslint-config-wikimedia": "0.5.0",
"grunt": "1.0.1",
"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.0",
"grunt-eslint": "20.1.0",
"grunt-eslint": "21.0.0",
"grunt-jsonlint": "1.1.0",
"grunt-stylelint": "0.9.0",
"grunt-stylelint": "0.10.1",
"grunt-svgmin": "5.0.0",
"stylelint": "8.2.0",
"stylelint-config-wikimedia": "0.4.2",
"stylelint": "9.2.0",
"stylelint-config-wikimedia": "0.4.3",
"wdio-mediawiki": "0.1.7",
"wdio-mocha-framework": "0.5.13",
"wdio-spec-reporter": "0.1.4",

View file

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

View file

@ -15,13 +15,13 @@
{ modelName: 'foo' }
);
assert.equal(
assert.strictEqual(
bundle.getCount(),
5,
'Bundled items added to internal list'
);
assert.equal(
assert.strictEqual(
bundle.getName(),
'foo',
'Bundle name stored'
@ -33,13 +33,13 @@
'All ids present'
);
assert.equal(
assert.strictEqual(
bundle.isRead(),
false,
'Bundle with all unread items is unread'
);
assert.equal(
assert.strictEqual(
bundle.hasUnseen(),
true,
'Bundle has unseen items'
@ -74,7 +74,7 @@
}
);
assert.equal(
assert.strictEqual(
bundle.hasUnseen(),
true,
'Bundle has unseen'
@ -85,20 +85,20 @@
bundledItems[ i ].toggleSeen( true );
}
assert.equal(
assert.strictEqual(
bundle.hasUnseen(),
false,
'Bundle does not have unseen after all items marked as seen'
);
assert.equal(
assert.strictEqual(
bundle.isRead(),
false,
'Bundle is unread'
);
// Mark one item as read
bundledItems[ 0 ].toggleRead( true );
assert.equal(
assert.strictEqual(
bundle.isRead(),
false,
'Bundle is still unread if it has some unread items'
@ -108,7 +108,7 @@
for ( i = 0; i < bundledItems.length; i++ ) {
bundledItems[ i ].toggleRead( true );
}
assert.equal(
assert.strictEqual(
bundle.isRead(),
true,
'Bundle is marked as read if all items are read'

View file

@ -116,7 +116,7 @@
[ 'baz', 'bar', 'foo' ],
'Model source names exist in order'
);
assert.equal(
assert.strictEqual(
model.hasUnseen(),
true,
'hasUnseen is true if there are unseen items in any group'
@ -129,14 +129,14 @@
}
}
groupDefinitions[ 0 ].items[ 0 ].toggleSeen( false );
assert.equal(
assert.strictEqual(
model.hasUnseen(),
true,
'hasUnseen is true even if only one item in one group is unseen'
);
groupDefinitions[ 0 ].items[ 0 ].toggleSeen( true );
assert.equal(
assert.strictEqual(
model.hasUnseen(),
false,
'hasUnseen is false if there are no unseen items in any of the groups'
@ -209,7 +209,7 @@
numUnseenItems = model.getItems().filter( function ( item ) {
return !item.isSeen();
} ).length;
assert.equal(
assert.strictEqual(
numUnseenItems,
numAllItems,
'Starting state: all items are unseen'
@ -221,7 +221,7 @@
numUnseenItems = model.getItems().filter( function ( item ) {
return !item.isSeen();
} ).length;
assert.equal(
assert.strictEqual(
numUnseenItems,
numAllItems - groupDefinitions[ 0 ].items.length,
'Only some items are seen'
@ -233,7 +233,7 @@
numUnseenItems = model.getItems().filter( function ( item ) {
return !item.isSeen();
} ).length;
assert.equal(
assert.strictEqual(
numUnseenItems,
0,
'All items are seen'

View file

@ -52,28 +52,28 @@
QUnit.test( 'Changing filters', function ( assert ) {
var model = new mw.echo.dm.FiltersModel();
assert.equal(
assert.strictEqual(
model.getReadState(),
'all',
'Initial value: all'
);
model.setReadState( 'unread' );
assert.equal(
assert.strictEqual(
model.getReadState(),
'unread',
'Changing state (unread)'
);
model.setReadState( 'read' );
assert.equal(
assert.strictEqual(
model.getReadState(),
'read',
'Changing state (read)'
);
model.setReadState( 'foo' );
assert.equal(
assert.strictEqual(
model.getReadState(),
'read',
'Ignoring invalid state (foo)'

View file

@ -4,7 +4,7 @@
QUnit.test( 'Constructing the model', function ( assert ) {
var model = new mw.echo.dm.NotificationGroupsList();
assert.equal(
assert.strictEqual(
model.getTimestamp(),
0,
'Empty group has timestamp 0'
@ -59,14 +59,14 @@
groupDefinitions[ i ].items
);
assert.equal(
assert.strictEqual(
model.getItemCount(),
i + 1,
'Group number increases after addGroup ("' + groupDefinitions[ i ].name + '")'
);
group = model.getGroupByName( groupDefinitions[ i ].name );
assert.equal(
assert.strictEqual(
group.getName(),
groupDefinitions[ i ].name,
'Group exists after addGroup ("' + groupDefinitions[ i ].name + '")'
@ -76,12 +76,12 @@
// Remove group
model.removeGroup( groupDefinitions[ 0 ].name );
assert.equal(
assert.strictEqual(
model.getItemCount(),
groupDefinitions.length - 1,
'Group number decreased after removeGroup'
);
assert.equal(
assert.strictEqual(
model.getGroupByName( groupDefinitions[ 0 ] ),
null,
'Removed group is no longer in the list'
@ -90,7 +90,7 @@
// Removing the last item from a group should remove the group
group = model.getGroupByName( 'baz' );
group.discardItems( groupDefinitions[ 2 ].items );
assert.equal(
assert.strictEqual(
model.getGroupByName( 'baz' ),
null,
'Empty group is no longer in the list'

View file

@ -69,24 +69,24 @@
new mw.echo.dm.NotificationItem( 5, { type: 'message', timestamp: '201609190500', read: true, seen: false } )
];
assert.equal(
assert.strictEqual(
model.getCount(),
0,
'Model list starts empty'
);
assert.equal(
assert.strictEqual(
model.getTimestamp(),
'200101010000',
'Model timestamp is its default'
);
model.setItems( items );
assert.equal(
assert.strictEqual(
model.getCount(),
6,
'Item list setup'
);
assert.equal(
assert.strictEqual(
model.getTimestamp(),
'201609190100',
'Model timestamp is the latest unread item\'s timestamp'

View file

@ -82,12 +82,12 @@
model.setAllSources( sources );
assert.equal(
assert.strictEqual(
model.getCurrentSource(),
'local',
'Default source is local'
);
assert.equal(
assert.strictEqual(
model.getCurrentPage(),
null,
'Default page is null'
@ -97,12 +97,12 @@
[ 'local', 'hewiki' ],
'Source array includes all sources'
);
assert.equal(
assert.strictEqual(
model.getSourceTitle( 'hewiki' ),
'Hebrew Wikipedia',
'Source title'
);
assert.equal(
assert.strictEqual(
model.getSourceTotalCount( 'hewiki' ),
15,
'Source total count'
@ -157,12 +157,12 @@
// Change source
model.setCurrentSourcePage( 'hewiki', 'User:Bar' );
assert.equal(
assert.strictEqual(
model.getCurrentSource(),
'hewiki',
'Source changed successfully'
);
assert.equal(
assert.strictEqual(
model.getCurrentPage(),
'User:Bar',
'Page changed successfully'

View file

@ -15,7 +15,7 @@
];
for ( i = 0; i < cases.length; i++ ) {
assert.equal(
assert.strictEqual(
model.getCappedNotificationCount( cases[ i ].input ),
cases[ i ].output,
'Capped notifications count: ' +
@ -35,21 +35,21 @@
model.setCount( 50 );
model.estimateChange( -10 );
assert.equal(
assert.strictEqual(
model.getCount(),
40, // 50-10
'Estimation within range'
);
model.estimateChange( 70 );
assert.equal(
assert.strictEqual(
model.getCount(),
100, // Estimation reached above cap - cap is set
'Estimation brings count to cap'
);
model.estimateChange( -10 );
assert.equal(
assert.strictEqual(
model.getCount(),
100, // We are already above cap, count will not change
'Estimation while counter is outside of cap - no change'

View file

@ -1,6 +1,6 @@
( function ( $, mw ) {
QUnit.module( 'ext.echo.overlay', {
setup: function () {
beforeEach: function () {
var ApiStub;
this.$badge = $( '<a class="mw-echo-notifications-badge mw-echo-unseen-notifications">1</a>' );
@ -198,7 +198,7 @@
}
} );
QUnit.test( 'mw.echo.overlay.buildOverlay', 7, function ( assert ) {
QUnit.test( 'mw.echo.overlay.buildOverlay', function ( assert ) {
var $overlay;
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub() );
mw.echo.overlay.buildOverlay( function ( $o ) {
@ -216,7 +216,7 @@
false, 'The badge no longer indicates new messages.' );
} );
QUnit.test( 'mw.echo.overlay.buildOverlay with messages', 5, function ( assert ) {
QUnit.test( 'mw.echo.overlay.buildOverlay with messages', function ( assert ) {
var $overlay;
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'no-new-messages' ) );
mw.echo.overlay.buildOverlay( function ( $o ) {
@ -232,7 +232,7 @@
false, 'The notification button class is updated with the default switch to alert tab.' );
} );
QUnit.test( 'Switch tabs on overlay. 1 unread alert, no unread messages.', 7, function ( assert ) {
QUnit.test( 'Switch tabs on overlay. 1 unread alert, no unread messages.', function ( assert ) {
var $overlay, $tabs;
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'no-new-messages' ) );
@ -259,7 +259,7 @@
true, 'Second tab has active class .as it is the only clickable tab' );
} );
QUnit.test( 'Unread message behaviour', 5, function ( assert ) {
QUnit.test( 'Unread message behaviour', function ( assert ) {
var $overlay;
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages' ) );
@ -282,7 +282,7 @@
'There are no notifications now so no need for button.' );
} );
QUnit.test( 'Mark as read.', 8, function ( assert ) {
QUnit.test( 'Mark as read.', function ( assert ) {
var $overlay;
this.$badge.text( '8' );
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages' ) );
@ -311,7 +311,7 @@
assert.strictEqual( this.$badge.text(), '6', 'Now 6 unread notifications.' );
} );
QUnit.test( 'Tabs when there is overflow.', 2, function ( assert ) {
QUnit.test( 'Tabs when there is overflow.', function ( assert ) {
var $overlay;
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages', 50 ) );
mw.echo.overlay.buildOverlay( function ( $o ) {
@ -324,7 +324,7 @@
assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length, 8, 'There are 8 unread notifications.' );
} );
QUnit.test( 'Switching tabs visibility', 4, function ( assert ) {
QUnit.test( 'Switching tabs visibility', function ( assert ) {
var $overlay;
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages' ) );