@@ -47,10 +47,12 @@ function isDirectory(dirPath) {
4747 return isDir
4848}
4949
50- export function findESLintDirectory ( modulesDir , config , projectPath , fallback = false ) {
50+ let fallbackForGlobalErrorThrown = false
51+
52+ export function findESLintDirectory ( modulesDir , config , projectPath , fallbackForGlobal = false ) {
5153 let eslintDir = null
5254 let locationType = null
53- if ( config . global . useGlobalEslint && ! fallback ) {
55+ if ( config . global . useGlobalEslint && ! fallbackForGlobal ) {
5456 locationType = 'global'
5557 const configGlobal = cleanPath ( config . global . globalNodePath )
5658 const prefixPath = configGlobal || getNodePrefixPath ( )
@@ -78,11 +80,15 @@ export function findESLintDirectory(modulesDir, config, projectPath, fallback =
7880 }
7981 }
8082
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 )
8692 }
8793
8894 return {
0 commit comments