Skip to content

Commit

Permalink
fix: Dispatch on eslint 8 differences
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 27, 2021
1 parent f95ef60 commit c964275
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/lib/rule-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c964275

Please sign in to comment.