.\" Man page generated from reStructuredText. . .TH "YAMLLINT" "1" "Nov 07, 2016" "1.5.0" "yamllint" .SH NAME yamllint \- . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .sp A linter for YAML files. .sp yamllint does not only check for syntax validity, but for weirdnesses like key repetition and cosmetic problems such as lines length, trailing spaces, indentation, etc. .SH SCREENSHOT [image: yamllint screenshot] [image] .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The default output format is inspired by \fI\%eslint\fP, a great linting tool for Javascript. .UNINDENT .UNINDENT .SH TABLE OF CONTENTS .SS Quickstart .SS Installing yamllint .sp On Fedora / CentOS: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo dnf install yamllint .ft P .fi .UNINDENT .UNINDENT .sp On Debian 9+ / Ubuntu 16.04+: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo apt\-get install yamllint .ft P .fi .UNINDENT .UNINDENT .sp On older Debian / Ubuntu versions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo add\-apt\-repository \-y ppa:adrienverge/ppa && sudo apt\-get update sudo apt\-get install yamllint .ft P .fi .UNINDENT .UNINDENT .sp Alternatively using pip, the Python package manager: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo pip install yamllint .ft P .fi .UNINDENT .UNINDENT .sp If you prefer installing from source, you can run, from the source directory: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C python setup.py sdist sudo pip install dist/yamllint\-*.tar.gz .ft P .fi .UNINDENT .UNINDENT .SS Running yamllint .sp Basic usage: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yamllint file.yml other\-file.yaml .ft P .fi .UNINDENT .UNINDENT .sp You can also lint all YAML files in a whole directory: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yamllint . .ft P .fi .UNINDENT .UNINDENT .sp The output will look like (colors are not displayed here): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C file.yml 1:4 error trailing spaces (trailing\-spaces) 4:4 error wrong indentation: expected 4 but found 3 (indentation) 5:4 error duplication of key "id\-00042" in mapping (key\-duplicates) 6:6 warning comment not indented like content (comments\-indentation) 12:6 error too many spaces after hyphen (hyphens) 15:12 error too many spaces before comma (commas) other\-file.yaml 1:1 warning missing document start "\-\-\-" (document\-start) 6:81 error line too long (87 > 80 characters) (line\-length) 10:1 error too many blank lines (4 > 2) (empty\-lines) 11:4 error too many spaces inside braces (braces) .ft P .fi .UNINDENT .UNINDENT .sp Add the \fB\-f parsable\fP arguments if you need an output format parsable by a machine (for instance for syntax highlighting in text editors). The output will then look like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C file.yml:6:2: [warning] missing starting space in comment (comments) file.yml:57:1: [error] trailing spaces (trailing\-spaces) file.yml:60:3: [error] wrong indentation: expected 4 but found 2 (indentation) .ft P .fi .UNINDENT .UNINDENT .sp If you have a custom linting configuration file (see how to configure yamllint), it can be passed to yamllint using the \fB\-c\fP option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yamllint \-c ~/myconfig file.yaml .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If you have a \fB\&.yamllint\fP file in your working directory, it will be automatically loaded as configuration by yamllint. .UNINDENT .UNINDENT .SS Configuration .sp yamllint uses a set of rules to check source 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. .sp To use a custom configuration file, use the \fB\-c\fP option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yamllint \-c /path/to/myconfig file\-to\-lint.yaml .ft P .fi .UNINDENT .UNINDENT .sp If \fB\-c\fP is not provided, yamllint will look for a configuration file in the following locations (by order of preference): .INDENT 0.0 .IP \(bu 2 \fB\&.yamllint\fP in the current working directory .IP \(bu 2 \fB$XDG_CONFIG_HOME/yamllint/config\fP .IP \(bu 2 \fB~/.config/yamllint/config\fP .UNINDENT .sp Finally if no config file is found, the default configuration is applied. .SS Default configuration .sp Unless told otherwise, yamllint uses its \fBdefault\fP configuration: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-\-\- rules: braces: min\-spaces\-inside: 0 max\-spaces\-inside: 0 brackets: min\-spaces\-inside: 0 max\-spaces\-inside: 0 colons: max\-spaces\-before: 0 max\-spaces\-after: 1 commas: max\-spaces\-before: 0 min\-spaces\-after: 1 max\-spaces\-after: 1 comments: level: warning require\-starting\-space: yes min\-spaces\-from\-content: 2 comments\-indentation: level: warning document\-end: disable document\-start: level: warning present: yes empty\-lines: max: 2 max\-start: 0 max\-end: 0 hyphens: max\-spaces\-after: 1 indentation: spaces: consistent indent\-sequences: yes check\-multi\-line\-strings: no key\-duplicates: enable line\-length: max: 80 allow\-non\-breakable\-words: yes allow\-non\-breakable\-inline\-mappings: no new\-line\-at\-end\-of\-file: enable new\-lines: type: unix trailing\-spaces: enable truthy: level: warning .ft P .fi .UNINDENT .UNINDENT .sp Details on rules can be found on the rules page\&. .sp There is another pre\-defined configuration named \fBrelaxed\fP\&. As its name suggests, it is more tolerant: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-\-\- extends: default rules: braces: level: warning max\-spaces\-inside: 1 brackets: level: warning max\-spaces\-inside: 1 colons: level: warning commas: level: warning comments: disable comments\-indentation: disable document\-start: disable empty\-lines: level: warning hyphens: level: warning indentation: level: warning indent\-sequences: consistent line\-length: level: warning allow\-non\-breakable\-inline\-mappings: yes truthy: disable .ft P .fi .UNINDENT .UNINDENT .sp It can be chosen using: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yamllint \-d relaxed file.yml .ft P .fi .UNINDENT .UNINDENT .SS Extending the default configuration .sp When writing a custom configuration file, you don\(aqt need to redefine every rule. Just extend the \fBdefault\fP configuration (or any already\-existing configuration file). .sp For instance, if you just want to disable the \fBcomments\-indentation\fP rule, your file could look like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # This is my first, very own configuration file for yamllint! # It extends the default conf by adjusting some options. extends: default rules: comments\-indentation: disable # don\(aqt bother me with this rule .ft P .fi .UNINDENT .UNINDENT .sp Similarly, if you want to set the \fBline\-length\fP rule as a warning and be less strict on block sequences indentation: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C extends: default rules: # 80 chars should be enough, but don\(aqt fail if a line is longer line\-length: max: 80 level: warning # accept both key: # \- item # # and key: # \- item indentation: indent\-sequences: whatever .ft P .fi .UNINDENT .UNINDENT .SS Custom configuration without a config file .sp It is possible \-\- although not recommended \-\- to pass custom configuration options to yamllint with the \fB\-d\fP (short for \fB\-\-config\-data\fP) option. .sp Its content can either be the name of a pre\-defined conf (example: \fBdefault\fP or \fBrelaxed\fP) or a serialized YAML object describing the configuration. .sp For instance: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yamllint \-d "{extends: relaxed, rules: {line\-length: {max: 120}}}" file.yaml .ft P .fi .UNINDENT .UNINDENT .SS Errors and warnings .sp Problems detected by yamllint can be raised either as errors or as warnings. .sp In both cases, the script will output them (with different colors when using the \fBstandard\fP output format), but the exit code can be different. More precisely, the script will exit will a failure code \fIonly when\fP there is one or more error(s). .SS Rules .sp When linting a document with yamllint, a series of rules (such as \fBline\-length\fP, \fBtrailing\-spaces\fP, etc.) are checked against. .sp A configuration file can be used to enable or disable these rules, to set their level (\fIerror\fP or \fIwarning\fP), but also to tweak their options. .sp This page describes the rules and their options. .SS List of rules .INDENT 0.0 .IP \(bu 2 \fI\%braces\fP .IP \(bu 2 \fI\%brackets\fP .IP \(bu 2 \fI\%colons\fP .IP \(bu 2 \fI\%commas\fP .IP \(bu 2 \fI\%comments\fP .IP \(bu 2 \fI\%comments\-indentation\fP .IP \(bu 2 \fI\%document\-end\fP .IP \(bu 2 \fI\%document\-start\fP .IP \(bu 2 \fI\%empty\-lines\fP .IP \(bu 2 \fI\%hyphens\fP .IP \(bu 2 \fI\%indentation\fP .IP \(bu 2 \fI\%key\-duplicates\fP .IP \(bu 2 \fI\%line\-length\fP .IP \(bu 2 \fI\%new\-line\-at\-end\-of\-file\fP .IP \(bu 2 \fI\%new\-lines\fP .IP \(bu 2 \fI\%trailing\-spaces\fP .IP \(bu 2 \fI\%truthy\fP .UNINDENT .SS braces .sp Use this rule to control the number of spaces inside braces (\fB{\fP and \fB}\fP). Options.INDENT 0.0 .IP \(bu 2 \fBmin\-spaces\-inside\fP defines the minimal number of spaces required inside braces. .IP \(bu 2 \fBmax\-spaces\-inside\fP defines the maximal number of spaces allowed inside braces. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBbraces: {min\-spaces\-inside: 0, max\-spaces\-inside: 0}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: {key1: 4, key2: 8} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: { key1: 4, key2: 8 } .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBbraces: {min\-spaces\-inside: 1, max\-spaces\-inside: 3}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: { key1: 4, key2: 8 } .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: { key1: 4, key2: 8 } .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: { key1: 4, key2: 8 } .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: {key1: 4, key2: 8 } .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS brackets .sp Use this rule to control the number of spaces inside brackets (\fB[\fP and \fB]\fP). Options.INDENT 0.0 .IP \(bu 2 \fBmin\-spaces\-inside\fP defines the minimal number of spaces required inside brackets. .IP \(bu 2 \fBmax\-spaces\-inside\fP defines the maximal number of spaces allowed inside brackets. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBbrackets: {min\-spaces\-inside: 0, max\-spaces\-inside: 0}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [1, 2, abc] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [ 1, 2, abc ] .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBbrackets: {min\-spaces\-inside: 1, max\-spaces\-inside: 3}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [ 1, 2, abc ] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [ 1, 2, abc ] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [ 1, 2, abc ] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [1, 2, abc ] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS colons .sp Use this rule to control the number of spaces before and after colons (\fB:\fP). Options.INDENT 0.0 .IP \(bu 2 \fBmax\-spaces\-before\fP defines the maximal number of spaces allowed before colons (use \fB\-1\fP to disable). .IP \(bu 2 \fBmax\-spaces\-after\fP defines the maximal number of spaces allowed after colons (use \fB\-1\fP to disable). .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBcolons: {max\-spaces\-before: 0, max\-spaces\-after: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: \- a \- b key: value .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBcolons: {max\-spaces\-before: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object : \- a \- b .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object : \- a \- b .ft P .fi .UNINDENT .UNINDENT .IP 3. 3 With \fBcolons: {max\-spaces\-after: 2}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C first: 1 second: 2 third: 3 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C first: 1 2nd: 2 third: 3 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS commas .sp Use this rule to control the number of spaces before and after commas (\fB,\fP). Options.INDENT 0.0 .IP \(bu 2 \fBmax\-spaces\-before\fP defines the maximal number of spaces allowed before commas (use \fB\-1\fP to disable). .IP \(bu 2 \fBmin\-spaces\-after\fP defines the minimal number of spaces required after commas. .IP \(bu 2 \fBmax\-spaces\-after\fP defines the maximal number of spaces allowed after commas (use \fB\-1\fP to disable). .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBcommas: {max\-spaces\-before: 0}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20, 30, {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20 , 30, {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBcommas: {max\-spaces\-before: 2}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10 , 20 , 30, {x: 1 , y: 2}] .ft P .fi .UNINDENT .UNINDENT .IP 3. 3 With \fBcommas: {max\-spaces\-before: \-1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20 , 30 , {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .IP 4. 3 With \fBcommas: {min\-spaces\-after: 1, max\-spaces\-after: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20,30, {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20,30, {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .IP 5. 3 With \fBcommas: {min\-spaces\-after: 1, max\-spaces\-after: 3}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20, 30, {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .IP 6. 3 With \fBcommas: {min\-spaces\-after: 0, max\-spaces\-after: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C strange var: [10, 20,30, {x: 1, y: 2}] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS comments .sp Use this rule to control the position and formatting of comments. Options.INDENT 0.0 .IP \(bu 2 Use \fBrequire\-starting\-space\fP to require a space character right after the \fB#\fP\&. Set to \fByes\fP to enable, \fBno\fP to disable. .IP \(bu 2 \fBmin\-spaces\-from\-content\fP is used to visually separate inline comments from content. It defines the minimal required number of spaces between a comment and its preceding content. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBcomments: {require\-starting\-space: yes}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C # This sentence # is a block comment .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C ############################## ## This is some documentation .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C #This sentence #is a block comment .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBcomments: {min\-spaces\-from\-content: 2}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C x = 2 ^ 127 \- 1 # Mersenne prime number .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C x = 2 ^ 127 \- 1 # Mersenne prime number .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS comments\-indentation .sp Use this rule to force comments to be indented like content. Examples.INDENT 0.0 .IP 1. 3 With \fBcomments\-indentation: {}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C # Fibonacci [0, 1, 1, 2, 3, 5] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C # Fibonacci [0, 1, 1, 2, 3, 5] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C list: \- 2 \- 3 # \- 4 \- 5 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C list: \- 2 \- 3 # \- 4 \- 5 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C # This is the first object obj1: \- item A # \- item B # This is the second object obj2: [] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C # This sentence # is a block comment .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C # This sentence # is a block comment .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS document\-end .sp Use this rule to require or forbid the use of document end marker (\fB\&...\fP). Options.INDENT 0.0 .IP \(bu 2 Set \fBpresent\fP to \fByes\fP when the document end marker is required, or to \fBno\fP when it is forbidden. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBdocument\-end: {present: yes}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \-\-\- this: is: [a, document] \&... \-\-\- \- this \- is: another one \&... .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \-\-\- this: is: [a, document] \-\-\- \- this \- is: another one \&... .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBdocument\-end: {present: no}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \-\-\- this: is: [a, document] \-\-\- \- this \- is: another one .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \-\-\- this: is: [a, document] \&... \-\-\- \- this \- is: another one .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS document\-start .sp Use this rule to require or forbid the use of document start marker (\fB\-\-\-\fP). Options.INDENT 0.0 .IP \(bu 2 Set \fBpresent\fP to \fByes\fP when the document start marker is required, or to \fBno\fP when it is forbidden. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBdocument\-start: {present: yes}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \-\-\- this: is: [a, document] \-\-\- \- this \- is: another one .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C this: is: [a, document] \-\-\- \- this \- is: another one .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBdocument\-start: {present: no}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C this: is: [a, document] \&... .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \-\-\- this: is: [a, document] \&... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS empty\-lines .sp Use this rule to set a maximal number of allowed consecutive blank lines. Options.INDENT 0.0 .IP \(bu 2 \fBmax\fP defines the maximal number of empty lines allowed in the document. .IP \(bu 2 \fBmax\-start\fP defines the maximal number of empty lines allowed at the beginning of the file. This option takes precedence over \fBmax\fP\&. .IP \(bu 2 \fBmax\-end\fP defines the maximal number of empty lines allowed at the end of the file. This option takes precedence over \fBmax\fP\&. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBempty\-lines: {max: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- foo: \- 1 \- 2 \- bar: [3, 4] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- foo: \- 1 \- 2 \- bar: [3, 4] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS hyphens .sp Use this rule to control the number of spaces after hyphens (\fB\-\fP). Options.INDENT 0.0 .IP \(bu 2 \fBmax\-spaces\-after\fP defines the maximal number of spaces allowed after hyphens. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBhyphens: {max\-spaces\-after: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- first list: \- a \- b \- \- 1 \- 2 \- 3 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- first list: \- a \- b .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- \- 1 \- 2 \- 3 .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBhyphens: {max\-spaces\-after: 3}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- key \- key2 \- key42 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- key \- key2 \- key42 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS indentation .sp Use this rule to control the indentation. Options.INDENT 0.0 .IP \(bu 2 \fBspaces\fP defines the indentation width, in spaces. Set either to an integer (e.g. \fB2\fP or \fB4\fP, representing the number of spaces in an indentation level) or to \fBconsistent\fP to allow any number, as long as it remains the same within the file. .IP \(bu 2 \fBindent\-sequences\fP defines whether block sequences should be indented or not (when in a mapping, this indentation is not mandatory \-\- some people perceive the \fB\-\fP as part of the indentation). Possible values: \fByes\fP, \fBno\fP, \fBwhatever\fP and \fBconsistent\fP\&. \fBconsistent\fP requires either all block sequences to be indented, or none to be. \fBwhatever\fP means either indenting or not indenting individual block sequences is OK. .IP \(bu 2 \fBcheck\-multi\-line\-strings\fP defines whether to lint indentation in multi\-line strings. Set to \fByes\fP to enable, \fBno\fP to disable. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBindentation: {spaces: 1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBindentation: {spaces: 4}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .ft P .fi .UNINDENT .UNINDENT .IP 3. 3 With \fBindentation: {spaces: consistent}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C some: Russian: dolls .ft P .fi .UNINDENT .UNINDENT .IP 4. 3 With \fBindentation: {spaces: 2, indent\-sequences: no}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C list: \- flying \- spaghetti \- monster .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C list: \- flying \- spaghetti \- monster .ft P .fi .UNINDENT .UNINDENT .IP 5. 3 With \fBindentation: {spaces: 2, indent\-sequences: whatever}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C list: \- flying: \- spaghetti \- monster \- not flying: \- spaghetti \- sauce .ft P .fi .UNINDENT .UNINDENT .IP 6. 3 With \fBindentation: {spaces: 2, indent\-sequences: consistent}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- flying: \- spaghetti \- monster \- not flying: \- spaghetti \- sauce .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- flying: \- spaghetti \- monster \- not flying: \- spaghetti \- sauce .ft P .fi .UNINDENT .UNINDENT .IP 7. 3 With \fBindentation: {spaces: 4, check\-multi\-line\-strings: yes}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C Blaise Pascal: Je vous écris une longue lettre parce que je n\(aqai pas le temps d\(aqen écrire une courte. .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C Blaise Pascal: Je vous écris une longue lettre parce que je n\(aqai pas le temps d\(aqen écrire une courte. .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C Blaise Pascal: Je vous écris une longue lettre parce que je n\(aqai pas le temps d\(aqen écrire une courte. .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C C code: void main() { printf("foo"); } .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C C code: void main() { printf("bar"); } .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS key\-duplicates .sp Use this rule to prevent multiple entries with the same key in mappings. Examples.INDENT 0.0 .IP 1. 3 With \fBkey\-duplicates: {}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- key 1: v key 2: val key 3: value \- {a: 1, b: 2, c: 3} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- key 1: v key 2: val key 1: value .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- {a: 1, b: 2, b: 3} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C duplicated key: 1 "duplicated key": 2 other duplication: 1 ? >\- other duplication : 2 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS line\-length .sp Use this rule to set a limit to lines length. Options.INDENT 0.0 .IP \(bu 2 \fBmax\fP defines the maximal (inclusive) length of lines. .IP \(bu 2 \fBallow\-non\-breakable\-words\fP is used to allow non breakable words (without spaces inside) to overflow the limit. This is useful for long URLs, for instance. Use \fByes\fP to allow, \fBno\fP to forbid. .IP \(bu 2 \fBallow\-non\-breakable\-inline\-mappings\fP implies \fBallow\-non\-breakable\-words\fP and extends it to also allow non\-breakable words in inline mappings. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBline\-length: {max: 70}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C long sentence: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C long sentence: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBline\-length: {max: 60, allow\-non\-breakable\-words: yes}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C this: is: \- a: http://localhost/very/very/very/very/very/very/very/very/long/url # this comment is too long, # but hard to split: # http://localhost/another/very/very/very/very/very/very/very/very/long/url .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- this line is waaaaaaaaaaaaaay too long but could be easily split... .ft P .fi .UNINDENT .UNINDENT .sp and the following code snippet would also \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- foobar: http://localhost/very/very/very/very/very/very/very/very/long/url .ft P .fi .UNINDENT .UNINDENT .IP 3. 3 With \fBline\-length: {max: 60, allow\-non\-breakable\-words: yes, allow\-non\-breakable\-inline\-mappings: yes}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- foobar: http://localhost/very/very/very/very/very/very/very/very/long/url .ft P .fi .UNINDENT .UNINDENT .IP 4. 3 With \fBline\-length: {max: 60, allow\-non\-breakable\-words: no}\fP .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C this: is: \- a: http://localhost/very/very/very/very/very/very/very/very/long/url .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS new\-line\-at\-end\-of\-file .sp Use this rule to require a new line character (\fB\en\fP) at the end of files. .sp The POSIX standard \fI\%requires the last line to end with a new line character\fP\&. All UNIX tools expect a new line at the end of files. Most text editors use this convention too. .SS new\-lines .sp Use this rule to force the type of new line characters. Options.INDENT 0.0 .IP \(bu 2 Set \fBtype\fP to \fBunix\fP to use UNIX\-typed new line characters (\fB\en\fP), or \fBdos\fP to use DOS\-typed new line characters (\fB\er\en\fP). .UNINDENT .SS trailing\-spaces .sp Use this rule to forbid trailing spaces at the end of lines. Examples.INDENT 0.0 .IP 1. 3 With \fBtrailing\-spaces: {}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C this document doesn\(aqt contain any trailing spaces .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C this document contains trailing spaces on lines 1 and 3 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS truthy .sp Use this rule to forbid truthy values that are not quoted nor explicitly typed. .sp This would prevent YAML parsers to tranform \fB[yes, FALSE, Off]\fP into \fB[true, false, false]\fP or \fB{y: 1, yes: 2, on: 3, true: 4, True: 5}\fP into \fB{y: 1, true: 5}\fP\&. Examples.INDENT 0.0 .IP 1. 3 With \fBtruthy: {}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C boolean: true object: {"True": 1, 1: "True"} "yes": 1 "on": 2 "true": 3 "True": 4 explicit: string1: !!str True string2: !!str yes string3: !!str off encoded: !!binary | True OFF pad== # this decodes as \(aqN»ž8Qii\(aq boolean1: !!bool true boolean2: !!bool "false" boolean3: !!bool FALSE boolean4: !!bool True boolean5: !!bool off boolean6: !!bool NO .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: {True: 1, 1: True} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C yes: 1 on: 2 true: 3 True: 4 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS Disable with comments .SS Disabling checks for a specific line .sp To prevent yamllint from reporting problems for a specific line, add a directive comment (\fB# yamllint disable\-line ...\fP) on that line, or on the line above. For instance: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # The following mapping contains the same key twice, # but I know what I\(aqm doing: key: value 1 key: value 2 # yamllint disable\-line rule:key\-duplicates \- This line is waaaaaaaaaay too long but yamllint will not report anything about it. # yamllint disable\-line rule:line\-length This line will be checked by yamllint. .ft P .fi .UNINDENT .UNINDENT .sp or: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # The following mapping contains the same key twice, # but I know what I\(aqm doing: key: value 1 # yamllint disable\-line rule:key\-duplicates key: value 2 # yamllint disable\-line rule:line\-length \- This line is waaaaaaaaaay too long but yamllint will not report anything about it. This line will be checked by yamllint. .ft P .fi .UNINDENT .UNINDENT .sp It it possible, although not recommend, to disabled \fBall\fP rules for a specific line: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # yamllint disable\-line \- { all : rules ,are disabled for this line} .ft P .fi .UNINDENT .UNINDENT .sp If you need to disable multiple rules, it is allowed to chain rules like this: \fB# yamllint disable\-line rule:hyphens rule:commas rule:indentation\fP\&. .SS Disabling checks for all (or part of) the file .sp To prevent yamllint from reporting problems for the whoe file, or for a block of lines within the file, use \fB# yamllint disable ...\fP and \fB# yamllint enable ...\fP directive comments. For instance: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # yamllint disable rule:colons \- Lorem : ipsum dolor : sit amet, consectetur : adipiscing elit # yamllint enable rule:colons \- rest of the document... .ft P .fi .UNINDENT .UNINDENT .sp It it possible, although not recommend, to disabled \fBall\fP rules: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # yamllint disable \- Lorem : ipsum: dolor : [ sit,amet] \- consectetur : adipiscing elit # yamllint enable .ft P .fi .UNINDENT .UNINDENT .sp If you need to disable multiple rules, it is allowed to chain rules like this: \fB# yamllint disable rule:hyphens rule:commas rule:indentation\fP\&. .SS Development .sp yamllint provides both a script and a Python module. The latter can be used to write your own linting tools: .INDENT 0.0 .TP .B class yamllint.linter.LintProblem(line, column, desc=\(aq\(aq, rule=None) Represents a linting problem found by yamllint. .INDENT 7.0 .TP .B column = None Column on which the problem was found (starting at 1) .UNINDENT .INDENT 7.0 .TP .B desc = None Human\-readable description of the problem .UNINDENT .INDENT 7.0 .TP .B line = None Line on which the problem was found (starting at 1) .UNINDENT .INDENT 7.0 .TP .B rule = None Identifier of the rule that detected the problem .UNINDENT .UNINDENT .INDENT 0.0 .TP .B yamllint.linter.run(input, conf) Lints a YAML source. .sp Returns a generator of LintProblem objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinput\fP \-\- buffer, string or stream to read from .IP \(bu 2 \fBconf\fP \-\- yamllint configuration object .UNINDENT .UNINDENT .UNINDENT .SS Integration with text editors .sp Most text editors support syntax checking and highlighting, to visually report syntax errors and warnings to the user. yamllint can be used to syntax\-check YAML source, but a bit of configuration is required depending on your favorite text editor. .SS Vim .sp Assuming that the \fI\%syntastic\fP plugin is installed, add to your \fB\&.vimrc\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C let g:syntastic_yaml_checkers = [\(aqyamllint\(aq] .ft P .fi .UNINDENT .UNINDENT .SS Neovim .sp Assuming that the \fI\%neomake\fP plugin is installed, yamllint is supported by default. It is automatically enabled when editing YAML files. .SS Other text editors Help wanted! .sp Your favorite text editor is not listed here? Help us improve by adding a section (by opening a pull\-request or issue on GitHub). .SH AUTHOR Adrien Vergé .SH COPYRIGHT Copyright 2016, Adrien Vergé .\" Generated by docutils manpage writer. .