There are some known violations which I want to skip, and can do successfully by including the appropriate rubocop:disable comment at the end of the line, eg:
<% if a > 0 # rubocop:disable Style/NumericPredicate %>
I am also using Brakeman (which I believe uses this parser) to check erb files, but once there are comments inside the erb tags, the file is no longer parseable so it's no longer checked
Issue
This code:
<script>
// ok
const a = <%= 1 %>;
// not ok
const b = <%= 1 # hello %>;
// ok
<% if true %>;
const c = true;
<% end%>
// not ok
<% if true # hello %>;
const d = true;
<% end%>
</script>
leads to this parsing error when running brakeman
== Errors ==
Error: app/views/comments_in_erb.html.erb:8 :: parse error on value "ok" (tIDENTIFIER) Could not parse app/views/comments_in_erb.html.erb
Location: Could not parse <snip>/app/views/comments_in_erb.html.erb
Expected behaviour
I would expect %> after a # to terminate the comment and the tag; currently it seems like %> is parsed as being part of the comment
Background
rubocop:disable
comment at the end of the line, eg:Issue
This code:
leads to this parsing error when running brakeman
Expected behaviour
I would expect
%>
after a#
to terminate the comment and the tag; currently it seems like%>
is parsed as being part of the commentWorking reproduction
You can see the issue here from this repo if you check it out and run
brakeman
- but sorry I don't have a non brakeman-specific reproduction https://github.com/johansenja/brakeman-erb-test/