Upgrade to eslint

We're going to want to use a newer version of JSHint
anyway to support use of ES6 in our browser tests so now
seems a good time to do this.

Bug: T149202
Change-Id: I5526b020cfc12c0e065ad15ed711a0e3a7bff1bc
This commit is contained in:
jdlrobson 2017-04-07 13:21:12 -07:00 committed by joakin
parent dbb73c389d
commit 298790a944
9 changed files with 35 additions and 48 deletions

17
.eslintrc.json Normal file
View file

@ -0,0 +1,17 @@
{
"extends": "wikimedia",
"env": {
"browser": true,
"jquery": true,
"qunit": true
},
"globals": {
"mw": false,
"OO": false,
"mediaWiki": false,
"require": false
},
"rules": {
"no-use-before-define": 1
}
}

View file

@ -1,4 +0,0 @@
{
"preset": "wikimedia",
"excludeFiles": [ "node_modules/**" ]
}

View file

@ -1 +0,0 @@
node_modules

View file

@ -1,23 +0,0 @@
{
// Enforcing
"bitwise": true,
"eqeqeq": true,
"es3": true,
"freeze": true,
"latedef": true,
"noarg": true,
"nonew": true,
"undef": true,
"unused": true,
// Environment
"browser": true,
"jquery": true,
"globals": {
"mw": false,
"mediaWiki": false,
"OO": false,
"QUnit": false
}
}

View file

@ -1,17 +1,13 @@
/*jshint node:true */ /* jshint node:true */
module.exports = function ( grunt ) { module.exports = function ( grunt ) {
var conf = grunt.file.readJSON( 'extension.json' ); var conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' ); grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.initConfig( { grunt.initConfig( {
jshint: { eslint: {
options: {
jshintrc: true
},
all: '.' all: '.'
}, },
jscs: { jscs: {
@ -26,6 +22,6 @@ module.exports = function ( grunt ) {
} }
} ); } );
grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] ); grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' ); grunt.registerTask( 'default', 'test' );
}; };

View file

@ -4,11 +4,11 @@
"test": "grunt test" "test": "grunt test"
}, },
"devDependencies": { "devDependencies": {
"eslint-config-wikimedia": "^0.3.0",
"grunt": "0.4.5", "grunt": "0.4.5",
"grunt-cli": "0.1.13",
"grunt-contrib-jshint": "0.11.3",
"grunt-banana-checker": "0.4.0", "grunt-banana-checker": "0.4.0",
"grunt-jscs": "2.4.0", "grunt-cli": "0.1.13",
"grunt-eslint": "^19.0.0",
"grunt-jsonlint": "1.0.7" "grunt-jsonlint": "1.0.7"
} }
} }

View file

@ -9,7 +9,7 @@
), ),
LIMIT = 3, LIMIT = 3,
debouncedLoad = $.debounce( 100, function () { debouncedLoad = $.debounce( 100, function () {
loadRelatedArticles(); loadRelatedArticles(); // eslint-disable-line
} ), } ),
$window = $( window ), $window = $( window ),
shouldShowReadMore; shouldShowReadMore;

View file

@ -25,7 +25,7 @@
mw.config.get( 'wgRelatedArticlesLoggingSamplingRate', 0 ), mw.config.get( 'wgRelatedArticlesLoggingSamplingRate', 0 ),
{ {
pageId: mw.config.get( 'wgArticleId' ), pageId: mw.config.get( 'wgArticleId' ),
skin: ( skin === 'minerva' ) ? skin + '-' + mw.config.get( 'wgMFMode' ) : skin, skin: ( skin === 'minerva' ) ? skin + '-' + mw.config.get( 'wgMFMode' ) : skin,
// We cannot depend on the uniqueness of mw.user.generateRandomSessionId(), // We cannot depend on the uniqueness of mw.user.generateRandomSessionId(),
// thus append the timestamp. See mw.user documentation for more info. // thus append the timestamp. See mw.user documentation for more info.
userSessionToken: mw.user.generateRandomSessionId() + userSessionToken: mw.user.generateRandomSessionId() +

View file

@ -31,6 +31,15 @@
} }
OO.initClass( RelatedPagesGateway ); OO.initClass( RelatedPagesGateway );
/**
* @ignore
* @param {Object} result
* @return {Array}
*/
function getPages( result ) {
return result && result.query && result.query.pages ? result.query.pages : [];
}
/** /**
* Gets the related pages for the current page. * Gets the related pages for the current page.
* *
@ -101,12 +110,5 @@
.then( getPages ); .then( getPages );
}; };
/**
* @ignore
*/
function getPages( result ) {
return result && result.query && result.query.pages ? result.query.pages : [];
}
mw.relatedPages.RelatedPagesGateway = RelatedPagesGateway; mw.relatedPages.RelatedPagesGateway = RelatedPagesGateway;
}( jQuery, mediaWiki ) ); }( jQuery, mediaWiki ) );