@@ -47,10 +47,12 @@ function isDirectory(dirPath) {
47
47
return isDir
48
48
}
49
49
50
- export function findESLintDirectory ( modulesDir , config , projectPath , fallback = false ) {
50
+ let fallbackForGlobalErrorThrown = false
51
+
52
+ export function findESLintDirectory ( modulesDir , config , projectPath , fallbackForGlobal = false ) {
51
53
let eslintDir = null
52
54
let locationType = null
53
- if ( config . global . useGlobalEslint && ! fallback ) {
55
+ if ( config . global . useGlobalEslint && ! fallbackForGlobal ) {
54
56
locationType = 'global'
55
57
const configGlobal = cleanPath ( config . global . globalNodePath )
56
58
const prefixPath = configGlobal || getNodePrefixPath ( )
@@ -78,11 +80,15 @@ export function findESLintDirectory(modulesDir, config, projectPath, fallback =
78
80
}
79
81
}
80
82
81
- if ( config . global . useGlobalEslint ) {
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 )
83
+ if ( config . global . useGlobalEslint && ! fallbackForGlobal ) {
84
+ if ( ! fallbackForGlobalErrorThrown ) {
85
+ // Throw the error only once to prevent performance issues
86
+ fallbackForGlobalErrorThrown = true
87
+ console . error ( `Global ESLint is not found, falling back to other Eslint installations...
88
+ Please ensure the global Node path is set correctly.
89
+ If you wanted to use a local installation of Eslint, disable Global Eslint option in the linter-eslint config.` )
90
+ }
91
+ return findESLintDirectory ( modulesDir , config , projectPath , true )
86
92
}
87
93
88
94
return {
0 commit comments