Added yaml tl;dr and yamllint notes to the kb

This commit is contained in:
Michele Cereda
2022-04-29 10:40:54 +02:00
parent 7d5465b10b
commit 2fef13f21f
2 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
# Yamllint
A linter for YAML files written in Python and compatible with Python 3 only.
## TL;DR
```shell
# Use a specific configuration file.
yamllint -c /path/to/config file.yaml
# Pass custom configuration options on the CLI.
yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" file.yaml
```
## Configuration
`yamllint` uses a set of [rules] to check YAML files for problems. Each rule is independent from the others, and can be enabled, disabled or tweaked. All these settings can be gathered in a configuration file.
To use a custom configuration file, use the `-c` option:
```shell
yamllint -c /path/to/config file.yaml
```
If no such option is provided, `yamllint` will look for a configuration file in the following locations (by order of preference):
- `.yamllint`, `.yamllint.yaml` or `.yamllint.yml` in the current working directory
- the file referenced by `$YAMLLINT_CONFIG_FILE`, if set
- `$XDG_CONFIG_HOME/yamllint/config`
- `~/.config/yamllint/config`
Finally, if no config file is found the default configuration is applied.
You can avoid the need to redefine every rule when writing a custom configuration file `extend`ing the default one or any other already-existing configuration file:
```yaml
extends: default
rules:
comments-indentation: disable # don't bother me at all with this rule
```
```yaml
extends: relaxed
line-length: # just warn if a line is longer than 120 chars, instead of failing at 81
max: 120
level: warning
indentation: # loosen up on block sequences indentation
indent-sequences: whatever
```
## Further readings
- [GitHub] page
- Yamllint's [documentation]
- [Rules]
[documentation]: https://yamllint.readthedocs.io/en/stable
[github]: https://github.com/adrienverge/yamllint
[rules]: https://yamllint.readthedocs.io/en/stable/rules.html