An open API service indexing awesome lists of open source software.

https://github.com/ydah/yamlint

A Ruby CLI for linting and formatting YAML files
https://github.com/ydah/yamlint

format formatter lint linter ruby yaml yml

Last synced: 5 months ago
JSON representation

A Ruby CLI for linting and formatting YAML files

Awesome Lists containing this project

README

          

yamlint


Ruby VersionLicensetestGem Version


A Ruby CLI for linting and formatting YAML files


Features
Quickstart
Installation
Usage
Configuration
Rules

## 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

```bash
gem install yamlint

# lint
yamlint .

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

## Installation

With Bundler:

```bash
bundle add yamlint
```

Without Bundler:

```bash
gem install yamlint
```

## Usage

Basic:

```bash
yamlint .
yamlint path/to/file.yml
```

Formatting:

```bash
yamlint format .
yamlint format --dry-run .
```

CI output:

```bash
yamlint -f github .
```

Help:

```bash
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:

```yaml
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`

```yaml
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

```bash
bin/setup
rake spec
```

Install locally:

```bash
bundle exec rake install
```

Release:

```bash
bundle exec rake release
```

## License

MIT License. See `LICENSE.txt` for details.