Bug 1509391 - [eslint] Ignore excluded files that mozlint wasn't able to handle automatically r=Standard8

Normally eslint handles its own file exclusions, but there are still some
globally excluded paths that |mach lint| passes in (e.g objdirs and things in
ThirdPartyPaths.txt).

This makes sure that if they show up in the 'config', we handle them.

Differential Revision: https://phabricator.services.mozilla.com/D12712

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2018-11-26 14:16:59 +00:00
Родитель bb423a3f8f
Коммит afd8a94f03
5 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -60,6 +60,10 @@ def lint(paths, config, binary=None, fix=None, setup=None, **lintargs):
return 1
extra_args = lintargs.get('extra_args') or []
exclude_args = []
for path in config.get('exclude', []):
exclude_args.extend(['--ignore-pattern', os.path.relpath(path, lintargs['root'])])
cmd_args = [binary,
os.path.join(module_path, "node_modules", "eslint", "bin", "eslint.js"),
# Enable the HTML plugin.
@ -70,7 +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',
] + extra_args + paths
] + extra_args + exclude_args + paths
# eslint requires that --fix be set before the --ext argument.
if fix:

Просмотреть файл

Просмотреть файл

@ -0,0 +1,2 @@
// Missing semicolon
let foo = "bar"

Просмотреть файл

@ -2,4 +2,5 @@
subsuite=mozlint, os == "linux"
skip-if = python == 3
[test_eslint.py]
[test_flake8.py]

Просмотреть файл

@ -0,0 +1,15 @@
import mozunit
from conftest import build
LINTER = 'eslint'
def test_lint_with_global_exclude(lint, config, paths):
config['exclude'] = ['subdir']
results = lint(paths(), config=config, root=build.topsrcdir)
assert len(results) == 0
if __name__ == '__main__':
mozunit.main()