Skip to content

Commit 520f797

Browse files
authored
Fix: crash on WebStorm (fixes #14) (#15)
1 parent b8766b6 commit 520f797

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/internal/get-linters.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,29 @@
55
"use strict"
66

77
const path = require("path")
8-
const needle = `${path.sep}eslint${path.sep}`
8+
const needle = `${path.sep}node_modules${path.sep}eslint${path.sep}`
99

1010
module.exports = () => {
1111
const eslintPaths = new Set(
1212
Object.keys(require.cache)
1313
.filter(id => id.includes(needle))
1414
.map(id => id.slice(0, id.indexOf(needle) + needle.length))
1515
)
16-
return Array.from(eslintPaths).map(eslintPath => require(eslintPath).Linter)
16+
const linters = []
17+
18+
for (const eslintPath of eslintPaths) {
19+
try {
20+
const linter = require(eslintPath).Linter
21+
22+
if (linter) {
23+
linters.push(linter)
24+
}
25+
} catch (error) {
26+
if (error.code !== "MODULE_NOT_FOUND") {
27+
throw error
28+
}
29+
}
30+
}
31+
32+
return linters
1733
}

0 commit comments

Comments
 (0)