Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested lists indentation error #710

Open
cmsirbu opened this issue Jan 31, 2025 · 1 comment
Open

Nested lists indentation error #710

cmsirbu opened this issue Jan 31, 2025 · 1 comment

Comments

@cmsirbu
Copy link

cmsirbu commented Jan 31, 2025

It looks like when encountering a list within a list, yamllint expects an extra level of indentation. I'm running version 1.35.1. Here's an example which, according to the documentation, should pass.

.yamllint.yaml

---
extends: "default"
rules:
  indentation:
    spaces: 2
    indent-sequences: true

issue.yaml

---
- flying:
  - spaghetti
  - monster
- not flying:
  - spaghetti
  - sauce

Output:

> uv run yamllint issue.yaml 
issue.yaml
  3:3       error    wrong indentation: expected 4 but found 2  (indentation)
  6:3       error    wrong indentation: expected 4 but found 2  (indentation)

I'm encountering this when parsing mkdocs configuration, where it's quite common to have lists within lists in the nav section:

nav:
  - Home: index.md
  - User Guide:
    - Writing your docs: writing-your-docs.md
    - Styling your docs: styling-your-docs.md
  - About:
    - License: license.md
    - Release Notes: release-notes.md

To me 2 spaces for each list level seems natural (and sufficient), but I can't find examples in the latest yaml spec itself.

@0phoff
Copy link

0phoff commented Feb 5, 2025

I am encountering the exact same issue.
Quote annoying as it breaks my CI/CD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants