Switch from jshint/jscs to eslint

Change-Id: I278905a67c42d268bb4a891c9df34b0fdbf4307d
This commit is contained in:
Fomafix 2018-03-22 21:20:28 +01:00
parent bafd88d0f5
commit 1416dc5465
8 changed files with 22 additions and 73 deletions

10
.eslintrc.json Normal file
View file

@ -0,0 +1,10 @@
{
"extends": "wikimedia",
"env": {
"browser": true,
"jquery": true
},
"globals": {
"mediaWiki": false
}
}

21
.jscsrc
View file

@ -1,21 +0,0 @@
{
"preset": "wikimedia",
"jsDoc": {
"checkAnnotations": {
"preset": "jsduck5",
"extra": {
"this": true,
"source": true,
"see": true
}
},
"checkTypes": "strictNativeCase",
"checkParamNames": true,
"checkRedundantAccess": true,
"checkRedundantReturns": true,
"requireNewlineAfterDescription": true,
"requireParamTypes": true,
"requireReturnTypes": true
}
}

View file

@ -1,2 +0,0 @@
node_modules
vendor

View file

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

View file

@ -4,15 +4,14 @@
* @package CookieWarning
*/
/*jshint node:true */
/* eslint-env node */
module.exports = function ( grunt ) {
var conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-contrib-csslint' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.initConfig( {
banana: conf.MessagesDirs,
@ -23,26 +22,13 @@ module.exports = function ( grunt ) {
'!vendor/**'
]
},
jshint: {
options: {
jshintrc: true
},
eslint: {
all: [
'*.js',
'modules/**/*.js'
'**/*.js',
'!node_modules/**',
'!vendor/**'
]
},
jscs: {
fix: {
options: {
fix: true
},
src: '<%= jshint.all %>'
},
main: {
src: '<%= jshint.all %>'
}
},
csslint: {
options: {
csslintrc: '.csslintrc'
@ -51,7 +37,7 @@ module.exports = function ( grunt ) {
}
} );
grunt.registerTask( 'lint', [ 'jshint', 'jscs:main', 'csslint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'lint', [ 'eslint', 'csslint', 'jsonlint', 'banana' ] );
grunt.registerTask( 'test', [ 'lint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
};

View file

@ -7,11 +7,11 @@
"test": "grunt test"
},
"devDependencies": {
"eslint-config-wikimedia": "0.5.0",
"grunt": "1.0.1",
"grunt-banana-checker": "0.4.0",
"grunt-contrib-csslint": "0.5.0",
"grunt-contrib-jshint": "0.11.3",
"grunt-jscs": "2.5.0",
"grunt-eslint": "20.1.0",
"grunt-jsonlint": "1.0.7"
}
}

View file

@ -1,11 +1,10 @@
/* global Geo, mediaWiki */
( function ( mw, $ ) {
'use strict';
var geoLocation;
geoLocation = {
/**
* @return string Two-letter country code
* @return {string} Two-letter country code
*/
getCountryCode: function () {
/**
@ -50,4 +49,4 @@
$( '.mw-cookiewarning-container' ).detach();
}
} );
}( mediaWiki, jQuery ) );
}( mediaWiki, jQuery ) );

View file

@ -29,4 +29,4 @@
ev.preventDefault();
} );
} )( mediaWiki, jQuery );
}( mediaWiki, jQuery ) );