Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor integration #225

Open
manuelpuyol opened this issue Jul 15, 2021 · 7 comments
Open

Editor integration #225

manuelpuyol opened this issue Jul 15, 2021 · 7 comments

Comments

@manuelpuyol
Copy link

Summary

erb-lint is a great tool to keep your ERB consistent and avoid known security issues, such as rendering raw inputs.

However, the linting process is usually late in the development process, typically being run during CI, which can slow down developers since they may only get notified of errors after opening a PR and getting the build to fail.

Proposal

Make erb-lint easy to integrate with editors (Vim, Emacs, VSCode...) so developers can have real-time feedback of the ERB they are editing.

Problems

The current output that erb-lint provides does not contain all the necessary information to decorate editors with the exact location of linting errors. Right now, it's only possible to get the line where the error occurs instead of the whole block (line + columns).

Solution

Adding a generic formatter that exposes more data about the error, such as a JSON formatter, similar to rubocop's formatter.

Exposing structured information about the errors in the file would allow better decorations for editors, like underlining the exact location of offenses.

Related

#173
#219
#224

@roelandxyz
Copy link

vim is now supported: dense-analysis/ale#3931

@manuelpuyol
Copy link
Author

@rafaelfranca
Copy link
Member

Maybe we should document in the README? Mind to open a PR?

@vlasar
Copy link

vlasar commented Jun 4, 2024

I'm attempting to integrate erb-lint for formatting into Neovim using https://github.com/stevearc/conform.nvim.

Is there way to silence the "report" without parsing the output manually?

By "report" I mean, for example, the following:

Linting and autocorrecting 1 files with 15 linters (11 autocorrectable)...

2 error(s) corrected in ERB files

The file gets correctly auto-fixed, but the report is appended to the top of the file.

SCR-20240604-otng

@nickpoorman
Copy link

Came here to comment the same thing as @vlasar. I would like to to using this in nvim conform with stdin mode so that it's fast but the report output injected at the top messes that up. Maybe it could have a quiet format like rubocop has. Or possibly redirect the report output at the top to stderr instead of stdout.

@rrothenberger
Copy link

@vlasar @nickpoorman I'm a bit late, so I hope you already found solution, but if not, you should be able to use conform with erb_lint through config like that:

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

Hope it helps!

@vlasar
Copy link

vlasar commented Sep 9, 2024

@rrothenberger Awesome. That works great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants