Skip to content

Conversation

@rrothenberger
Copy link

@rrothenberger rrothenberger commented Sep 6, 2024

Hey 👋

The goal of this PR is to make it easier to use this great tool within editors, for example using it with conform. It does that by adding a new reporter: none, which will prevent reporting any linter output to stdout, and by adding flag --no-file-header which will prevent outputting this line:

================ /path/to/file.html.erb ==================

Naming is hard, so more than happy to adjust naming.

Example:
image

There is another PR with similar changes: #357, the main differences are:

  • none reporter just does not output anything instead of moving the lining logs into stderr, as I was afraid it might still be read by some editors.
  • I didn't want to change behavior of all cli outputs by setting --format - personally wouldn't expect that from the CLI, so instead I decided to add new flag that disabled the file header from above.

I skipped specs for the reporter itself, as this just prevents outputs.


If someone found this out looking for solution for conform - even if this is not merged, you still can use erb_lint with conform, just not through stdin, example configuration:

    formatters = {
      erb_lint = {
        stdin = false,
        tmpfile_format = ".conform.$RANDOM.$FILENAME",
        command = "bundle",
        args = { "exec", "erblint", "--autocorrect", "$FILENAME" },
      },
    },

if stdin? && autocorrect?
# When running from stdin, we only lint a single file
puts "================ #{lint_files.first} ==================\n"
puts "================ #{lint_files.first} ==================\n" unless @options[:no_file_header]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than introducing a new option, can we just assume that when the 'none' reporter is being used, we ignore the header?

@etiennebarrie
Copy link
Member

Can you check whether #393 would work for you? I think it should.

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

Successfully merging this pull request may close these issues.

3 participants