跳转到主要内容

YAML文件检查器。

项目描述

YAML文件检查器。

yamllint不仅检查语法有效性,还检查诸如键重复和如行长度、尾随空格、缩进等外观问题。

CI tests status Code coverage status Documentation status

用Python编写(仅与Python 3兼容)。

文档

https://yamllint.readthedocs.io/

概览

屏幕截图

yamllint screenshot

安装

使用pip,Python包管理器

pip install --user yamllint

yamllint也打包适用于所有主要操作系统,请参阅安装示例(dnfapt-get…)在文档中

用法

# Lint one or more files
yamllint my_file.yml my_other_file.yaml ...
# Lint all YAML files in a directory
yamllint .
# Use a pre-defined lint configuration
yamllint -d relaxed file.yaml

# Use a custom lint configuration
yamllint -c /path/to/myconfig file-to-lint.yaml
# Output a parsable format (for syntax checking in editors like Vim, emacs...)
yamllint -f parsable file.yaml

请参阅完整文档了解更多!

特性

以下是一个yamllint配置文件示例

extends: default

rules:
  # 80 chars should be enough, but don't fail if a line is longer
  line-length:
    max: 80
    level: warning

  # don't bother me with this rule
  indentation: disable

在YAML文件中,可以使用特殊注释来禁用对单行的检查

This line is waaaaaaaaaay too long  # yamllint disable-line

或对整个块的检查

# yamllint disable rule:colons
- Lorem       : ipsum
  dolor       : sit amet,
  consectetur : adipiscing elit
# yamllint enable

可以使用.gitignore风格的模式忽略特定文件(完全或仅针对某些规则)

# For all rules
ignore: |
  *.dont-lint-me.yaml
  /bin/
  !/bin/*.lint-me-anyway.yaml

rules:
  key-duplicates:
    ignore: |
      generated
      *.template.yaml
  trailing-spaces:
    ignore: |
      *.ignore-trailing-spaces.yaml
      /ascii-art/*

请参阅完整文档了解更多!

许可证

GPL版本3

项目详情


发行历史 发行通知 | RSS订阅

下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

yamllint-1.35.1.tar.gz (134.6 kB 查看哈希值)

上传时间

构建分布

yamllint-1.35.1-py3-none-any.whl (66.7 kB 查看哈希值)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面