build: Install eslint

Change-Id: Ia34ce1a961d4b96c9467430576777223e9cda2ff
This commit is contained in:
James D. Forrester 2019-05-06 15:37:39 -07:00
parent 076b469525
commit 26d2866425
4 changed files with 42 additions and 5 deletions

23
.eslintrc.json Normal file
View file

@ -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"
}
}

1
.gitignore vendored
View file

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

View file

@ -4,16 +4,27 @@
* @package CiteThisPage * @package CiteThisPage
*/ */
/*jshint node:true */ /* eslint-env node, es6 */
module.exports = function ( grunt ) { module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-jsonlint' ); var conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.initConfig( { grunt.initConfig( {
banana: { eslint: {
all: ["i18n/"] options: {
reportUnusedDisableDirectives: true,
cache: true
},
all: [
'**/*.js',
'!{vendor,node_modules}/**'
]
}, },
banana: conf.MessagesDirs,
jsonlint: { jsonlint: {
all: [ all: [
'**/*.json', '**/*.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' ); grunt.registerTask( 'default', 'test' );
}; };

View file

@ -7,9 +7,11 @@
"test": "grunt test" "test": "grunt test"
}, },
"devDependencies": { "devDependencies": {
"eslint-config-wikimedia": "0.11.0",
"grunt": "1.0.3", "grunt": "1.0.3",
"grunt-banana-checker": "0.6.0", "grunt-banana-checker": "0.6.0",
"grunt-jsonlint": "1.1.0", "grunt-jsonlint": "1.1.0",
"grunt-eslint": "21.0.0",
"grunt-stylelint": "0.10.1", "grunt-stylelint": "0.10.1",
"stylelint-config-wikimedia": "0.5.0" "stylelint-config-wikimedia": "0.5.0"
} }