.\" Man page generated from reStructuredText. . .TH "YAMLLINT" "1" "Apr 16, 2019" "1.15.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 8+ / 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 Mac OS 10.11+: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C brew 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 pip install \-\-user 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 pip install \-\-user 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 Or lint a YAML stream from standard input: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C echo \-e \(aqthis: is\envalid: YAML\(aq | 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 By default, the output of yamllint is colored when run from a terminal, and pure text in other cases. Add the \fB\-f standard\fP arguments to force non\-colored output. Use the \fB\-f colored\fP arguments to force colored output. .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: enable brackets: enable colons: enable commas: enable comments: level: warning comments\-indentation: level: warning document\-end: disable document\-start: level: warning empty\-lines: enable empty\-values: enable hyphens: enable indentation: enable key\-duplicates: enable key\-ordering: disable line\-length: enable new\-line\-at\-end\-of\-file: enable new\-lines: enable octal\-values: enable quoted\-strings: disable 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: true 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. The CLI will output them (with different colors when using the \fBcolored\fP output format, or \fBauto\fP when run from a terminal). .sp By default the script will exit with a return code \fB1\fP \fIonly when\fP there is one or more error(s). .sp However if strict mode is enabled with the \fB\-s\fP (or \fB\-\-strict\fP) option, the return code will be: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB0\fP if no errors or warnings occur .IP \(bu 2 \fB1\fP if one or more errors occur .IP \(bu 2 \fB2\fP if no errors occur, but one or more warnings occur .UNINDENT .UNINDENT .UNINDENT .SS Ignoring paths .sp It is possible to exclude specific files or directories, so that the linter doesn\(aqt process them. .sp You can either totally ignore files (they won\(aqt be looked at): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C extends: default ignore: | /this/specific/file.yaml all/this/directory/ *.template.yaml .ft P .fi .UNINDENT .UNINDENT .sp or ignore paths only for specific rules: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C extends: default rules: trailing\-spaces: ignore: | /this\-file\-has\-trailing\-spaces\-but\-it\-is\-OK.yaml /generated/*.yaml .ft P .fi .UNINDENT .UNINDENT .sp Note that this \fB\&.gitignore\fP\-style path pattern allows complex path exclusion/inclusion, see the \fI\%pathspec README file\fP for more details. Here is a more complex example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # For all rules ignore: | *.dont\-lint\-me.yaml /bin/ !/bin/*.lint\-me\-anyway.yaml extends: default rules: key\-duplicates: ignore: | generated *.template.yaml trailing\-spaces: ignore: | *.ignore\-trailing\-spaces.yaml ascii\-art/* .ft P .fi .UNINDENT .UNINDENT .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\%empty\-values\fP .IP \(bu 2 \fI\%hyphens\fP .IP \(bu 2 \fI\%indentation\fP .IP \(bu 2 \fI\%key\-duplicates\fP .IP \(bu 2 \fI\%key\-ordering\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\%octal\-values\fP .IP \(bu 2 \fI\%quoted\-strings\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. .IP \(bu 2 \fBmin\-spaces\-inside\-empty\fP defines the minimal number of spaces required inside empty braces. .IP \(bu 2 \fBmax\-spaces\-inside\-empty\fP defines the maximal number of spaces allowed inside empty 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 .IP 3. 3 With \fBbraces: {min\-spaces\-inside\-empty: 0, max\-spaces\-inside\-empty: 0}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: {} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: { } .ft P .fi .UNINDENT .UNINDENT .IP 4. 3 With \fBbraces: {min\-spaces\-inside\-empty: 1, max\-spaces\-inside\-empty: \-1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: { } .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: {} .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. .IP \(bu 2 \fBmin\-spaces\-inside\-empty\fP defines the minimal number of spaces required inside empty brackets. .IP \(bu 2 \fBmax\-spaces\-inside\-empty\fP defines the maximal number of spaces allowed inside empty 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 .IP 3. 3 With \fBbrackets: {min\-spaces\-inside\-empty: 0, max\-spaces\-inside\-empty: 0}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [ ] .ft P .fi .UNINDENT .UNINDENT .IP 4. 3 With \fBbrackets: {min\-spaces\-inside\-empty: 1, max\-spaces\-inside\-empty: \-1}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [ ] .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C object: [] .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 \fBtrue\fP to enable, \fBfalse\fP to disable. .IP \(bu 2 Use \fBignore\-shebangs\fP to ignore a \fI\%shebang\fP at the beginning of the file when \fBrequire\-starting\-space\fP is set. .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: true}\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 \fBtrue\fP when the document end marker is required, or to \fBfalse\fP when it is forbidden. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBdocument\-end: {present: true}\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: false}\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 \fBtrue\fP when the document start marker is required, or to \fBfalse\fP when it is forbidden. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBdocument\-start: {present: true}\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: false}\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 empty\-values .sp Use this rule to prevent nodes with empty content, that implicitly result in \fBnull\fP values. Options.INDENT 0.0 .IP \(bu 2 Use \fBforbid\-in\-block\-mappings\fP to prevent empty values in block mappings. .IP \(bu 2 Use \fBforbid\-in\-flow\-mappings\fP to prevent empty values in flow mappings. .UNINDENT Examples.INDENT 0.0 .IP 1. 3 With \fBempty\-values: {forbid\-in\-block\-mappings: true}\fP .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C some\-mapping: sub\-element: correctly indented .ft P .fi .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C explicitly\-null: null .ft P .fi .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C some\-mapping: sub\-element: incorrectly indented .ft P .fi .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C implicitly\-null: .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBempty\-values: {forbid\-in\-flow\-mappings: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C {prop: null} {a: 1, b: 2, c: 3} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C {prop: } .ft P .fi .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C {a: 1, b:, c: 3} .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: \fBtrue\fP, \fBfalse\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 \fBtrue\fP to enable, \fBfalse\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: false}\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: true}\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 key\-ordering .sp Use this rule to enforce alphabetical ordering of keys in mappings. The sorting order uses the Unicode code point number. As a result, the ordering is case\-sensitive and not accent\-friendly (see examples below). Examples.INDENT 0.0 .IP 1. 3 With \fBkey\-ordering: {}\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} \- T\-shirt: 1 T\-shirts: 2 t\-shirt: 3 t\-shirts: 4 \- hair: true hais: true haïr: true haïssable: true .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- key 2: v key 1: val .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- {b: 1, a: 2} .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- T\-shirt: 1 t\-shirt: 2 T\-shirts: 3 t\-shirts: 4 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C \- haïr: true hais: true .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS line\-length .sp Use this rule to set a limit to lines length. .sp Note: with Python 2, the \fBline\-length\fP rule may not work properly with unicode characters because of the way strings are represented in bytes. We recommend running yamllint with Python 3. 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 \fBtrue\fP to allow, \fBfalse\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: true}\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: true, allow\-non\-breakable\-inline\-mappings: true}\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: false}\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 octal\-values .sp Use this rule to prevent values with octal numbers. In YAML, numbers that start with \fB0\fP are interpreted as octal, but this is not always wanted. For instance \fB010\fP is the city code of Beijing, and should not be converted to \fB8\fP\&. Examples.INDENT 0.0 .IP 1. 3 With \fBoctal\-values: {forbid\-implicit\-octal: true}\fP .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C user: city\-code: \(aq010\(aq .ft P .fi .UNINDENT .UNINDENT .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C user: city\-code: 010,021 .ft P .fi .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C user: city\-code: 010 .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 With \fBoctal\-values: {forbid\-explicit\-octal: true}\fP .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C user: city\-code: \(aq0o10\(aq .ft P .fi .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C user: city\-code: 0o10 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS quoted\-strings .sp Use this rule to forbid any string values that are not quoted. You can also enforce the type of the quote used using the \fBquote\-type\fP option (\fBsingle\fP, \fBdouble\fP or \fBany\fP). .sp \fBNote\fP: Multi\-line strings (with \fB|\fP or \fB>\fP) will not be checked. Examples.INDENT 0.0 .IP 1. 3 With \fBquoted\-strings: {quote\-type: any}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C foo: "bar" bar: \(aqfoo\(aq number: 123 boolean: true .ft P .fi .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C foo: bar .ft P .fi .UNINDENT .UNINDENT .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 non\-explictly typed truthy values other than \fBtrue\fP and \fBfalse\fP, for example \fBYES\fP, \fBFalse\fP and \fBoff\fP\&. .sp This can be useful to prevent surprises from YAML parsers transforming \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 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 .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 is 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 whole 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 is 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, filepath=None) 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\%ALE\fP plugin is installed, yamllint is supported by default. It is automatically enabled when editing YAML files. .sp If you instead use the \fI\%syntastic\fP plugin, add this 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 Emacs .sp If you are \fI\%flycheck\fP user, you can use \fI\%flycheck\-yamllint\fP integration. .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). .SS Integration with other software .SS Integration with pre\-commit .sp You can integrate yamllint in \fI\%pre\-commit\fP tool. Here is an example, to add in your .pre\-commit\-config.yaml .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-\-\- # Update the sha variable with the release version that you want, from the yamllint repo \- repo: https://github.com/adrienverge/yamllint.git sha: v1.8.1 hooks: \- id: yamllint .ft P .fi .UNINDENT .UNINDENT .SH AUTHOR Adrien Vergé .SH COPYRIGHT Copyright 2016, Adrien Vergé .\" Generated by docutils manpage writer. .