diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..3edb1b89 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "root": true, + "extends": [ + "wikimedia/client", + "wikimedia/jquery" + ], + "globals": { + "ve": true, + "VisualEditorSupportCheck": false, + "OO": false, + "unicodeJS": false, + "RangeFix": false, + "Papa": false, + "mw": false, + "require": false + }, + "rules": { + "no-jquery/no-hide": "error", + "no-jquery/no-show": "error", + "no-jquery/no-toggle": "error", + "max-len": "off" + } +} diff --git a/.gitignore b/.gitignore index 4489bce0..0071d7df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /node_modules/ /vendor/ /composer.lock +.eslintcache # Editors *.kate-swp diff --git a/Gruntfile.js b/Gruntfile.js index b5e41a57..c98c1aae 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,16 +4,27 @@ * @package CiteThisPage */ -/*jshint node:true */ +/* eslint-env node, es6 */ module.exports = function ( grunt ) { - grunt.loadNpmTasks( 'grunt-jsonlint' ); + var conf = grunt.file.readJSON( 'extension.json' ); + grunt.loadNpmTasks( 'grunt-banana-checker' ); + grunt.loadNpmTasks( 'grunt-eslint' ); + grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.initConfig( { - banana: { - all: ["i18n/"] + eslint: { + options: { + reportUnusedDisableDirectives: true, + cache: true + }, + all: [ + '**/*.js', + '!{vendor,node_modules}/**' + ] }, + banana: conf.MessagesDirs, jsonlint: { all: [ '**/*.json', @@ -30,6 +41,6 @@ module.exports = function ( grunt ) { } } ); - grunt.registerTask( 'test', [ 'jsonlint', 'banana', 'stylelint' ] ); + grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana', 'stylelint' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/package.json b/package.json index c9124d82..b6515601 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,11 @@ "test": "grunt test" }, "devDependencies": { + "eslint-config-wikimedia": "0.11.0", "grunt": "1.0.3", "grunt-banana-checker": "0.6.0", "grunt-jsonlint": "1.1.0", + "grunt-eslint": "21.0.0", "grunt-stylelint": "0.10.1", "stylelint-config-wikimedia": "0.5.0" }