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

Commit

Permalink
fix: add fallback for the global eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 14, 2021
1 parent 2f98b0f commit d1babbb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/worker-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ function isDirectory(dirPath) {
return isDir
}

export function findESLintDirectory(modulesDir, config, projectPath) {
export function findESLintDirectory(modulesDir, config, projectPath, fallback = false) {
let eslintDir = null
let locationType = null
if (config.global.useGlobalEslint) {
if (config.global.useGlobalEslint && !fallback) {
locationType = 'global'
const configGlobal = cleanPath(config.global.globalNodePath)
const prefixPath = configGlobal || getNodePrefixPath()
Expand Down Expand Up @@ -79,7 +79,10 @@ export function findESLintDirectory(modulesDir, config, projectPath) {
}

if (config.global.useGlobalEslint) {
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.')
// TODO push the error to the user
console.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.`)
findESLintDirectory(modulesDir, config, projectPath, true)
}

return {
Expand Down

0 comments on commit d1babbb

Please sign in to comment.