author Mark Banner <>
Mon, 08 May 2017 10:29:47 +0100
changeset 357769 e0f9c56c15f0f412f2111f1f3379d69b2a213188
parent 354754 6c67c4f0bf30b8453d1fd9d8dc6f66319449aeb1
child 371144 8954e1ad4d825d361e5c65df9b61f90ba0b33354
permissions -rw-r--r--
Bug 1362947 - Upgrade eslint-plugin-html to 2.0.3 to pick up --fix support. r=jaws MozReview-Commit-ID: 5fVG7akPnGM

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

from __future__ import absolute_import, print_function, unicode_literals

import argparse
import os

from mozbuild.base import (

from mach.decorators import (

here = os.path.abspath(os.path.dirname(__file__))

def setup_argument_parser():
    from mozlint import cli
    return cli.MozlintParser()

class MachCommands(MachCommandBase):

        'lint', category='devenv',
        description='Run linters.',
    def lint(self, *runargs, **lintargs):
        """Run linters."""
        from mozlint import cli
        lintargs['exclude'] = ['obj*']
        return*runargs, **lintargs)

    @Command('eslint', category='devenv',
             description='Run eslint or help configure eslint for optimal development.')
    @CommandArgument('paths', default=None, nargs='*',
                     help="Paths to file or directories to lint, like "
                          "'browser/' Defaults to the "
                          "current directory if not given.")
    @CommandArgument('-s', '--setup', default=False, action='store_true',
                     help='Configure eslint for optimal development.')
    @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('extra_args', nargs=argparse.REMAINDER,
                     help='Extra args that will be forwarded to eslint.')
    def eslint(self, paths, extra_args=[], **kwargs):
        self._mach_context.commands.dispatch('lint', self._mach_context,
                                             linters=['eslint'], paths=paths,
                                             argv=extra_args, **kwargs)