Bug 1291910 - Add ability for mach eslint to accept --fix. r=Felipe
authorJared Wein <jwein@mozilla.com>
Wed, 03 Aug 2016 19:18:55 -0400
changeset 349274 0f652fa04c5630d625dfde7c359be0f0339caea6
parent 349273 6265328c999cc098a56a2e4e3392927c94b220bc
child 349275 0bcc782c6b6409c8ccd052edfa21c1bd06591920
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1291910
milestone51.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 1291910 - Add ability for mach eslint to accept --fix. r=Felipe MozReview-Commit-ID: 5PB2oI2jPri
tools/lint/mach_commands.py
--- a/tools/lint/mach_commands.py
+++ b/tools/lint/mach_commands.py
@@ -81,18 +81,20 @@ class MachCommands(MachCommandBase):
     @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,.html]',
                      help='Filename extensions to lint, default: "[.js,.jsm,.jsx,.xml,.html]".')
     @CommandArgument('-b', '--binary', default=None,
                      help='Path to eslint binary.')
+    @CommandArgument('--fix', default=False, action='store_true',
+                     help='Request that eslint automatically fix errors, where possible.')
     @CommandArgument('args', nargs=argparse.REMAINDER)  # Passed through to eslint.
-    def eslint(self, setup, ext=None, binary=None, args=None):
+    def eslint(self, setup, ext=None, binary=None, fix=False, args=None):
         '''Run eslint.'''
 
         module_path = self.get_eslint_module_path()
 
         # eslint requires at least node 4.2.3
         nodePath = self.get_node_or_npm_path("node", LooseVersion("4.2.3"))
         if not nodePath:
             return 1
@@ -143,16 +145,20 @@ class MachCommands(MachCommandBase):
                     # 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
 
+        # eslint requires that --fix be set before the --ext argument.
+        if fix:
+            cmd_args.insert(1, '--fix')
+
         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')},