From 7707f6065acf9224e5b5ffb227533d75647dbe00 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 30 Jun 2019 12:06:38 +0700 Subject: [PATCH] Upgrade to ESLint v6 and require Node.js 8 Fixes #162 --- .travis.yml | 2 +- package.json | 13 +++++-------- tasks/eslint.js | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ae9d62a..f98fed06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '12' - '10' - '8' - - '6' diff --git a/package.json b/package.json index 9b1e1b70..299bb3b7 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "test": "grunt" @@ -20,22 +20,19 @@ ], "keywords": [ "gruntplugin", + "eslint", "lint", "validate", - "report", - "jshint", - "jslint", - "ecmascript", - "esprima" + "report" ], "dependencies": { "chalk": "^2.1.0", - "eslint": "^5.16.0" + "eslint": "^6.0.1" }, "devDependencies": { "grunt": "^1.0.1", "grunt-cli": "^1.2.0", - "grunt-shell": "^2.1.0" + "grunt-shell": "^3.0.1" }, "peerDependencies": { "grunt": ">=1" diff --git a/tasks/eslint.js b/tasks/eslint.js index 089c6b74..134dc40f 100644 --- a/tasks/eslint.js +++ b/tasks/eslint.js @@ -4,7 +4,7 @@ const eslint = require('eslint'); module.exports = grunt => { grunt.registerMultiTask('eslint', 'Validate files with ESLint', function () { - const opts = this.options({ + const options = this.options({ outputFile: false, quiet: false, maxWarnings: -1, @@ -16,47 +16,47 @@ module.exports = grunt => { return true; } - const formatter = eslint.CLIEngine.getFormatter(opts.format); + const formatter = eslint.CLIEngine.getFormatter(options.format); if (!formatter) { - grunt.warn(`Could not find formatter ${opts.format}`); + grunt.warn(`Could not find formatter ${options.format}`); return false; } - const engine = new eslint.CLIEngine(opts); + const engine = new eslint.CLIEngine(options); let report; try { report = engine.executeOnFiles(this.filesSrc); - } catch (err) { - grunt.warn(err); + } catch (error) { + grunt.warn(error); return false; } - if (opts.fix) { + if (options.fix) { eslint.CLIEngine.outputFixes(report); } let results = report.results; - if (opts.quiet) { + if (options.quiet) { results = eslint.CLIEngine.getErrorResults(results); } const output = formatter(results); - if (opts.outputFile) { - grunt.file.write(opts.outputFile, output); + if (options.outputFile) { + grunt.file.write(options.outputFile, output); } else if (output) { console.log(output); } - const tooManyWarnings = opts.maxWarnings >= 0 && report.warningCount > opts.maxWarnings; + const tooManyWarnings = options.maxWarnings >= 0 && report.warningCount > options.maxWarnings; if (report.errorCount === 0 && tooManyWarnings) { - grunt.warn(`ESLint found too many warnings (maximum: ${opts.maxWarnings})`); + grunt.warn(`ESLint found too many warnings (maximum: ${options.maxWarnings})`); } - return opts.failOnError ? report.errorCount === 0 : 0; + return options.failOnError ? report.errorCount === 0 : 0; }); };