yamllint
yamllint uses a set of rules to check source files for problems
| Type | object |
|---|---|
| File match |
**/.yamllint
**/.yamllint.yaml
**/.yamllint.yml
|
| Schema URL | https://catalog.lintel.tools/schemas/schemastore/yamllint/latest.json |
| Source | https://www.schemastore.org/yamllint.json |
Validate with Lintel
npx @lintel/lintel check
yamllint uses a set of rules to check YAML source files for problems.
Properties
When writing a custom configuration file, you don’t need to redefine every rule. Just extend the default configuration (or any already-existing configuration file).
To configure what yamllint should consider as YAML files when listing directories, set yaml-files configuration option.
[
"*.yaml",
"*.yml",
".yamllint"
]
This is passed to Python's locale.setlocale.
When linting a document with yamllint, a series of rules are checked against. A configuration file can be used to enable or disable these rules, to set their level (error or warning), but also to tweak their options.
23 nested properties
Use this rule to report duplicated anchors and aliases referencing undeclared anchors.
Use this rule to control the use of flow mappings or number of spaces inside braces ({ and }).
Use this rule to control the use of flow sequences or the number of spaces inside brackets ([ and ]).
Use this rule to control the position and formatting of comments.
{
"level": "warning"
}
Use this rule to force comments to be indented like content.
{
"level": "warning"
}
Use this rule to require or forbid the use of document end marker (...).
Use this rule to require or forbid the use of document start marker (---).
{
"level": "warning"
}
Use this rule to set a maximal number of allowed consecutive blank lines.
Use this rule to prevent nodes with empty content, that implicitly result in null values.
Use this rule to limit the permitted values for floating-point numbers. YAML permits three classes of float expressions: approximation to real numbers, positive and negative infinity and "not a number".
Use this rule to prevent multiple entries with the same key in mappings.
Use this rule to enforce alphabetical ordering of keys in mappings. The sorting order uses the Unicode code point number as a default. As a result, the ordering is case-sensitive and not accent-friendly (see examples below). This can be changed by setting the global locale option. This allows one to sort case and accents properly.
Use this rule to require a new line character (\n) at the end of files.
The POSIX standard requires the last line to end with a new line character. All UNIX tools expect a new line at the end of files. Most text editors use this convention too.
Use this rule to prevent values with octal numbers. In YAML, numbers that start with 0 are interpreted as octal, but this is not always wanted. For instance 010 is the city code of Beijing, and should not be converted to 8.
Use this rule to forbid any string values that are not quoted, or to prevent quoted strings without needing it. You can also enforce the type of the quote used.
Use this rule to forbid non-explicitly typed truthy values other than allowed ones (by default: true and false), for example YES or off.
This can be useful to prevent surprises from YAML parsers transforming [yes, FALSE, Off] into [true, false, false] or {y: 1, yes: 2, on: 3, true: 4, True: 5} into {y: 1, true: 5}.
Depending on the YAML specification version used by the YAML document, the list of truthy values can differ. In YAML 1.2, only capitalized / uppercased combinations of true and false are considered truthy, whereas in YAML 1.1 combinations of yes, no, on and off are too. To make the YAML specification version explicit in a YAML document, a %YAML 1.2 directive can be used (see example below).
{
"level": "warning"
}