Skip to content

Config: Report when a wrongly named config file is present - #1996

Merged
marcoroth merged 1 commit into
mainfrom
herb-yaml-config
Aug 4, 2026
Merged

marcoroth merged 1 commit into
mainfrom
herb-yaml-config

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

Inspired by #1678, which ran into a real friction point: creating .herb.yaml instead of .herb.yml didn't work, and the way it didn't work was unhelpful.

.herb.yml stays the only configuration filename Herb reads, following the convention used by Rails and most other Ruby tooling. Supporting both extensions at the same time would mean two places a setting can live, and it isn't obvious which one wins. The problem worth fixing isn't the filename, it's that a misnamed file looks like it should work.

So herb-lint would hard fail in one situation, and in Ruby a .herb.yaml full of carefully written excludes was silently doing nothing. The Ruby case is almost certainly how this gets discovered in the first place.

This pull request replaces all of that with a warning at config discovery time, in every runtime:

⚠ Ignoring /your-project/.herb.yaml: Herb only reads `.herb.yml`. Rename it to `.herb.yml` to apply it.

The run continues instead of aborting, so a stray file can't block linting or formatting. Ruby prefixes it with [Herb], matching the other warnings there.

Detection also covers a missing leading dot, not just the wrong extension:

.herb.yaml
herb.yml
herb.yaml

The warning fires whether or not a valid config exists, which covers the case a hard error never reached. With both files present, .herb.yml is still read and the .herb.yaml is reported as ignored:

⚠ Ignoring /your-project/.herb.yaml: Herb only reads `.herb.yml`. Rename it to `.herb.yml` to apply it.
✓ Using Herb config file at /your-project/.herb.yml

Passing a misnamed file explicitly is reported too, since --config-file .herb.yaml previously fell back to discovery without saying so.

Language Server

The wrong_file_extension diagnostic already existed but only looked for .herb.yaml. It now reports every variant and derives the filename from the file it found:

Found herb.yml file. Please rename to .herb.yml

Supersedes #1678

`.herb.yml` stays the only configuration filename Herb reads, following the
convention used by Rails and most other Ruby tooling. A file named
`.herb.yaml`, `herb.yml`, or `herb.yaml` was previously either rejected with a
hard error (JavaScript and Rust) or ignored without a word (Ruby), so it looked
like the configuration simply had no effect.

All three runtimes now report the file instead, and the hard errors are gone:

    ⚠ Ignoring /project/.herb.yaml: Herb only reads `.herb.yml`. Rename it to `.herb.yml` to apply it.

The language server reports the same thing as a `wrong_file_extension`
diagnostic for every misnamed variant, not just `.herb.yaml`.

Co-authored-by: Kryštof Korb <krystof@korb.cz>
@marcoroth
marcoroth marked this pull request as ready for review August 4, 2026 18:27
@github-actions github-actions Bot added documentation Improvements or additions to documentation ruby Ruby source for the gem and its libraries typescript TypeScript source across the javascript/ packages rbs RBS type signatures in sig/ rubygem The herb RubyGem and its packaging config Herb configuration file handling and config options rust Rust bindings and the Herb Rust crate labels Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit cb9485f


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 4, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@1996
npx https://pkg.pr.new/@herb-tools/language-server@1996
npx https://pkg.pr.new/@herb-tools/linter@1996

commit: cb9485f

@marcoroth
marcoroth merged commit b52312d into main Aug 4, 2026
34 checks passed
@marcoroth
marcoroth deleted the herb-yaml-config branch August 4, 2026 18:37
marcoroth added a commit that referenced this pull request Aug 4, 2026
Follow up on #1996, which started reporting a config file that Herb
doesn't read, but only on the CLI:

```
⚠ Ignoring /your-project/.herb.yaml: Herb only reads `.herb.yml`. Rename it to `.herb.yml` to apply it.
```

In the editor a `.herb.yaml`, `herb.yml`, or `herb.yaml` still showed
nothing at all. That is the same impression the file already gives on
its own, so the one place where the mistake is most likely to be made
was also the one place that stayed quiet about it.

The reason is that these documents never reached the language server.
The VS Code document selector and the file watchers on both sides only
ever matched `.herb.yml`, so the server was never told the file existed.

This pull request opens that path and reports the file once it arrives.
The document gets an error spanning its entire contents:

```
Herb only reads `.herb.yml`, so this file is ignored. Rename it to `.herb.yml` to apply it.
```

The status bar turns red and reads `.herb.yaml (Not Read)`, with a
tooltip naming every misnamed file found and what to rename it to.
Clicking it opens the file:

<img width="2638" height="1954" alt="CleanShot 2026-08-04 at 21 17
06@2x"
src="https://github.com/user-attachments/assets/6cda238c-852b-460d-adcf-fad4831eb0af"
/>

This branch was successfully deployed

1 active deployment
herb-tools (Preview) — cb9485f3 Deployed Aug 4, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Herb configuration file handling and config options documentation Improvements or additions to documentation rbs RBS type signatures in sig/ ruby Ruby source for the gem and its libraries rubygem The herb RubyGem and its packaging rust Rust bindings and the Herb Rust crate typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant