From 715440a64ffe3f0d84082653485f16ee686cbe23 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 27 Oct 2021 15:17:22 -0700 Subject: [PATCH] fix: Dispatch on eslint 8 differences --- src/lib/rule-finder.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lib/rule-finder.js b/src/lib/rule-finder.js index 26f2229..63afb82 100644 --- a/src/lib/rule-finder.js +++ b/src/lib/rule-finder.js @@ -19,12 +19,20 @@ function _getConfigFile(specifiedFile) { } function _getConfigs(configFile, files) { - const cliEngine = new eslint.CLIEngine({ - // Ignore any config applicable depending on the location on the filesystem - useEslintrc: false, - // Point to the particular config - configFile - }); + const cliEngine = eslint.ESLint + ? new eslint.ESLint({ + // Ignore any config applicable depending on the location on the filesystem + useEslintrc: false, + // Point to the particular config + overrideConfigFile: configFile + }) + : new eslint.CLIEngine({ + // Ignore any config applicable depending on the location on the filesystem + useEslintrc: false, + // Point to the particular config + configFile + }); + return new Set(files .map(filePath => cliEngine.isPathIgnored(filePath) ? false : cliEngine.getConfigForFile(filePath)) .filter(Boolean)); @@ -67,7 +75,7 @@ function _getPluginRules(config) { } function _getCoreRules() { - return eslint.linter.getRules(); + return (eslint.Linter ? new eslint.Linter() : eslint.linter).getRules(); } function _filterRuleNames(ruleNames, rules, predicate) {