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

Rubocop Layout/CommentIndentation autocorrection can cause wrong ERB #306

Open
tjschuck opened this issue Feb 8, 2023 · 0 comments
Open

Comments

@tjschuck
Copy link

tjschuck commented Feb 8, 2023

Consider the following ERB:

<%# comment syntax 1 %>
<% # comment syntax 2 %>

The second line is wrong, and correctly gets caught by erb-lint, failing with Bad ERB comment syntax. Should be <%# without a space between.

However, if you also have Rubocop enabled with Layout/CommentIndentation, for example with this erb-lint config:

---
EnableDefaultLinters: true
linters:
  Rubocop:
    enabled: true
    rubocop_config:
      AllCops:
        DisabledByDefault: true
      Layout/CommentIndentation:
        Enabled: true

The test file above gets corrected to:

<%# comment syntax 1 %>
# comment syntax 2 %>

Which is definitely wrong!

I'm not sure if the only solution is to add Layout/CommentIndentation to the list of recommended cops to disable in https://github.com/Shopify/erb-lint#Rubocop or if something better can be done to avoid the problem altogether.

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

No branches or pull requests

1 participant