From 5e1c448203a63ea4d2e3b4ea2a09f31cbc68b754 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 5 Nov 2018 09:01:13 -0800 Subject: [PATCH] Refactor CLIEngine piece based on feedback --- lib/cli-engine.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/cli-engine.js b/lib/cli-engine.js index c2b380b429f..652d68b59b4 100644 --- a/lib/cli-engine.js +++ b/lib/cli-engine.js @@ -475,6 +475,8 @@ class CLIEngine { // setup special filter for fixes if (this.options.fix && this.options.fixTypes && this.options.fixTypes.length > 0) { + debug(`Using fix types ${this.options.fixTypes}`); + // throw an error if any invalid fix types are found validateFixTypes(this.options.fixTypes); @@ -482,7 +484,8 @@ class CLIEngine { const fixTypes = new Set(this.options.fixTypes); // save original value of options.fix in case it's a function - const originalFix = this.options.fix; + const originalFix = (typeof this.options.fix === "function") + ? this.options.fix : () => this.options.fix; // create a cache of rules (but don't populate until needed) this._rulesCache = null; @@ -491,7 +494,7 @@ class CLIEngine { const rule = this._rulesCache.get(lintResult.ruleId); const matches = rule.meta && fixTypes.has(rule.meta.type); - return matches && (typeof originalFix === "function" ? originalFix(lintResult) : true); + return matches && originalFix(lintResult); }; }