Skip to content

Latest commit

 

History

History
58 lines (36 loc) · 1.17 KB

lint_test.md

File metadata and controls

58 lines (36 loc) · 1.17 KB

Factory function to make lint test rules.

When the linter exits non-zero, the test will print the output of the linter and then fail.

To use this, in your linters.bzl where you define the aspect, just create a test that references it.

For example, with flake8:

load("@aspect_rules_lint//lint:lint_test.bzl", "lint_test")
load("@aspect_rules_lint//lint:flake8.bzl", "flake8_aspect")

flake8 = flake8_aspect(
    binary = "@@//:flake8",
    config = "@@//:.flake8",
)

flake8_test = lint_test(aspect = flake8)

Now in your BUILD files you can add a test:

load("//tools/lint:linters.bzl", "flake8_test")

py_library(
    name = "unused_import",
    srcs = ["unused_import.py"],
)

flake8_test(
    name = "flake8",
    srcs = [":unused_import"],
)

lint_test

load("@aspect_rules_lint//lint:lint_test.bzl", "lint_test")

lint_test(aspect)

PARAMETERS

Name Description Default Value
aspect

-

none