Shopify / erb_lint

Lint your ERB or HTML files
MIT License
680 stars 122 forks source link

Added a quiet reporter that directs all reporting data to stderr #357

Open nickpoorman opened 5 months ago

nickpoorman commented 5 months ago

Neovim conform and other editors such as Zed work better when able to pipe a file directly to stdin and get the formatted output via stdout.

The current reporters inject report data to the formatted file written to stdout. This PR adds a quiet reporter similar to rubocop's quiet format and writes all report output to stderr.

Addresses comments: https://github.com/Shopify/erb-lint/issues/225#issuecomment-2147731814, https://github.com/Shopify/erb-lint/issues/225#issuecomment-2192203785

The report output is still available via stderr but can also now be disabled with the ruby -W0 flag to suppress the warnings:

❯ cat index.html.erb | ruby -W0 erblint --format quiet --autocorrect --stdin index.html.erb

This can be run now as follows in a conform.nvim configuration:

formatters = {
  erb_lint = {
    env = {
      RUBYOPT = "-W0" -- suppress reporting output
    },
    command = "bundle",
    args = { "exec", "erblint", "--format", "quiet", "--autocorrect", "--stdin", "$FILENAME" },
  },
}
nickpoorman commented 5 months ago

I have signed the CLA!

thewatts commented 3 months ago

Found this while trying to integrate erb_lint with my neovim setup.

Can confirm - this addition would be very much appreciated 😇