Skip to content

Commit

Permalink
fix: eslint v6.0.0-alpha.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed May 13, 2019
1 parent 877080b commit 9654a51
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ const needle = path.join("lib", "linter.js")

iterateESLintModules(patch)

function getLinterFromModule(moduleExports) {
return moduleExports.Linter ? moduleExports.Linter : moduleExports
}

function getModuleFromRequire() {
return require("eslint/lib/linter")
return getLinterFromModule(require("eslint/lib/linter"))
}

function getModuleFromCache(key) {
Expand All @@ -34,7 +38,7 @@ function getModuleFromCache(key) {
const module = require.cache[key]
if (!module || !module.exports) return

const Linter = module.exports
const Linter = getLinterFromModule(module.exports)
if (
typeof Linter === "function" &&
typeof Linter.prototype.verify === "function"
Expand Down Expand Up @@ -114,8 +118,7 @@ function getMode(pluginSettings, filenameOrOptions) {
}
}

function patch(moduleExports) {
const Linter = moduleExports.Linter ? moduleExports.Linter : moduleExports
function patch(Linter) {
const verify = Linter.prototype.verify

// ignore if verify function is already been patched sometime before
Expand Down

0 comments on commit 9654a51

Please sign in to comment.