Skip to main content
Version: 0.18.x

vale

API for declaring a Vale lint aspect that visits markdown files.

First, all markdown sources must be the srcs of some Bazel rule. Either use a filegroup with markdown in the tags:

filegroup(
name = "md",
srcs = glob(["*.md"]),
tags = ["markdown"],
)

or use a markdown_library rule such as the one in https://github.com/dwtj/dwtj_rules_markdown.

Note that any Markdown files in the repo which aren't in the srcs of one of these rules will not be linted by Vale.

Styles

Vale is powered by Styles. There is a built-in style and if this is sufficient then it's not necessary to follow the rest of this section.

The styles from https://vale.sh/hub/ are already fetched by fetch_vale() which has a Bazel-based mirror of https://github.com/errata-ai/packages/blob/master/library.json. It's possible to fetch more styles using a typical http_archive() call.

At runtime, Vale requires the styles are "installed" into a folder together. Use the copy_to_directory rule to accomplish this, for example,

copy_to_directory(
name = "vale_styles",
srcs = ["@vale_write-good//:write-good"],
include_external_repositories = ["vale_*"],
)

Note that the .vale.ini file may have a StylesPath entry. Under Bazel, we set VALE_STYLES_PATH in the environment, so the StylesPath is used only when running Vale outside Bazel, such as in an editor extension.

See the example in rules_lint for a fully-working vale setup.

Usage

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

vale = vale_aspect(
binary = "@@//tools/lint:vale",
# A copy_to_bin rule that places the .vale.ini file into bazel-bin
config = "@@//:.vale_ini",
# Optional.
# A copy_to_directory rule that "installs" custom styles together into a single folder
styles = "@@//tools/lint:vale_styles",
)

Macros and Functions

fetch_vale

A repository macro used from WORKSPACE to fetch vale binaries

Example usage (generated):

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

fetch_vale(
)

tag

Optional. Default: "v3.1.0"

a tag of vale that we have mirrored, e.g. v3.0.5

lint_vale_aspect

A factory function to create a linter aspect.

Example usage (generated):

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

lint_vale_aspect(
binary = None,
config = None,
)

binary

Required.

config

Required.

styles

Optional. Default: Label("//lint:empty_styles")

vale_action

Example usage (generated):

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

vale_action(
ctx = None,
executable = None,
srcs = [],
styles = None,
config = None,
report = None,
)

ctx

Required.

executable

Required.

srcs

Required.

styles

Required.

config

Required.

report

Required.

use_exit_code

Optional. Default: False