.vale.ini
Learn how a configuration file is shaped, where Vale finds it, and how several of them combine.
The file
A configuration is an INI file with three kinds of section. Keys above the first section header apply to the run as a whole. [formats] maps file extensions Vale does not know onto ones it does. Every other section header is a glob, and its keys apply to the files that match:
StylesPath = styles
MinAlertLevel = suggestion
Packages = Microsoft
[formats]
mdx = md
[*]
BasedOnStyles = Vale
[*.{md,mdx}]
BasedOnStyles = Vale, Microsoft
Microsoft.Contractions = NOThe generator writes a starting file, and the View file beside it when a data format is chosen. After that, vale sync installs whatever Packages names, and vale ls-config prints the configuration a run would use, with every source resolved.
Each key has one home. A core key under a section, or a section key above the first header, is an error that names the key. A key Vale does not read at all is a warning and is otherwise ignored, so a URL left on a line of its own is noticed rather than silently parsed as a key named https.
Core settings
string
The directory holding styles and the config/ assets. Relative to the file that sets it, and it has to exist.
string
The pattern a word-level token is wrapped in, for languages where \b is the wrong boundary.
Format associations
[formats] tells Vale to read one extension as another:
The association changes how a file is parsed, not what it is called: sections still match the name on disk, so the files above need a [*.mdx] section, or one whose glob covers both. Mapping a code or data extension onto a markup one lints the markup embedded in that code or data, such as the Markdown in a language's doc comments. Mapping an extension Vale doesn't know onto a code format parses the file with that language's grammar (Vale v3.25.0 or later), so it's for files that are that language under another extension, not for a language Vale doesn't support.
A key may also be a file name or a glob, for a file that has no extension to map:
The extension is looked up first; then the keys are tried in order, a bare name against the file's base name and a glob against the base name and the path. Naming a file or a glob requires Vale v3.22.0 or later.
A second named section, [asciidoctor], holds attributes passed to Asciidoctor when it renders .adoc files. See AsciiDoc.
A third, [sphinx], names the directives and roles a Sphinx project's extensions add, so their text is read the right way in reStructuredText and MyST alike. See reStructuredText.
Sections
A section header is a glob matched against a file's path as Vale was given it. [*] is every file, [*.{md,rst}] is two extensions, and [docs/src/*.md] is one part of the project when Vale runs from its root; see Globbing. Sections are read in the order written, and a file that matches more than one takes all of them; see A file in several sections.
string[]
The styles whose rules run. A later matching section replaces the list rather than adding to it.
string[]
Patterns whose matches are removed before parsing, for block-level markup Vale does not know.
string[]
Patterns whose matches are removed before linting, for inline markup Vale does not know.
string[2]
The pair that opens and closes a comment, so in-text directives work in a format without HTML comments.
A comma inside a BlockIgnores or TokenIgnores pattern is written \,, so a quantifier like {2,} survives the split.
Rules
Any other key under a section names a rule, Style.Rule, and its value switches the rule or sets its level:
A level set in one section holds for that section's files only, so a rule can be an error in Markdown and a warning in HTML. A rule named on its own, without its style in BasedOnStyles, is loaded from its file.
A bracket key adjusts one of the rule's parameters, and holds wherever the rule runs:
It takes the scalars a rule reads: a number, a boolean, a level name. The keys that make a rule what it is, such as message, tokens, swap, and exceptions, are refused, since changing those is authoring and belongs in a style that extends the rule.
A file in several sections
A file matches every section whose glob fits it, and each one applies, in the order written. guide.fr.md matches both [*.md] and [*.fr.md], so it takes the first section's settings and then the second's:
Every Markdown file runs the Google style. A French one runs it without those two rules, and nothing in [*.fr.md] repeats what [*.md] set. When both sections set the same key, the later one holds for that file: a rule at error in [*.md] and suggestion in [*.fr.md] is a suggestion in French files and an error elsewhere.
BasedOnStyles is the one key that replaces rather than adjusts. A [*.fr.md] that names its own styles runs those alone, so leave it out of a section that only means to adjust. [*] is the base under every section, wherever in the file it is written.
Conditional sections
A header can filter the files its glob matches, the way a list comprehension's if does. The section applies only where the expression after if holds:
NONE runs nothing, so unpublished posts are skipped and never read. A condition can adjust instead of skipping, and every section key follows it:
The expression is written the way a filter is, so the fields are capitalized and start with a dot:
Field
Example for docs/_posts/draft.md
.Path
"docs/_posts/draft.md", relative to the project root
.Dir
"docs/_posts"
.Name
"draft.md"
.Ext
".md"
.Meta
The file's front matter, keyed as written
.Meta holds YAML, TOML, or JSON front matter, and its keys keep their own case. A field a file doesn't have is nil, so .Meta.published == false is false for a file with no published key, and .Meta.draft on its own reads as false.
A conditional section is placed in order like any other, so write it after the sections it adjusts. An expression that doesn't compile is a configuration error, reported before any file is read.
Search
A run finds its configuration in this order and uses the first that applies:
The file named by
--config.The file named by
VALE_CONFIG_PATH.The first of
.vale.ini,_vale.ini,vale.ini,.vale,_vale, or.config/vale.iniin the working directory or a directory above it, then in the home directory. A root-level file is read before one in.config/. The directory the file was found in is the project root, so a.config/vale.inimakes the directory holding.configthe root while its own relative paths, such asStylesPath, still resolve against.config/. A file named by--configorVALE_CONFIG_PATHmakes its own directory the root.
Whichever one is found, the user-level file is read too, underneath it. It lives in the operating system's configuration directory, and vale ls-dirs prints the path:
Windows
%LOCALAPPDATA%\vale\.vale.ini
macOS
$HOME/Library/Application Support/vale/.vale.ini
Linux
$XDG_CONFIG_HOME/vale/.vale.ini
That file is the place for preferences that hold across every project, and --no-global leaves it out of a run. When no project file is found, it is the configuration.
Layering
When more than one file is read, the user-level file comes first and the project's file is laid over it, so where both set a single value, the project's holds: MinAlertLevel reads the last one set. A list key gathers every value from every file, in reading order and without duplicates, so a BasedOnStyles in the user-level file adds styles to a project's. StylesPath is both: each file's path is added, resolved against that file, and the project's is the one new assets are written to.
Under a project file that names ProjectStyle at MinAlertLevel = error, this runs both styles and reports errors: the list joined, and the project's level held.
vale sync is the exception. It reads exactly one file, the one the search finds, and installs that file's Packages. To install what the user-level file names, point the command at it with --config.
Last updated