mampf icon indicating copy to clipboard operation
mampf copied to clipboard

Herb HTML+ERB linting/formatting

Open Splines opened this issue 1 month ago • 0 comments

Ever since the first creation of #730, I wasn't too happy with the erb linting/formatting inside HTML files. For that PR, I've initially set up erb-lint, however it is only available as CLI. Therefore, I then integrated a VSCode extension that can run commands on file save. But this was error-prone (due to overwriting new file content) and very, very slow (multiple seconds), compared to the instant feedback we got with ESLint. In general, html-eslint is awesome, it's just that erb support is missing.

In this comment, I was recommended to use better-html, but that got deprecated in favor of Herb, which seems quite promising and already has very good docs. It uses a new approach to think of HTML and ERB together from the ground up. First experimentation with the Herb Language Server in VSCode seems quite promising. However, there is more to be done such that we can adopt, e.g.:

  • https://github.com/marcoroth/herb/issues/356, see also https://github.com/marcoroth/herb/issues/537
  • https://github.com/marcoroth/herb/issues/916 The Herb Formatter is only in experimental preview right now. It also doesn't give us squiggly lines in VSCode right now when the formatting is incorrect. But it does a good job when saving the file.

Herb is currently being developed, see the Herb GitHub repo. Maybe it's a good idea to postpone HTML formatting/linting for a bit to then jump onto Herb once it's more feature-complete and stable. In the meantime, feel free to experiment with it already.

Splines avatar Nov 22 '25 11:11 Splines