Bug 1509391 - [eslint] Ignore excluded files that mozlint wasn't able to handle automatically r=Standard8
☠☠ backed out by 0a2f54a1a5ca ☠ ☠
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Mon, 26 Nov 2018 14:16:59 +0000
changeset 504549 c8e417bfccfbba8bd7917368778939949d1126bd
parent 504548 46bb2a2ba36f639a81098d8264b8a9d48dbbd315
child 504550 5720aea08e4f55c211eaab665d32838c932d9c07
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1509391
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
tools/lint/eslint/__init__.py
tools/lint/test/files/eslint/good.js
tools/lint/test/files/eslint/subdir/bad.js
tools/lint/test/python.ini
tools/lint/test/test_eslint.py
--- a/tools/lint/eslint/__init__.py
+++ b/tools/lint/eslint/__init__.py
@@ -55,27 +55,31 @@ def lint(paths, config, binary=None, fix
     if not binary:
         binary, _ = find_node_executable()
 
     if not binary:
         print(ESLINT_NOT_FOUND_MESSAGE)
         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.
                 # We can't currently enable this in the global config file
                 # because it has bad interactions with the SublimeText
                 # ESLint plugin (bug 1229874).
                 '--plugin', 'html',
                 # 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:
         cmd_args.insert(2, '--fix')
 
     shell = False
     if os.environ.get('MSYSTEM') in ('MINGW32', 'MINGW64'):
         # The eslint binary needs to be run from a shell with msys
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/tools/lint/test/files/eslint/subdir/bad.js
@@ -0,0 +1,2 @@
+// Missing semicolon
+let foo = "bar"
--- a/tools/lint/test/python.ini
+++ b/tools/lint/test/python.ini
@@ -1,5 +1,6 @@
 [DEFAULT]
 subsuite=mozlint, os == "linux"
 skip-if = python == 3
 
+[test_eslint.py]
 [test_flake8.py]
new file mode 100644
--- /dev/null
+++ b/tools/lint/test/test_eslint.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()