зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1258341 - [mozlint] Add ability to forward miscellaneous command line arguments to the underlying linter, r=smacleod
This is mostly to maintain backwards compatibility with the |mach eslint| command. But it's also going to be used in automation. The 'mozlint-eslint' task will need to pass in --quiet to eslint. Maybe in the future we should remove this ability and only allow well-defined arguments in mozlint. But for now it's convenient and allows us to land the eslint->mozlint patch series quicker. MozReview-Commit-ID: KYhC6SEySC3 --HG-- extra : rebase_source : ad7f0cdeb57ed8a99becb90d761d73ef45ce853a
This commit is contained in:
Родитель
eba50c94d8
Коммит
c88eb083d8
|
@ -6,7 +6,7 @@ from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser, REMAINDER
|
||||||
|
|
||||||
|
|
||||||
SEARCH_PATHS = []
|
SEARCH_PATHS = []
|
||||||
|
@ -52,6 +52,10 @@ class MozlintParser(ArgumentParser):
|
||||||
'help': "Lint files touched by changes in the working directory "
|
'help': "Lint files touched by changes in the working directory "
|
||||||
"(i.e haven't been committed yet). Works with mercurial or git.",
|
"(i.e haven't been committed yet). Works with mercurial or git.",
|
||||||
}],
|
}],
|
||||||
|
[['extra_args'],
|
||||||
|
{'nargs': REMAINDER,
|
||||||
|
'help': "Extra arguments that will be forwarded to the underlying linter.",
|
||||||
|
}],
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
@ -60,6 +64,13 @@ class MozlintParser(ArgumentParser):
|
||||||
for cli, args in self.arguments:
|
for cli, args in self.arguments:
|
||||||
self.add_argument(*cli, **args)
|
self.add_argument(*cli, **args)
|
||||||
|
|
||||||
|
def parse_known_args(self, *args, **kwargs):
|
||||||
|
# This is here so the eslint mach command doesn't lose 'extra_args'
|
||||||
|
# when using mach's dispatch functionality.
|
||||||
|
args, extra = ArgumentParser.parse_known_args(self, *args, **kwargs)
|
||||||
|
args.extra_args = extra
|
||||||
|
return args, extra
|
||||||
|
|
||||||
|
|
||||||
def find_linters(linters=None):
|
def find_linters(linters=None):
|
||||||
lints = []
|
lints = []
|
||||||
|
|
Загрузка…
Ссылка в новой задаче