From f22e39e22b83c87a723db5f7b3ee96972dafb535 Mon Sep 17 00:00:00 2001 From: rejas Date: Wed, 11 Mar 2020 11:12:30 +0100 Subject: [PATCH] Add switch to auto fix eslint and stylelint issues --- Gruntfile.js | 5 ++++- package.json | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 829279e2..2b2048d7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,9 +1,10 @@ module.exports = function(grunt) { require("time-grunt")(grunt); + var fix = (grunt.option("env") || "lint") === "lint"; grunt.initConfig({ - pkg: grunt.file.readJSON("package.json"), eslint: { options: { + fix: fix, configFile: ".eslintrc.json" }, target: [ @@ -26,6 +27,7 @@ module.exports = function(grunt) { stylelint: { simple: { options: { + fix: fix, configFile: ".stylelintrc.json" }, src: [ @@ -101,5 +103,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-jsonlint"); grunt.loadNpmTasks("grunt-yamllint"); grunt.loadNpmTasks("grunt-markdownlint"); + grunt.registerTask("default", ["eslint", "stylelint", "jsonlint", "markdownlint", "yamllint"]); }; diff --git a/package.json b/package.json index a3ffd9b8..4640e627 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "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: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", - "lint": "grunt" + "lint": "grunt --env=lint" }, "repository": { "type": "git",