Skip to content

yamllint config is incompatible with Ruby/Psych-generated YAML files #93

Description

@ineedjet

Problem

The current baseline yamllint config has two rules that conflict with YAML files generated by Ruby's Psych (the standard Ruby YAML serializer used by Rails, RuboCop, i18n-tasks, etc.):

  1. document-start: present: false — Psych always adds --- to the start of every document. This cannot be disabled via options in any Ruby version (including Ruby 4 / Psych 5.4).

  2. indentation: indent-sequences: true (inherited from extends: default) — Psych always outputs block sequences at the same indentation level as the parent key (non-indented style). This also cannot be changed via options.

Psych output (always)

---
en:
  date:
    abbr_day_names:
    - Sun
    - Mon

What baseline yamllint requires

en:
  date:
    abbr_day_names:
      - Sun
      - Mon

Psych has no options to suppress --- or produce indented sequences — both behaviors are hardcoded in libyaml's C emitter.

Affected files in a typical Rails project

  • config/locales/*.yml — generated/normalized by i18n-tasks
  • .rubocop_todo.yml — generated by rubocop --auto-gen-config
  • .rubocop.yml, .erb_lint.yml — blank lines between sections (separate issue, already fixed by removing blank lines)

Consequence

In a Rails project using baseline's yamllint linter, i18n-tasks health and yamllint are mutually exclusive:

  • If locale files pass yamllint → i18n-tasks health fails ("data requires normalization")
  • If i18n-tasks normalize is run → yamllint fails

Proposed solution

Support two yamllint profiles in baseline — one for Psych-generated files, one for human-written files:

config/yamllint/default.yml   # current rules, for human-written YAML
config/yamllint/psych.yml     # relaxed rules for Psych output

Or alternatively, support a project-level yamllint config override (e.g. .yamllint-baseline.yml that extends the baseline config), so projects can add their own ignore: patterns or rule overrides.

A minimal fix would be adding config/locales/ to the baseline ignore: block, since locale files are a universal Rails pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions