mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
Added yaml tl;dr and yamllint notes to the kb
This commit is contained in:
59
knowledge base/yamllint.md
Normal file
59
knowledge base/yamllint.md
Normal 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
|
||||
Reference in New Issue
Block a user