Bug 1230300: Fix mach eslint to pass command arguments through to eslint. r=gps
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 03 Dec 2015 10:38:29 -0800
changeset 276065 d4a2076b059234d5fbd9397bd6ba3c112181ae80
parent 276064 6c9319ab4430fd2858325fd1546d8fcc8fe513d7
child 276066 74b17234e93408021bc0413b60874638457e2e5e
push id69030
push usercbook@mozilla.com
push dateThu, 10 Dec 2015 11:34:18 +0000
treeherdermozilla-inbound@39c8aabf9719 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1230300: Fix mach eslint to pass command arguments through to eslint. r=gps Currently mach treats the first argument to eslint as the path and moves it to the end of the arguments but this breaks usage like "mach eslint -f json browser". It used to be necessary to change to the directory you wanted to lint but now the .eslintignore is at the top level we just run from the top level. This means the path argument doesn't need to be special anymore.
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -163,26 +163,22 @@ 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('path', nargs='?', default='.',
-        help='Path to files to lint, like "browser/components/loop" '
-            'or "mobile/android". '
-            'Defaults to the current directory if not given.')
     @CommandArgument('-e', '--ext', default='[.js,.jsm,.jsx,.xml]',
-        help='Filename extensions to lint, default: "[.js,.jsm,.jsx,.xml]".')
+        help='Filename extensions to lint, default: "[.js,.jsm,.jsx]".')
     @CommandArgument('-b', '--binary', default=None,
         help='Path to eslint binary.')
     @CommandArgument('args', nargs=argparse.REMAINDER)  # Passed through to eslint.
-    def eslint(self, setup, path, ext=None, binary=None, args=[]):
+    def eslint(self, setup, ext=None, binary=None, args=None):
         '''Run eslint.'''
         if setup:
             return self.eslint_setup()
         if not binary:
             binary = os.environ.get('ESLINT', None)
             if not binary:
@@ -190,35 +186,24 @@ class MachCommands(MachCommandBase):
                     binary = which.which('eslint')
                 except which.WhichError:
         if not binary:
             return 1
-        # The cwd below is unfortunate.  eslint --config=PATH/TO/.eslintrc works,
-        # but --ignore-path=PATH/TO/.eslintignore treats paths as relative to
-        # the current directory, rather than as relative to the location of
-        # .eslintignore (see https://github.com/eslint/eslint/issues/1382).
-        # mach commands always execute in the topsrcdir, so we could make all
-        # paths in .eslint relative to the topsrcdir, but it's not clear if
-        # that's a good choice for future eslint and IDE integrations.
-        # Unfortunately, running after chdir does not print the full path to
-        # files (convenient for opening with copy-and-paste).  In the meantime,
-        # we just print the active path.
+        self.log(logging.INFO, 'eslint', {'binary': binary, 'args': args},
+            'Running {binary}')
-        self.log(logging.INFO, 'eslint', {'binary': binary, 'path': path},
-            'Running {binary} in {path}')
+        args = args or ['.']
         cmd_args = [binary,
             '--ext', ext,  # This keeps ext as a single argument.
         ] + args
-        # Path must come after arguments.
-        cmd_args += [path]
         return 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.
     def eslint_setup(self, update_only=False):
         """Ensure eslint is optimally configured.