diff --git a/lib/internal/get-linters.js b/lib/internal/get-linters.js index 5e4a443..2482662 100644 --- a/lib/internal/get-linters.js +++ b/lib/internal/get-linters.js @@ -5,7 +5,7 @@ "use strict" const path = require("path") -const needle = `${path.sep}eslint${path.sep}` +const needle = `${path.sep}node_modules${path.sep}eslint${path.sep}` module.exports = () => { const eslintPaths = new Set( @@ -13,5 +13,21 @@ module.exports = () => { .filter(id => id.includes(needle)) .map(id => id.slice(0, id.indexOf(needle) + needle.length)) ) - return Array.from(eslintPaths).map(eslintPath => require(eslintPath).Linter) + const linters = [] + + for (const eslintPath of eslintPaths) { + try { + const linter = require(eslintPath).Linter + + if (linter) { + linters.push(linter) + } + } catch (error) { + if (error.code !== "MODULE_NOT_FOUND") { + throw error + } + } + } + + return linters }