mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-11-27 17:50:25 +00:00
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:
parent
dbb73c389d
commit
298790a944
17
.eslintrc.json
Normal file
17
.eslintrc.json
Normal 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
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
node_modules
|
23
.jshintrc
23
.jshintrc
|
@ -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
|
||||
}
|
||||
}
|
12
Gruntfile.js
12
Gruntfile.js
|
@ -1,17 +1,13 @@
|
|||
/*jshint node:true */
|
||||
/* jshint node:true */
|
||||
module.exports = function ( grunt ) {
|
||||
var conf = grunt.file.readJSON( 'extension.json' );
|
||||
|
||||
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
||||
grunt.loadNpmTasks( 'grunt-eslint' );
|
||||
grunt.loadNpmTasks( 'grunt-jsonlint' );
|
||||
grunt.loadNpmTasks( 'grunt-banana-checker' );
|
||||
grunt.loadNpmTasks( 'grunt-jscs' );
|
||||
|
||||
grunt.initConfig( {
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: true
|
||||
},
|
||||
eslint: {
|
||||
all: '.'
|
||||
},
|
||||
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' );
|
||||
};
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-config-wikimedia": "^0.3.0",
|
||||
"grunt": "0.4.5",
|
||||
"grunt-cli": "0.1.13",
|
||||
"grunt-contrib-jshint": "0.11.3",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
),
|
||||
LIMIT = 3,
|
||||
debouncedLoad = $.debounce( 100, function () {
|
||||
loadRelatedArticles();
|
||||
loadRelatedArticles(); // eslint-disable-line
|
||||
} ),
|
||||
$window = $( window ),
|
||||
shouldShowReadMore;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
mw.config.get( 'wgRelatedArticlesLoggingSamplingRate', 0 ),
|
||||
{
|
||||
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(),
|
||||
// thus append the timestamp. See mw.user documentation for more info.
|
||||
userSessionToken: mw.user.generateRandomSessionId() +
|
||||
|
|
|
@ -31,6 +31,15 @@
|
|||
}
|
||||
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.
|
||||
*
|
||||
|
@ -101,12 +110,5 @@
|
|||
.then( getPages );
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
function getPages( result ) {
|
||||
return result && result.query && result.query.pages ? result.query.pages : [];
|
||||
}
|
||||
|
||||
mw.relatedPages.RelatedPagesGateway = RelatedPagesGateway;
|
||||
}( jQuery, mediaWiki ) );
|
||||
|
|
Loading…
Reference in a new issue