yamlint

Ruby VersionLicensetestGem Version

A Ruby CLI for linting and formatting YAML files

FeaturesQuickstartInstallationUsageConfigurationRules

Features

  • Rule-based linting and auto-formatting

  • Configuration via .yamllint(.yml/.yaml) with preset extends

  • CI-friendly output formats (standard/parsable/colored/github)

  • YAML file patterns and ignore support

Quickstart

gem install yamlint

# lint
yamlint .

# format (dry-run)
yamlint format --dry-run .

Installation

With Bundler:

bundle add yamlint

Without Bundler:

gem install yamlint

Usage

Basic:

yamlint .
yamlint path/to/file.yml

Formatting:

yamlint format .
yamlint format --dry-run .

CI output:

yamlint -f github .

Help:

yamlint --help

Configuration

Default config file names:

  • .yamllint

  • .yamllint.yml

  • .yamllint.yaml

Configuration options:

Option Type Default Behavior
extends string none Inherit a preset (default or relaxed). Values from the current file override the preset.
yaml-files list of glob strings ["*.yaml", "*.yml"] Glob patterns used when discovering YAML files in directories.
ignore list of strings [] List of paths to skip. Parsed by the config loader but not currently applied to file discovery.
rules map {} Per-rule configuration. Set a rule to disable or false to turn it off, or provide a map of options.

Notes:

  • Rule option keys accept either snake_case or kebab-case and are normalized internally.

  • Rule option defaults come from the rule implementation and are merged with your overrides.

Example:

extends: default

yaml-files:
  - "*.yml"
  - "*.yaml"

ignore:
  - vendor
  - node_modules

rules:
  line-length:
    max: 120
  document-start: disable
  truthy:
    allowed-values: ["true", "false"]

Presets

Available presets:

  • default

  • relaxed

extends: relaxed

Rules

Key rules:

  • anchors, braces, brackets, colons, commas, comments, comments-indentation

  • document-start, document-end, empty-lines, empty-values, float-values

  • hyphens, indentation, key-duplicates, key-ordering, line-length

  • new-lines, new-line-at-end-of-file, octal-values, quoted-strings

  • trailing-spaces, truthy

Output formats

Use -f/--format to select an output format:

  • standard

  • parsable

  • colored

  • github

Development

bin/setup
rake spec

Install locally:

bundle exec rake install

Release:

bundle exec rake release

License

MIT License. See LICENSE.txt for details.