← 返回命令列表

Linux command

yamllint 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Lint a YAML file

yamllint [file.yaml]

Lint all YAML files

yamllint [path/to/directory]

Use a specific configuration file

yamllint -c [.yamllint.yaml] [file.yaml]

Use a predefined configuration

yamllint -d relaxed [file.yaml]

Output in parsable format

yamllint -f parsable [file.yaml]

Strict mode

yamllint -s [file.yaml]

List files that would be linted

yamllint --list-files [path]

说明

yamllint is a linter for YAML files that checks for syntax validity and style issues. Beyond basic syntax checking, it detects problems like duplicate keys, line length violations, trailing spaces, indentation inconsistencies, and truthy value ambiguities. Configuration is loaded from .yamllint, .yamllint.yaml, or .yamllint.yml in the current or parent directories, the $YAMLLINT_CONFIG_FILE environment variable, or $XDG_CONFIG_HOME/yamllint/config (~/.config/yamllint/config). The tool provides multiple output formats suitable for different use cases: human-readable, editor integration, and CI systems (GitHub Actions, GitLab CI).

参数

-c, --config-file _file_
Use specified configuration file.
-d, --config-data _data_
Configuration as YAML string or preset name (default, relaxed).
-f, --format _format_
Output format: standard, parsable, github, gitlab, colored, auto.
-s, --strict
Return non-zero exit code on warnings (not just errors).
--no-warnings
Suppress warning messages in output.
--list-files
List files that would be processed without linting.
-v, --version
Display version and exit.
-h, --help
Display help message and exit.

FAQ

What is the yamllint command used for?

yamllint is a linter for YAML files that checks for syntax validity and style issues. Beyond basic syntax checking, it detects problems like duplicate keys, line length violations, trailing spaces, indentation inconsistencies, and truthy value ambiguities. Configuration is loaded from .yamllint, .yamllint.yaml, or .yamllint.yml in the current or parent directories, the $YAMLLINT_CONFIG_FILE environment variable, or $XDG_CONFIG_HOME/yamllint/config (~/.config/yamllint/config). The tool provides multiple output formats suitable for different use cases: human-readable, editor integration, and CI systems (GitHub Actions, GitLab CI).

How do I run a basic yamllint example?

Run `yamllint [file.yaml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -c, --config-file _file_ do in yamllint?

Use specified configuration file.