Add switch to auto fix eslint and stylelint issues

This commit is contained in:
rejas 2020-03-11 11:12:30 +01:00
parent 7470a3b813
commit f22e39e22b
2 changed files with 6 additions and 3 deletions

View File

@ -1,9 +1,10 @@
module.exports = function(grunt) { module.exports = function(grunt) {
require("time-grunt")(grunt); require("time-grunt")(grunt);
var fix = (grunt.option("env") || "lint") === "lint";
grunt.initConfig({ grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
eslint: { eslint: {
options: { options: {
fix: fix,
configFile: ".eslintrc.json" configFile: ".eslintrc.json"
}, },
target: [ target: [
@ -26,6 +27,7 @@ module.exports = function(grunt) {
stylelint: { stylelint: {
simple: { simple: {
options: { options: {
fix: fix,
configFile: ".stylelintrc.json" configFile: ".stylelintrc.json"
}, },
src: [ src: [
@ -101,5 +103,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-jsonlint"); grunt.loadNpmTasks("grunt-jsonlint");
grunt.loadNpmTasks("grunt-yamllint"); grunt.loadNpmTasks("grunt-yamllint");
grunt.loadNpmTasks("grunt-markdownlint"); grunt.loadNpmTasks("grunt-markdownlint");
grunt.registerTask("default", ["eslint", "stylelint", "jsonlint", "markdownlint", "yamllint"]); grunt.registerTask("default", ["eslint", "stylelint", "jsonlint", "markdownlint", "yamllint"]);
}; };

View File

@ -12,9 +12,9 @@
"test": "NODE_ENV=test ./node_modules/mocha/bin/mocha tests --recursive", "test": "NODE_ENV=test ./node_modules/mocha/bin/mocha tests --recursive",
"test:unit": "NODE_ENV=test ./node_modules/mocha/bin/mocha tests/unit --recursive", "test:unit": "NODE_ENV=test ./node_modules/mocha/bin/mocha tests/unit --recursive",
"test:e2e": "NODE_ENV=test ./node_modules/mocha/bin/mocha tests/e2e --recursive", "test:e2e": "NODE_ENV=test ./node_modules/mocha/bin/mocha tests/e2e --recursive",
"test:lint": "grunt", "test:lint": "grunt --env=test",
"config:check": "node tests/configs/check_config.js", "config:check": "node tests/configs/check_config.js",
"lint": "grunt" "lint": "grunt --env=lint"
}, },
"repository": { "repository": {
"type": "git", "type": "git",