mediawiki-extensions-Popups/Gruntfile.js
Ed Sanders 6de53e8681 Replace grunt fix with grunt eslint --fix
Appending --fix is what the eslint output suggests when
fixable errors are detectable, so better to just support
that than invent a new grunt sub-task.

Pass the same option to stylelint.

Change-Id: Ic8902f821d53a3fe6ca521ff1785c52baa99ceb1
2020-02-24 14:49:19 +00:00

86 lines
1.7 KiB
JavaScript

/* eslint-evn node */
module.exports = function ( grunt ) {
const conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-svgmin' );
grunt.initConfig( {
banana: conf.MessagesDirs,
eslint: {
options: {
cache: true,
maxWarnings: 0,
reportUnusedDisableDirectives: true,
extensions: [ '.js', '.json' ]
},
// Lint the built artifacts with ES5 so that no ES6 slips to production
build: {
options: {
configFile: '.eslintrc.es5.json'
},
src: [
'resources/dist/*.js'
]
},
sources: {
options: {
fix: grunt.option( 'fix' )
},
src: [
'*.{js,json}',
'src/**/*.{js,json}',
'tests/**/*.{js,json}'
]
}
},
stylelint: {
options: {
syntax: 'less',
fix: grunt.option( 'fix' )
},
all: [
'src/**/*.less'
]
},
// SVG Optimization
svgmin: {
options: grunt.file.readJSON( '.svgo.json' ),
all: {
files: [ {
expand: true,
cwd: 'resources/ext.popups.images',
src: [
'**/*.svg'
],
dest: 'resources/ext.popups.images/',
ext: '.svg'
} ]
}
},
watch: {
options: {
interrupt: true,
debounceDelay: 1000
},
lint: {
files: [ 'resources/ext.popups.main/**/*.less', 'resources/**/*.js' ],
tasks: [ 'lint' ]
},
configFiles: {
files: [ 'Gruntfile.js' ],
options: {
reload: true
}
}
}
} );
grunt.registerTask( 'lint', [ 'eslint', 'stylelint', 'banana', 'eslint:build', 'svgmin' ] );
grunt.registerTask( 'default', [ 'lint' ] );
};