Bug 1230776: Support scripts from HTML files in eslint. r=gps
authorKris Maglione <maglione.k@gmail.com>
Sat, 05 Dec 2015 13:17:49 -0800
changeset 312465 dd26de01e3d255d6f62e679a58a0113ac1128183
parent 312464 5803942d32dc6318004c4a9c17b51355aa1c0f57
child 312466 1d6e1baf6604f3ea5b980f7e3f72976c2ef6c703
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1230776
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1230776: Support scripts from HTML files in eslint. r=gps Also removes related unused variables in mach_commands.py.
.eslintignore
python/mach_commands.py
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,14 +1,18 @@
 # Always ignore node_modules.
 **/node_modules/**/*.*
 
 # Exclude expected objdirs.
 obj*/**
 
+# Temporarily ignore HTML files that still need to be fixed.
+browser/extensions/loop/**/*.html
+devtools/**/*.html
+
 # We ignore all these directories by default, until we get them enabled.
 # If you are enabling a directory, please add directory specific exclusions
 # below.
 accessible/**
 addon-sdk/**
 build/**
 caps/**
 chrome/**
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -43,31 +43,16 @@ Valid installation paths:
 NPM_NOT_FOUND_MESSAGE = '''
 Node Package Manager (npm) is either not installed or installed to a
 non-standard path. Please install npm from https://nodejs.org (it comes as an
 option in the node installation) and try again.
 
 Valid installation paths:
 '''.strip()
 
-ESLINT_PROMPT = '''
-Would you like to use eslint
-'''.strip()
-
-ESLINT_PLUGIN_MOZILLA_PROMPT = '''
-eslint-plugin-mozilla is an eslint plugin containing rules that help enforce
-JavaScript coding standards in the Mozilla project. Would you like to use this
-plugin
-'''.strip()
-
-ESLINT_PLUGIN_REACT_PROMPT = '''
-eslint-plugin-react is an eslint plugin containing rules that help React
-developers follow strict guidelines. Would you like to install it
-'''.strip()
-
 
 @CommandProvider
 class MachCommands(MachCommandBase):
     @Command('python', category='devenv',
         description='Run Python.')
     @CommandArgument('args', nargs=argparse.REMAINDER)
     def python(self, args):
         # Avoid logging the command
@@ -163,18 +148,18 @@ class MachCommands(MachCommandBase):
                 return 1
 
         return 0 if return_code == 0 else 1
 
     @Command('eslint', category='devenv',
         description='Run eslint or help configure eslint for optimal development.')
     @CommandArgument('-s', '--setup', default=False, action='store_true',
         help='configure eslint for optimal development.')
-    @CommandArgument('-e', '--ext', default='[.js,.jsm,.jsx,.xml]',
-        help='Filename extensions to lint, default: "[.js,.jsm,.jsx]".')
+    @CommandArgument('-e', '--ext', default='[.js,.jsm,.jsx,.xml,.html]',
+        help='Filename extensions to lint, default: "[.js,.jsm,.jsx,.xml,.html]".')
     @CommandArgument('-b', '--binary', default=None,
         help='Path to eslint binary.')
     @CommandArgument('args', nargs=argparse.REMAINDER)  # Passed through to eslint.
     def eslint(self, setup, ext=None, binary=None, args=None):
         '''Run eslint.'''
 
         if setup:
             return self.eslint_setup()
@@ -192,18 +177,23 @@ class MachCommands(MachCommandBase):
             return 1
 
         self.log(logging.INFO, 'eslint', {'binary': binary, 'args': args},
             'Running {binary}')
 
         args = args or ['.']
 
         cmd_args = [binary,
-            '--ext', ext,  # This keeps ext as a single argument.
-        ] + args
+                    # Enable the HTML plugin.
+                    # We can't currently enable this in the global config file
+                    # because it has bad interactions with the SublimeText
+                    # ESLint plugin (bug 1229874).
+                    '--plugin', 'html',
+                    '--ext', ext,  # This keeps ext as a single argument.
+                    ] + args
 
         success = self.run_process(cmd_args,
             pass_thru=True,  # Allow user to run eslint interactively.
             ensure_exit_code=False,  # Don't throw on non-zero exit code.
             require_unix_environment=True # eslint is not a valid Win32 binary.
         )
 
         self.log(logging.INFO, 'eslint', {'msg': ('No errors' if success == 0 else 'Errors')},
@@ -236,16 +226,22 @@ class MachCommands(MachCommandBase):
 
         # Install eslint-plugin-mozilla.
         success = self.callProcess("eslint-plugin-mozilla",
                                    [npmPath, "link"],
                                    "testing/eslint-plugin-mozilla")
         if not success:
             return 1
 
+        # Install eslint-plugin-html.
+        success = self.callProcess("eslint-plugin-html",
+                                   [npmPath, "install", "eslint-plugin-html", "-g"])
+        if not success:
+            return 1
+
         # Install eslint-plugin-react.
         success = self.callProcess("eslint-plugin-react",
                                    [npmPath, "install", "eslint-plugin-react", "-g"])
         if not success:
             return 1
 
         print("\nESLint and approved plugins installed successfully!")