Config selection
yamllint -c <config> <file>
Use a config file
yamllint -d relaxed <file>
Built-in lenient preset
yamllint -d default <file>
Built-in default preset
yamllint -d "{extends: default, rules: {line-length:
{max: 120}}}" .
Inline config on the CLI
YAMLLINT_CONFIG_FILE=<path> yamllint .
Config via environment
.yamllint
Per-project config file name
Also .yamllint.yaml and .yamllint.yml; searched in the current
dir and its parents.
~/.config/yamllint/config
User-wide fallback config
Config file keys
extends: default
Start from the default preset
extends: relaxed
Start from the lenient preset
rules:
Map of rule name to settings
<rule>: enable
Turn a rule on with defaults
<rule>: disable
Turn a rule off
level: warning
Rule problems become warnings
level: error
Rule problems become errors
ignore: |
Gitignore-style paths to skip
<rule>: {ignore: <patterns>}
Skip paths for one rule only
ignore-from-file: .gitignore
Read ignore patterns from a file
Cannot be combined with ignore.
yaml-files: ["*.yaml", ".yamllint"]
Which names count as YAML
Whitespace rules
indentation: {spaces: 2}
Fixed indent width
indentation: {spaces: consistent}
Any width, used consistently
indentation: {indent-sequences: consistent}
Allow both list indent styles
true forces indented lists under keys, false forbids it,
consistent allows either per file.
line-length: {max: 120}
Longer lines allowed
line-length: {allow-non-breakable-words: true}
Long URLs are exempt
line-length: {allow-non-breakable-inline-mappings:
true}
Exempt long key: value lines
line-length: disable
No line length limit
trailing-spaces: enable
Flag spaces at line end
empty-lines: {max: 1}
Limit consecutive blank lines
new-line-at-end-of-file: enable
Require a final newline
new-lines: {type: unix}
LF line endings (also dos, platform)
hyphens: {max-spaces-after: 1}
Spaces after a list dash
Syntax and style rules
document-start: {present: false}
Do not require ---
document-start: disable
Ignore the --- check
document-end: {present: true}
Require ... at the end
truthy: {allowed-values: ["true",
"false"]}
Which bool words are allowed
truthy: {allowed-values: ["true", "false",
"on"]}
Allow on (GitHub Actions)
truthy: {check-keys: false}
Do not flag keys like on:
comments: {min-spaces-from-content: 1}
Gap before inline comment
comments: {require-starting-space: true}
Need # then a space
comments-indentation: disable
Allow odd comment indent
colons: {max-spaces-after: -1}
No limit after colon (aligned values)
braces: {min-spaces-inside: 0, max-spaces-inside: 1}
Spaces inside { }
brackets: {max-spaces-inside: 1}
Spaces inside [ ]
commas: {max-spaces-after: 1}
Spaces after commas
braces: {forbid: true}
Ban flow mappings {a: 1}
brackets: {forbid: true}
Ban flow lists [a, b]
Value and key rules
key-duplicates: enable
Same key twice in a mapping
On by default; the most useful catch for copy-pasted config.
key-duplicates: {forbid-duplicated-merge-keys: true}
Also duplicates via <<
key-ordering: enable
Require sorted keys
key-ordering: {ignored-keys:
["<regex>"]}
Exempt keys from sorting
anchors: {forbid-unused-anchors: true}
Flag &anchors nobody uses
anchors: {forbid-duplicated-anchors: true}
Flag a repeated &anchor name
anchors: {forbid-undeclared-aliases: true}
Flag *alias with no anchor
quoted-strings: {quote-type: double}
Force one quote style
quoted-strings: {required: only-when-needed}
Quote only when necessary
quoted-strings: {allow-quoted-quotes: true}
Keep quotes holding other quotes
empty-values: enable
Flag key: with no value
octal-values: enable
Flag 0777 style numbers