зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1485793 - [eslint] Don't print an error message if there aren't any files to lint, r=Standard8
This case is expected in the mozlint world (e.g, when running all linters). This will still print a warning, just a far less scary one and will still return 0. There is a case to be made that we should silently ignore this as no other linters print this warning, but it's useful enough to warrant keeping. Differential Revision: https://phabricator.services.mozilla.com/D37414 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
da30f0dd76
Коммит
09a16b2413
|
@ -6,6 +6,7 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "eslint"))
|
||||
|
@ -97,7 +98,12 @@ def lint(paths, config, binary=None, fix=None, setup=None, **lintargs):
|
|||
try:
|
||||
jsonresult = json.loads(proc.output[0])
|
||||
except ValueError:
|
||||
print(ESLINT_ERROR_MESSAGE.format("\n".join(proc.output)))
|
||||
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
|
||||
|
||||
results = []
|
||||
|
|
|
@ -11,5 +11,10 @@ def test_lint_with_global_exclude(lint, config, paths):
|
|||
assert len(results) == 0
|
||||
|
||||
|
||||
def test_no_files_to_lint(lint, config, paths):
|
||||
ret = lint(paths('nolint'), root=build.topsrcdir)
|
||||
assert ret == []
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
||||
|
|
Загрузка…
Ссылка в новой задаче