Shopify / erb-lint

Lint your ERB or HTML files
MIT License
592 stars 113 forks source link

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

Open nickpoorman opened 1 week ago

nickpoorman commented 1 week 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 1 week ago

I have signed the CLA!