The `yamllint` is basically a program to check syntax of YAML files. If you got YAML files in your project, you can ask your CI (continuous integration) to check for YAML syntax.
Read yamllint documentation at https://yamllint.readthedocs.io/en/latest/index.html
What is yamllint?
A linter for YAML files
What is Linting?
Linting is the process of running a program that will analyse code for potential errors.
A simple way to install it
pip install yamllint
A simple usage
yamllint .
Output:
./my1.yml
1:1 warning missing document start "---" (document-start)
19:7 error wrong indentation: expected 8 but found 6 (indentation)
22:9 error wrong indentation: expected 10 but found 8 (indentation)
35:9 error wrong indentation: expected 10 but found 8 (indentation)
40:81 error line too long (86 > 80 characters) (line-length)
46:9 error wrong indentation: expected 10 but found 8 (indentation)
49:7 error wrong indentation: expected 8 but found 6 (indentation)
./my2.yml
1:1 warning missing document start "---" (document-start)
6:7 error wrong indentation: expected 4 but found 6 (indentation)
9:5 error wrong indentation: expected 2 but found 4 (indentation)
11:5 error wrong indentation: expected 6 but found 4 (indentation)
It recursively checks all the yaml files in the current directory
Can we guide yamllint what to check in configuration file?
Create a config file
cat .yamllint.yaml
extends: default
rules:
# 90 chars should be enough, but don't fail if a line is longer
line-length:
max: 90
level: warning
# Disabling the document-start error messages
document-start:
present: false
yamllint -c .yamllint.yaml .
No comments:
Post a Comment