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
- Host: GitHub
- URL: https://github.com/ydah/yamlint
- Owner: ydah
- License: mit
- Created: 2022-11-16T11:22:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-01-22T01:17:32.000Z (5 months ago)
- Last Synced: 2026-01-22T12:48:36.410Z (5 months ago)
- Topics: format, formatter, lint, linter, ruby, yaml, yml
- Language: Ruby
- Homepage: https://ydah.github.io/yamlint/
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
yamlint
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.