.\" Man page generated from reStructuredText. . . .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 .. .TH "YAMLLINT" "1" "Dec 30, 2023" "1.33.0" "yamllint" .SH NAME yamllint \- Linter for YAML files .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 Running yamllint .sp Basic usage: .INDENT 0.0 .INDENT 3.5 .sp .EX yamllint file.yml other\-file.yaml .EE .UNINDENT .UNINDENT .sp You can also lint all YAML files in a whole directory: .INDENT 0.0 .INDENT 3.5 .sp .EX yamllint . .EE .UNINDENT .UNINDENT .sp Or lint a YAML stream from standard input: .INDENT 0.0 .INDENT 3.5 .sp .EX echo \-e \(aqthis: is\envalid: YAML\(aq | yamllint \- .EE .UNINDENT .UNINDENT .sp The output will look like (colors are not displayed here): .INDENT 0.0 .INDENT 3.5 .sp .EX 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 \(dqid\-00042\(dq 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 \(dq\-\-\-\(dq (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) .EE .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 \fI\%syntax highlighting in text editors\fP). The output will then look like: .INDENT 0.0 .INDENT 3.5 .sp .EX 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) .EE .UNINDENT .UNINDENT .sp If you have a custom linting configuration file (see \fI\%how to configure yamllint\fP), it can be passed to yamllint using the \fB\-c\fP option: .INDENT 0.0 .INDENT 3.5 .sp .EX yamllint \-c ~/myconfig file.yaml .EE .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 \fI\%rules\fP 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 .EX yamllint \-c /path/to/myconfig file\-to\-lint.yaml .EE .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 a file named \fB\&.yamllint\fP, \fB\&.yamllint.yaml\fP, or \fB\&.yamllint.yml\fP in the current working directory, or a parent directory (the search for this file is terminated at the user\(aqs home or filesystem root) .IP \(bu 2 a filename referenced by \fB$YAMLLINT_CONFIG_FILE\fP, if set .IP \(bu 2 a file named \fB$XDG_CONFIG_HOME/yamllint/config\fP or \fB~/.config/yamllint/config\fP, if present .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 .EX \-\-\- yaml\-files: \- \(aq*.yaml\(aq \- \(aq*.yml\(aq \- \(aq.yamllint\(aq rules: anchors: enable 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: disable float\-values: disable 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: disable quoted\-strings: disable trailing\-spaces: enable truthy: level: warning .EE .UNINDENT .UNINDENT .sp Details on rules can be found on \fI\%the rules page\fP\&. .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 .EX \-\-\- 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 .EE .UNINDENT .UNINDENT .sp It can be chosen using: .INDENT 0.0 .INDENT 3.5 .sp .EX yamllint \-d relaxed file.yml .EE .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 .EX # 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 .EE .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 .EX 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 .EE .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 .EX yamllint \-d \(dq{extends: relaxed, rules: {line\-length: {max: 120}}}\(dq file.yaml .EE .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 .sp If the script is invoked with the \fB\-\-no\-warnings\fP option, it won\(aqt output warning level problems, only error level ones. .SS YAML files extensions .sp To configure what yamllint should consider as YAML files when listing directories, set \fByaml\-files\fP configuration option. The default is: .INDENT 0.0 .INDENT 3.5 .sp .EX yaml\-files: \- \(aq*.yaml\(aq \- \(aq*.yml\(aq \- \(aq.yamllint\(aq .EE .UNINDENT .UNINDENT .sp The same rules as for ignoring paths apply (\fB\&.gitignore\fP\-style path pattern, see below). .sp If you need to know the exact list of files that yamllint would process, without really linting them, you can use \fB\-\-list\-files\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX yamllint \-\-list\-files . .EE .UNINDENT .UNINDENT .SS Ignoring paths .sp It is possible to exclude specific files or directories, so that the linter doesn\(aqt process them. They can be provided either as a list of paths, or as a bulk string. .sp You can either totally ignore files (they won\(aqt be looked at): .INDENT 0.0 .INDENT 3.5 .sp .EX extends: default ignore: | /this/specific/file.yaml all/this/directory/ *.template.yaml # or: ignore: \- /this/specific/file.yaml \- all/this/directory/ \- \(aq*.template.yaml\(aq .EE .UNINDENT .UNINDENT .sp or ignore paths only for specific rules: .INDENT 0.0 .INDENT 3.5 .sp .EX extends: default rules: trailing\-spaces: ignore: | /this\-file\-has\-trailing\-spaces\-but\-it\-is\-OK.yaml /generated/*.yaml # or: rules: trailing\-spaces: ignore: \- /this\-file\-has\-trailing\-spaces\-but\-it\-is\-OK.yaml \- /generated/*.yaml .EE .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 .EX # 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/* .EE .UNINDENT .UNINDENT .sp You can also use the \fB\&.gitignore\fP file (or any list of files) through: .INDENT 0.0 .INDENT 3.5 .sp .EX ignore\-from\-file: .gitignore .EE .UNINDENT .UNINDENT .sp or: .INDENT 0.0 .INDENT 3.5 .sp .EX ignore\-from\-file: [.gitignore, .yamlignore] .EE .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 However, this is mutually exclusive with the \fBignore\fP key. .UNINDENT .UNINDENT .sp If you need to know the exact list of files that yamllint would process, without really linting them, you can use \fB\-\-list\-files\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX yamllint \-\-list\-files . .EE .UNINDENT .UNINDENT .SS Setting the locale .sp It is possible to set the \fBlocale\fP option globally. This is passed to Python\(aqs \fI\%locale.setlocale\fP, so an empty string \fB\(dq\(dq\fP will use the system default locale, while e.g. \fB\(dqen_US.UTF\-8\(dq\fP will use that. .sp Currently this only affects the \fBkey\-ordering\fP rule. The default will order by Unicode code point number, while locales will sort case and accents properly as well. .INDENT 0.0 .INDENT 3.5 .sp .EX extends: default locale: en_US.UTF\-8 .EE .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 \fI\%configuration file\fP 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\%anchors\fP .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\%float\-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 anchors .sp Use this rule to report duplicated anchors and aliases referencing undeclared anchors. .sp Options .INDENT 0.0 .IP \(bu 2 Set \fBforbid\-undeclared\-aliases\fP to \fBtrue\fP to avoid aliases that reference an anchor that hasn\(aqt been declared (either not declared at all, or declared later in the document). .IP \(bu 2 Set \fBforbid\-duplicated\-anchors\fP to \fBtrue\fP to avoid duplications of a same anchor. .IP \(bu 2 Set \fBforbid\-unused\-anchors\fP to \fBtrue\fP to avoid anchors being declared but not used anywhere in the YAML document via alias. .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: anchors: forbid\-undeclared\-aliases: true forbid\-duplicated\-anchors: false forbid\-unused\-anchors: false .EE .UNINDENT .UNINDENT .sp Examples .INDENT 0.0 .IP 1. 3 With \fBanchors: {forbid\-undeclared\-aliases: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor foo: bar \- *anchor .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor foo: bar \- *unknown .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor foo: bar \- <<: *unknown extra: value .EE .UNINDENT .UNINDENT .IP 2. 3 With \fBanchors: {forbid\-duplicated\-anchors: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor1 Foo Bar \- &anchor2 [item 1, item 2] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor Foo Bar \- &anchor [item 1, item 2] .EE .UNINDENT .UNINDENT .IP 3. 3 With \fBanchors: {forbid\-unused\-anchors: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor foo: bar \- *anchor .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- \- &anchor foo: bar \- items: \- item1 \- item2 .EE .UNINDENT .UNINDENT .UNINDENT .SS braces .sp Use this rule to control the use of flow mappings or number of spaces inside braces (\fB{\fP and \fB}\fP). .sp Options .INDENT 0.0 .IP \(bu 2 \fBforbid\fP is used to forbid the use of flow mappings which are denoted by surrounding braces (\fB{\fP and \fB}\fP). Use \fBtrue\fP to forbid the use of flow mappings completely. Use \fBnon\-empty\fP to forbid the use of all flow mappings except for empty ones. .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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: braces: forbid: false min\-spaces\-inside: 0 max\-spaces\-inside: 0 min\-spaces\-inside\-empty: \-1 max\-spaces\-inside\-empty: \-1 .EE .UNINDENT .UNINDENT .sp Examples .INDENT 0.0 .IP 1. 3 With \fBbraces: {forbid: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: key1: 4 key2: 8 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: { key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .IP 2. 3 With \fBbraces: {forbid: non\-empty}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: {} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: { key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .IP 3. 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 .EX object: {key1: 4, key2: 8} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: { key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .IP 4. 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 .EX object: { key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: { key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: { key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: {key1: 4, key2: 8 } .EE .UNINDENT .UNINDENT .IP 5. 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 .EX object: {} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: { } .EE .UNINDENT .UNINDENT .IP 6. 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 .EX object: { } .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: {} .EE .UNINDENT .UNINDENT .UNINDENT .SS brackets .sp Use this rule to control the use of flow sequences or the number of spaces inside brackets (\fB[\fP and \fB]\fP). .sp Options .INDENT 0.0 .IP \(bu 2 \fBforbid\fP is used to forbid the use of flow sequences which are denoted by surrounding brackets (\fB[\fP and \fB]\fP). Use \fBtrue\fP to forbid the use of flow sequences completely. Use \fBnon\-empty\fP to forbid the use of all flow sequences except for empty ones. .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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: brackets: forbid: false min\-spaces\-inside: 0 max\-spaces\-inside: 0 min\-spaces\-inside\-empty: \-1 max\-spaces\-inside\-empty: \-1 .EE .UNINDENT .UNINDENT .sp Examples .INDENT 0.0 .IP 1. 3 With \fBbrackets: {forbid: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: \- 1 \- 2 \- abc .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [ 1, 2, abc ] .EE .UNINDENT .UNINDENT .IP 2. 3 With \fBbrackets: {forbid: non\-empty}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [ 1, 2, abc ] .EE .UNINDENT .UNINDENT .IP 3. 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 .EX object: [1, 2, abc] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [ 1, 2, abc ] .EE .UNINDENT .UNINDENT .IP 4. 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 .EX object: [ 1, 2, abc ] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [ 1, 2, abc ] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [ 1, 2, abc ] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [1, 2, abc ] .EE .UNINDENT .UNINDENT .IP 5. 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 .EX object: [] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [ ] .EE .UNINDENT .UNINDENT .IP 6. 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 .EX object: [ ] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: [] .EE .UNINDENT .UNINDENT .UNINDENT .SS colons .sp Use this rule to control the number of spaces before and after colons (\fB:\fP). .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: colons: max\-spaces\-before: 0 max\-spaces\-after: 1 .EE .UNINDENT .UNINDENT .sp 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 .EX object: \- a \- b key: value .EE .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 .EX object : \- a \- b .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object : \- a \- b .EE .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 .EX first: 1 second: 2 third: 3 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX first: 1 2nd: 2 third: 3 .EE .UNINDENT .UNINDENT .UNINDENT .SS commas .sp Use this rule to control the number of spaces before and after commas (\fB,\fP). .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: commas: max\-spaces\-before: 0 min\-spaces\-after: 1 max\-spaces\-after: 1 .EE .UNINDENT .UNINDENT .sp 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 .EX strange var: [10, 20, 30, {x: 1, y: 2}] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX strange var: [10, 20 , 30, {x: 1, y: 2}] .EE .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 .EX strange var: [10 , 20 , 30, {x: 1 , y: 2}] .EE .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 .EX strange var: [10, 20 , 30 , {x: 1, y: 2}] .EE .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 .EX strange var: [10, 20, 30, {x: 1, y: 2}] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX strange var: [10, 20,30, {x: 1, y: 2}] .EE .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 .EX strange var: [10, 20, 30, {x: 1, y: 2}] .EE .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 .EX strange var: [10, 20,30, {x: 1, y: 2}] .EE .UNINDENT .UNINDENT .UNINDENT .SS comments .sp Use this rule to control the position and formatting of comments. .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: comments: require\-starting\-space: true ignore\-shebangs: true min\-spaces\-from\-content: 2 .EE .UNINDENT .UNINDENT .sp 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 .EX # This sentence # is a block comment .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX ############################## ## This is some documentation .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX #This sentence #is a block comment .EE .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 .EX x = 2 ^ 127 \- 1 # Mersenne prime number .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX x = 2 ^ 127 \- 1 # Mersenne prime number .EE .UNINDENT .UNINDENT .UNINDENT .SS comments\-indentation .sp Use this rule to force comments to be indented like content. .sp 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 .EX # Fibonacci [0, 1, 1, 2, 3, 5] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX # Fibonacci [0, 1, 1, 2, 3, 5] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX list: \- 2 \- 3 # \- 4 \- 5 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX list: \- 2 \- 3 # \- 4 \- 5 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX # This is the first object obj1: \- item A # \- item B # This is the second object obj2: [] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX # This sentence # is a block comment .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX # This sentence # is a block comment .EE .UNINDENT .UNINDENT .UNINDENT .SS document\-end .sp Use this rule to require or forbid the use of document end marker (\fB\&...\fP). .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: document\-end: present: true .EE .UNINDENT .UNINDENT .sp 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 .EX \-\-\- this: is: [a, document] \&... \-\-\- \- this \- is: another one \&... .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- this: is: [a, document] \-\-\- \- this \- is: another one \&... .EE .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 .EX \-\-\- this: is: [a, document] \-\-\- \- this \- is: another one .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- this: is: [a, document] \&... \-\-\- \- this \- is: another one .EE .UNINDENT .UNINDENT .UNINDENT .SS document\-start .sp Use this rule to require or forbid the use of document start marker (\fB\-\-\-\fP). .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: document\-start: present: true .EE .UNINDENT .UNINDENT .sp 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 .EX \-\-\- this: is: [a, document] \-\-\- \- this \- is: another one .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX this: is: [a, document] \-\-\- \- this \- is: another one .EE .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 .EX this: is: [a, document] \&... .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \-\-\- this: is: [a, document] \&... .EE .UNINDENT .UNINDENT .UNINDENT .SS empty\-lines .sp Use this rule to set a maximal number of allowed consecutive blank lines. .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: empty\-lines: max: 2 max\-start: 0 max\-end: 0 .EE .UNINDENT .UNINDENT .sp 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 .EX \- foo: \- 1 \- 2 \- bar: [3, 4] .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- foo: \- 1 \- 2 \- bar: [3, 4] .EE .UNINDENT .UNINDENT .UNINDENT .SS empty\-values .sp Use this rule to prevent nodes with empty content, that implicitly result in \fBnull\fP values. .sp 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. .IP \(bu 2 Use \fBforbid\-in\-block\-sequences\fP to prevent empty values in block sequences. .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: empty\-values: forbid\-in\-block\-mappings: true forbid\-in\-flow\-mappings: true forbid\-in\-block\-sequences: true .EE .UNINDENT .UNINDENT .sp 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 .EX some\-mapping: sub\-element: correctly indented .EE .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .EX explicitly\-null: null .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX some\-mapping: sub\-element: incorrectly indented .EE .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .EX implicitly\-null: .EE .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 .EX {prop: null} {a: 1, b: 2, c: 3} .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX {prop: } .EE .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .EX {a: 1, b:, c: 3} .EE .UNINDENT .UNINDENT .IP 3. 3 With \fBempty\-values: {forbid\-in\-block\-sequences: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX some\-sequence: \- string item .EE .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .EX some\-sequence: \- null .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX some\-sequence: \- .EE .UNINDENT .UNINDENT .INDENT 3.0 .INDENT 3.5 .sp .EX some\-sequence: \- string item \- .EE .UNINDENT .UNINDENT .UNINDENT .SS float\-values .sp Use this rule to limit the permitted values for floating\-point numbers. YAML permits three classes of float expressions: approximation to real numbers, positive and negative infinity and \(dqnot a number\(dq. .sp Options .INDENT 0.0 .IP \(bu 2 Use \fBrequire\-numeral\-before\-decimal\fP to require floats to start with a numeral (ex \fB0.0\fP instead of \fB\&.0\fP). .IP \(bu 2 Use \fBforbid\-scientific\-notation\fP to forbid scientific notation. .IP \(bu 2 Use \fBforbid\-nan\fP to forbid NaN (not a number) values. .IP \(bu 2 Use \fBforbid\-inf\fP to forbid infinite values. .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: float\-values: forbid\-inf: false forbid\-nan: false forbid\-scientific\-notation: false require\-numeral\-before\-decimal: false .EE .UNINDENT .UNINDENT .sp Examples .INDENT 0.0 .IP 1. 3 With \fBfloat\-values: {require\-numeral\-before\-decimal: true}\fP .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX anemometer: angle: 0.0 .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX anemometer: angle: .0 .EE .UNINDENT .UNINDENT .IP 2. 3 With \fBfloat\-values: {forbid\-scientific\-notation: true}\fP .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX anemometer: angle: 0.00001 .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX anemometer: angle: 10e\-6 .EE .UNINDENT .UNINDENT .IP 3. 3 With \fBfloat\-values: {forbid\-nan: true}\fP .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX anemometer: angle: .NaN .EE .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP 1. 3 With \fBfloat\-values: {forbid\-inf: true}\fP .UNINDENT .INDENT 0.0 .INDENT 3.5 the following code snippets would \fBFAIL\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX anemometer: angle: .inf .EE .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS hyphens .sp Use this rule to control the number of spaces after hyphens (\fB\-\fP). .sp Options .INDENT 0.0 .IP \(bu 2 \fBmax\-spaces\-after\fP defines the maximal number of spaces allowed after hyphens. .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: hyphens: max\-spaces\-after: 1 .EE .UNINDENT .UNINDENT .sp 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 .EX \- first list: \- a \- b \- \- 1 \- 2 \- 3 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- first list: \- a \- b .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- \- 1 \- 2 \- 3 .EE .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 .EX \- key \- key2 \- key42 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- key \- key2 \- key42 .EE .UNINDENT .UNINDENT .UNINDENT .SS indentation .sp Use this rule to control the indentation. .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: indentation: spaces: consistent indent\-sequences: true check\-multi\-line\-strings: false .EE .UNINDENT .UNINDENT .sp 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 .EX history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .EE .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 .EX history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .EE .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 .EX history: \- name: Unix date: 1969 \- name: Linux date: 1991 nest: recurse: \- haystack: needle .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX some: Russian: dolls .EE .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 .EX list: \- flying \- spaghetti \- monster .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX list: \- flying \- spaghetti \- monster .EE .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 .EX list: \- flying: \- spaghetti \- monster \- not flying: \- spaghetti \- sauce .EE .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 .EX \- flying: \- spaghetti \- monster \- not flying: \- spaghetti \- sauce .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- flying: \- spaghetti \- monster \- not flying: \- spaghetti \- sauce .EE .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 .EX Blaise Pascal: Je vous écris une longue lettre parce que je n\(aqai pas le temps d\(aqen écrire une courte. .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX Blaise Pascal: Je vous écris une longue lettre parce que je n\(aqai pas le temps d\(aqen écrire une courte. .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX Blaise Pascal: Je vous écris une longue lettre parce que je n\(aqai pas le temps d\(aqen écrire une courte. .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX C code: void main() { printf(\(dqfoo\(dq); } .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX C code: void main() { printf(\(dqbar\(dq); } .EE .UNINDENT .UNINDENT .UNINDENT .SS key\-duplicates .sp Use this rule to prevent multiple entries with the same key in mappings. .sp 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 .EX \- key 1: v key 2: val key 3: value \- {a: 1, b: 2, c: 3} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- key 1: v key 2: val key 1: value .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- {a: 1, b: 2, b: 3} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX duplicated key: 1 \(dqduplicated key\(dq: 2 other duplication: 1 ? >\- other duplication : 2 .EE .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 default. As a result, the ordering is case\-sensitive and not accent\-friendly (see examples below). This can be changed by setting the global \fBlocale\fP option. This allows one to sort case and accents properly. .sp 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 .EX \- 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 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- key 2: v key 1: val .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- {b: 1, a: 2} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- T\-shirt: 1 t\-shirt: 2 T\-shirts: 3 t\-shirts: 4 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- haïr: true hais: true .EE .UNINDENT .UNINDENT .IP 2. 3 With global option \fBlocale: \(dqen_US.UTF\-8\(dq\fP and rule \fBkey\-ordering: {}\fP .sp as opposed to before, the following code snippet would now \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- t\-shirt: 1 T\-shirt: 2 t\-shirts: 3 T\-shirts: 4 \- hair: true haïr: true hais: true haïssable: true .EE .UNINDENT .UNINDENT .UNINDENT .SS line\-length .sp Use this rule to set a limit to lines length. .sp 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 .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: line\-length: max: 80 allow\-non\-breakable\-words: true allow\-non\-breakable\-inline\-mappings: false .EE .UNINDENT .UNINDENT .sp 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 .EX long sentence: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX long sentence: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. .EE .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 .EX 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 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- this line is waaaaaaaaaaaaaay too long but could be easily split... .EE .UNINDENT .UNINDENT .sp and the following code snippet would also \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- foobar: http://localhost/very/very/very/very/very/very/very/very/long/url .EE .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 .EX \- foobar: http://localhost/very/very/very/very/very/very/very/very/long/url .EE .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 .EX this: is: \- a: http://localhost/very/very/very/very/very/very/very/very/long/url .EE .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. .sp Options .INDENT 0.0 .IP \(bu 2 Set \fBtype\fP to \fBunix\fP to enforce UNIX\-typed new line characters (\fB\en\fP), set \fBtype\fP to \fBdos\fP to enforce DOS\-typed new line characters (\fB\er\en\fP), or set \fBtype\fP to \fBplatform\fP to infer the type from the system running yamllint (\fB\en\fP on POSIX / UNIX / Linux / Mac OS systems or \fB\er\en\fP on DOS / Windows systems). .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: new\-lines: type: unix .EE .UNINDENT .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\&. .sp Options .INDENT 0.0 .IP \(bu 2 Use \fBforbid\-implicit\-octal\fP to prevent numbers starting with \fB0\fP\&. .IP \(bu 2 Use \fBforbid\-explicit\-octal\fP to prevent numbers starting with \fB0o\fP\&. .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: octal\-values: forbid\-implicit\-octal: true forbid\-explicit\-octal: true .EE .UNINDENT .UNINDENT .sp 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 .EX user: city\-code: \(aq010\(aq .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX user: city\-code: 010,021 .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX user: city\-code: 010 .EE .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 .EX user: city\-code: \(aq0o10\(aq .EE .UNINDENT .UNINDENT .sp the following code snippets would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX user: city\-code: 0o10 .EE .UNINDENT .UNINDENT .UNINDENT .SS quoted\-strings .sp Use this rule to forbid any string values that are not quoted, or to prevent quoted strings without needing it. You can also enforce the type of the quote used. .sp Options .INDENT 0.0 .IP \(bu 2 \fBquote\-type\fP defines allowed quotes: \fBsingle\fP, \fBdouble\fP or \fBany\fP (default). .IP \(bu 2 \fBrequired\fP defines whether using quotes in string values is required (\fBtrue\fP, default) or not (\fBfalse\fP), or only allowed when really needed (\fBonly\-when\-needed\fP). .IP \(bu 2 \fBextra\-required\fP is a list of PCRE regexes to force string values to be quoted, if they match any regex. This option can only be used with \fBrequired: false\fP and \fBrequired: only\-when\-needed\fP\&. .IP \(bu 2 \fBextra\-allowed\fP is a list of PCRE regexes to allow quoted string values, even if \fBrequired: only\-when\-needed\fP is set. .IP \(bu 2 \fBallow\-quoted\-quotes\fP allows (\fBtrue\fP) using disallowed quotes for strings with allowed quotes inside. Default \fBfalse\fP\&. .UNINDENT .sp \fBNote\fP: Multi\-line strings (with \fB|\fP or \fB>\fP) will not be checked. .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: quoted\-strings: quote\-type: any required: true extra\-required: [] extra\-allowed: [] allow\-quoted\-quotes: false .EE .UNINDENT .UNINDENT .sp Examples .INDENT 0.0 .IP 1. 3 With \fBquoted\-strings: {quote\-type: any, required: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: \(dqbar\(dq bar: \(aqfoo\(aq number: 123 boolean: true .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: bar .EE .UNINDENT .UNINDENT .IP 2. 3 With \fBquoted\-strings: {quote\-type: single, required: only\-when\-needed}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: bar bar: foo not_number: \(aq123\(aq not_boolean: \(aqtrue\(aq not_comment: \(aq# comment\(aq not_list: \(aq[1, 2, 3]\(aq not_map: \(aq{a: 1, b: 2}\(aq .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: \(aqbar\(aq .EE .UNINDENT .UNINDENT .IP 3. 3 With \fBquoted\-strings: {required: false, extra\-required: [^http://, ^ftp://]}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- localhost \- \(dqlocalhost\(dq \- \(dqhttp://localhost\(dq \- \(dqftp://localhost\(dq .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- http://localhost \- ftp://localhost .EE .UNINDENT .UNINDENT .IP 4. 3 With \fBquoted\-strings: {required: only\-when\-needed, extra\-allowed: [^http://, ^ftp://], extra\-required: [QUOTED]}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- localhost \- \(dqhttp://localhost\(dq \- \(dqftp://localhost\(dq \- \(dqthis is a string that needs to be QUOTED\(dq .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- \(dqlocalhost\(dq \- this is a string that needs to be QUOTED .EE .UNINDENT .UNINDENT .IP 5. 3 With \fBquoted\-strings: {quote\-type: double, allow\-quoted\-quotes: false}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: \(dqbar\e\(dqbaz\(dq .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: \(aqbar\(dqbaz\(aq .EE .UNINDENT .UNINDENT .IP 6. 3 With \fBquoted\-strings: {quote\-type: double, allow\-quoted\-quotes: true}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX foo: \(aqbar\(dqbaz\(aq .EE .UNINDENT .UNINDENT .UNINDENT .SS trailing\-spaces .sp Use this rule to forbid trailing spaces at the end of lines. .sp 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 .EX this document doesn\(aqt contain any trailing spaces .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX this document contains trailing spaces on lines 1 and 3 .EE .UNINDENT .UNINDENT .UNINDENT .SS truthy .sp Use this rule to forbid non\-explicitly typed truthy values other than allowed ones (by default: \fBtrue\fP and \fBfalse\fP), for example \fBYES\fP or \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\&. .sp Options .INDENT 0.0 .IP \(bu 2 \fBallowed\-values\fP defines the list of truthy values which will be ignored during linting. The default is \fB[\(aqtrue\(aq, \(aqfalse\(aq]\fP, but can be changed to any list containing: \fB\(aqTRUE\(aq\fP, \fB\(aqTrue\(aq\fP, \fB\(aqtrue\(aq\fP, \fB\(aqFALSE\(aq\fP, \fB\(aqFalse\(aq\fP, \fB\(aqfalse\(aq\fP, \fB\(aqYES\(aq\fP, \fB\(aqYes\(aq\fP, \fB\(aqyes\(aq\fP, \fB\(aqNO\(aq\fP, \fB\(aqNo\(aq\fP, \fB\(aqno\(aq\fP, \fB\(aqON\(aq\fP, \fB\(aqOn\(aq\fP, \fB\(aqon\(aq\fP, \fB\(aqOFF\(aq\fP, \fB\(aqOff\(aq\fP, \fB\(aqoff\(aq\fP\&. .IP \(bu 2 \fBcheck\-keys\fP disables verification for keys in mappings. By default, \fBtruthy\fP rule applies to both keys and values. Set this option to \fBfalse\fP to prevent this. .UNINDENT .sp Default values (when enabled) .INDENT 0.0 .INDENT 3.5 .sp .EX rules: truthy: allowed\-values: [\(aqtrue\(aq, \(aqfalse\(aq] check\-keys: true .EE .UNINDENT .UNINDENT .sp 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 .EX boolean: true object: {\(dqTrue\(dq: 1, 1: \(dqTrue\(dq} \(dqyes\(dq: 1 \(dqon\(dq: 2 \(dqTrue\(dq: 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 \(dqfalse\(dq boolean3: !!bool FALSE boolean4: !!bool True boolean5: !!bool off boolean6: !!bool NO .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX object: {True: 1, 1: True} .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX yes: 1 on: 2 True: 3 .EE .UNINDENT .UNINDENT .IP 2. 3 With \fBtruthy: {allowed\-values: [\(dqyes\(dq, \(dqno\(dq]}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- yes \- no \- \(dqtrue\(dq \- \(aqfalse\(aq \- foo \- bar .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX \- true \- false \- on \- off .EE .UNINDENT .UNINDENT .IP 3. 3 With \fBtruthy: {check\-keys: false}\fP .sp the following code snippet would \fBPASS\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX yes: 1 on: 2 true: 3 .EE .UNINDENT .UNINDENT .sp the following code snippet would \fBFAIL\fP: .INDENT 3.0 .INDENT 3.5 .sp .EX yes: Yes on: On true: True .EE .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 .EX # 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. .EE .UNINDENT .UNINDENT .sp or: .INDENT 0.0 .INDENT 3.5 .sp .EX # 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. .EE .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 .EX # yamllint disable\-line \- { all : rules ,are disabled for this line} .EE .UNINDENT .UNINDENT .sp You can\(aqt make yamllint ignore invalid YAML syntax on a line (which generates a \fIsyntax error\fP), such as when templating a YAML file with Jinja. In some cases, you can workaround this by putting the templating syntax in a YAML comment. See \fI\%Putting template flow control in comments\fP\&. .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 .EX # yamllint disable rule:colons \- Lorem : ipsum dolor : sit amet, consectetur : adipiscing elit # yamllint enable rule:colons \- rest of the document... .EE .UNINDENT .UNINDENT .sp It is possible, although not recommend, to disabled \fBall\fP rules: .INDENT 0.0 .INDENT 3.5 .sp .EX # yamllint disable \- Lorem : ipsum: dolor : [ sit,amet] \- consectetur : adipiscing elit # yamllint enable .EE .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 Disabling all checks for a file .sp To prevent yamllint from reporting problems for a specific file, add the directive comment \fB# yamllint disable\-file\fP as the first line of the file. For instance: .INDENT 0.0 .INDENT 3.5 .sp .EX # yamllint disable\-file # The following mapping contains the same key twice, but I know what I\(aqm doing: key: value 1 key: value 2 \- This line is waaaaaaaaaay too long but yamllint will not report anything about it. .EE .UNINDENT .UNINDENT .sp or: .INDENT 0.0 .INDENT 3.5 .sp .EX # yamllint disable\-file # This file is not valid YAML because it is a Jinja template {% if extra_info %} key1: value1 {% endif %} key2: value2 .EE .UNINDENT .UNINDENT .SS Putting template flow control in comments .sp Alternatively for templating you can wrap the template statements in comments to make it a valid YAML file. As long as the templating language doesn\(aqt use the same comment symbol, it should be a valid template and valid YAML (pre and post\-template processing). .sp Example of a Jinja2 code that cannot be parsed as YAML because it contains invalid tokens \fB{%\fP and \fB%}\fP: .INDENT 0.0 .INDENT 3.5 .sp .EX # This file IS NOT valid YAML and will produce syntax errors {% if extra_info %} key1: value1 {% endif %} key2: value2 .EE .UNINDENT .UNINDENT .sp But it can be fixed using YAML comments: .INDENT 0.0 .INDENT 3.5 .sp .EX # This file IS valid YAML because the Jinja is in a YAML comment # {% if extra_info %} key1: value1 # {% endif %} key2: value2 .EE .UNINDENT .UNINDENT .SS Development .sp yamllint provides both a script and a Python module. The latter can be used to write your own linting tools. .sp Basic example of running the linter from Python: .INDENT 0.0 .INDENT 3.5 .sp .EX import yamllint yaml_config = yamllint.config.YamlLintConfig(\(dqextends: default\(dq) for p in yamllint.linter.run(open(\(dqexample.yaml\(dq, \(dqr\(dq), yaml_config): print(p.desc, p.line, p.rule) .EE .UNINDENT .UNINDENT .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 Column on which the problem was found (starting at 1) .UNINDENT .INDENT 7.0 .TP .B desc Human\-readable description of the problem .UNINDENT .INDENT 7.0 .TP .B line Line on which the problem was found (starting at 1) .UNINDENT .INDENT 7.0 .TP .B rule 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 .EX let g:syntastic_yaml_checkers = [\(aqyamllint\(aq] .EE .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 Visual Studio Code .sp \fI\%https://marketplace.visualstudio.com/items?itemName=fnando.linter\fP .SS IntelliJ .sp \fI\%https://plugins.jetbrains.com/plugin/15349\-yamllint\fP .SS Other text editors .sp 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 the \fI\%pre\-commit\fP tool. Here is an example, to add in your .pre\-commit\-config.yaml .INDENT 0.0 .INDENT 3.5 .sp .EX \-\-\- # Update the rev variable with the release version that you want, from the yamllint repo # You can pass your custom .yamllint with args attribute. repos: \- repo: https://github.com/adrienverge/yamllint.git rev: v1.29.0 hooks: \- id: yamllint args: [\-\-strict, \-c=/path/to/.yamllint] .EE .UNINDENT .UNINDENT .SS Integration with GitHub Actions .sp yamllint auto\-detects when it\(aqs running inside of \fI\%GitHub Actions\fP and automatically uses the suited output format to decorate code with linting errors. You can also force the GitHub Actions output with \fByamllint \-\-format github\fP\&. .sp A minimal example workflow using GitHub Actions: .INDENT 0.0 .INDENT 3.5 .sp .EX \-\-\- on: push # yamllint disable\-line rule:truthy jobs: lint: runs\-on: ubuntu\-latest steps: \- uses: actions/checkout@v3 \- name: Install yamllint run: pip install yamllint \- name: Lint YAML files run: yamllint . .EE .UNINDENT .UNINDENT .SS Integration with Arcanist .sp You can configure yamllint to run on \fBarc lint\fP\&. Here is an example \fB\&.arclint\fP file that makes use of this configuration. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqlinters\(dq: { \(dqyamllint\(dq: { \(dqtype\(dq: \(dqscript\-and\-regex\(dq, \(dqscript\-and\-regex.script\(dq: \(dqyamllint\(dq, \(dqscript\-and\-regex.regex\(dq: \(dq/^(?P\e\ed+):(?P\e\ed+) +(?Pwarning|error) +(?P.*) +\e\e((?P.*)\e\e)$/m\(dq, \(dqinclude\(dq: \(dq(\e\e.(yml|yaml)$)\(dq } } } .EE .UNINDENT .UNINDENT .SH AUTHOR Adrien Vergé .SH COPYRIGHT 2023, Adrien Vergé .\" Generated by docutils manpage writer. .