зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1608535 - [lint] Forward new --no-error-on-unmatched-pattern to eslint, r=Standard8
This prevents eslint from dumping an error and bailing when a path was specified that doesn't contain any lintable files. This patch fixes a bad interaction with 'mozlint' where passing a directory containing failures alongside a directory that doesn't have lintable files results in the errors being hidden and mozlint reporting that everying is OK. Differential Revision: https://phabricator.services.mozilla.com/D60686 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1d7d0b00b0
Коммит
8f09bc743f
|
@ -8,7 +8,6 @@ from __future__ import absolute_import, print_function
|
|||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import sys
|
||||
|
||||
|
@ -75,6 +74,7 @@ def lint(paths, config, binary=None, fix=None, setup=None, **lintargs):
|
|||
# This keeps ext as a single argument.
|
||||
'--ext', '[{}]'.format(','.join(config['extensions'])),
|
||||
'--format', 'json',
|
||||
'--no-error-on-unmatched-pattern',
|
||||
] + extra_args + exclude_args + paths
|
||||
log.debug("Command: {}".format(' '.join(cmd_args)))
|
||||
|
||||
|
@ -106,10 +106,6 @@ def lint(paths, config, binary=None, fix=None, setup=None, **lintargs):
|
|||
jsonresult = json.loads(proc.output[0])
|
||||
except ValueError:
|
||||
output = "\n".join(proc.output)
|
||||
if re.search(r'No files matching the pattern "(.*)" were found.', output):
|
||||
print("warning: no files to lint (eslint)")
|
||||
return []
|
||||
|
||||
print(ESLINT_ERROR_MESSAGE.format(output))
|
||||
return 1
|
||||
|
||||
|
|
|
@ -12,8 +12,13 @@ def test_lint_with_global_exclude(lint, config, paths):
|
|||
|
||||
|
||||
def test_no_files_to_lint(lint, config, paths):
|
||||
ret = lint(paths('nolint'), root=build.topsrcdir)
|
||||
assert ret == []
|
||||
# A directory with no files to lint.
|
||||
results = lint(paths('nolint'), root=build.topsrcdir)
|
||||
assert results == []
|
||||
|
||||
# Errors still show up even when a directory with no files is passed in.
|
||||
results = lint(paths('nolint', 'subdir/bad.js'), root=build.topsrcdir)
|
||||
assert len(results) == 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Загрузка…
Ссылка в новой задаче