summaryrefslogtreecommitdiffstats
path: root/tools/lint/test/test_eslint.py
blob: 01456a406392e05db00c336fbfd9c791587e6106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import mozunit

from conftest import build

LINTER = "eslint"


def test_lint_with_global_exclude(lint, config, paths):
    config["exclude"] = ["subdir", "import"]
    results = lint(paths(), config=config, root=build.topsrcdir)
    assert len(results) == 0


def test_no_files_to_lint(lint, config, paths):
    # 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


def test_bad_import(lint, config, paths):
    results = lint(paths("import"), config=config, root=build.topsrcdir)
    assert results == 1


if __name__ == "__main__":
    mozunit.main()