[gnome-builder] eslint: try to use a bundled eslint



commit 6fd5cf12a475fd921ec680c6bebafbdb53c493ed
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jan 1 16:43:38 2022 -0800

    eslint: try to use a bundled eslint
    
    We already bundle eslint as part of the typescript-language-server, so
    try to use that as a fallback if/when possible.
    
    Related !490

 src/plugins/eslint/eslint_plugin.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/eslint/eslint_plugin.py b/src/plugins/eslint/eslint_plugin.py
index 1b76201a7..81b51cebe 100644
--- a/src/plugins/eslint/eslint_plugin.py
+++ b/src/plugins/eslint/eslint_plugin.py
@@ -38,6 +38,8 @@ SEVERITY_MAP = {
     2: Ide.DiagnosticSeverity.ERROR
 }
 
+# Comes from typescript-language-server
+BUNDLED_ESLINT = 
'/app/lib/yarn/global/node_modules/typescript-language-server/node_modules/eslint/bin/eslint.js'
 
 class ESLintDiagnosticProvider(Ide.Object, Ide.DiagnosticProvider):
     @staticmethod
@@ -45,8 +47,14 @@ class ESLintDiagnosticProvider(Ide.Object, Ide.DiagnosticProvider):
         local_eslint = os.path.join(srcdir, 'node_modules', '.bin', 'eslint')
         if os.path.exists(local_eslint):
             return local_eslint
+        elif GLib.find_program_in_path('eslint'):
+            # Prefer PATH over our bundled eslint
+            return 'eslint'
+        elif os.path.exists(BUNDLED_ESLINT):
+            return BUNDLED_ESLINT
         else:
-            return 'eslint'  # Just rely on PATH
+            # Just return something, even though it wont work
+            return 'eslint'
 
     def create_launcher(self):
         context = self.get_context()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]