build: Install eslint and make pass

Change-Id: Icd36451d4d47836b773133a55c07eca3b58700a2
This commit is contained in:
James D. Forrester 2019-05-06 17:20:57 -07:00
parent 0a0476b2c3
commit eca4be01de
6 changed files with 27 additions and 37 deletions

10
.eslintrc.json Normal file
View file

@ -0,0 +1,10 @@
{
"root": true,
"extends": [
"wikimedia/client",
"wikimedia/jquery"
],
"globals": {
"mw": false
}
}

2
.gitignore vendored
View file

@ -1,7 +1,7 @@
.*
*~
*.kate-swp
.*.swp
node_modules/
/composer.lock
/vendor/
.eslintcache

View file

@ -1,24 +0,0 @@
{
"predef": [
"jQuery",
"mediaWiki"
],
/* Common */
// Enforcing
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"quotmark": "single",
"trailing": true,
"undef": true,
"unused": true,
// Environment
"browser": true
}

View file

@ -1,17 +1,20 @@
/*jshint node:true */
/* eslint-env node, es6 */
module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
var conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
var conf = grunt.file.readJSON( 'extension.json' );
grunt.initConfig( {
jshint: {
eslint: {
options: {
jshintrc: true
reportUnusedDisableDirectives: true,
cache: true
},
all: [
'*.js'
'**/*.js',
'!{vendor,node_modules}/**'
]
},
banana: conf.MessagesDirs,
@ -24,6 +27,6 @@ module.exports = function ( grunt ) {
}
} );
grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
};

View file

@ -1,14 +1,14 @@
( function ( mw, $ ) {
( function () {
$( function () {
/*global confirm */
// Confirm nuke
// eslint-disable-next-line no-jquery/no-global-selector
$( 'form[name="nukelist"]' ).on( 'submit', function () {
var pages = $( this ).find( 'input[name="pages[]"][type="checkbox"]:checked' );
if ( pages.length ) {
// eslint-disable-next-line no-alert
return confirm( mw.message( 'nuke-confirm', pages.length ) );
}
} );
} );
}( mediaWiki, jQuery ) );
}() );

View file

@ -4,9 +4,10 @@
"test": "grunt test"
},
"devDependencies": {
"eslint-config-wikimedia": "0.12.0",
"grunt": "1.0.3",
"grunt-banana-checker": "0.6.0",
"grunt-contrib-jshint": "1.1.0",
"grunt-eslint": "21.0.0",
"grunt-jsonlint": "1.1.0"
}
}