Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit d1babbb

Browse files
committed
fix: add fallback for the global eslint
1 parent 2f98b0f commit d1babbb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/worker-helpers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ function isDirectory(dirPath) {
4747
return isDir
4848
}
4949

50-
export function findESLintDirectory(modulesDir, config, projectPath) {
50+
export function findESLintDirectory(modulesDir, config, projectPath, fallback = false) {
5151
let eslintDir = null
5252
let locationType = null
53-
if (config.global.useGlobalEslint) {
53+
if (config.global.useGlobalEslint && !fallback) {
5454
locationType = 'global'
5555
const configGlobal = cleanPath(config.global.globalNodePath)
5656
const prefixPath = configGlobal || getNodePrefixPath()
@@ -79,7 +79,10 @@ export function findESLintDirectory(modulesDir, config, projectPath) {
7979
}
8080

8181
if (config.global.useGlobalEslint) {
82-
throw new Error('Global ESLint is not found, please ensure the global Node path is set correctly. If you wanted to use a local installation of Eslint, disable Global Eslint option in the linter-eslint config.')
82+
// TODO push the error to the user
83+
console.error(`Global ESLint is not found, please ensure the global Node path is set correctly.
84+
If you wanted to use a local installation of Eslint, disable Global Eslint option in the linter-eslint config.`)
85+
findESLintDirectory(modulesDir, config, projectPath, true)
8386
}
8487

8588
return {

0 commit comments

Comments
 (0)