-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add support for linting ECR files #536
Conversation
Requires Crystal >= 1.15.0
Specs would be good to have too 🙏 |
Co-authored-by: Sijawusz Pur Rahnama <[email protected]>
@nobodywasishere I may have missed some conversation, but does this conflict with |
I don't know if there's been a conversation about that, but I do see how this could conflict with def render_page
my_var = 1
# ^^^^ error: Useless assignment to `my_var`
render("path/to/page.ecr")
end <%= my_var %> This is already an issue though without this PR. Is there something specific you had in mind? Another one specific to ECR though is something like: <%
my_var ||= 2
# ^^^^ Lint/Syntax: Cannot use `my_var` in assignment to `my_var`
%>
<%= my_var %> Which means templates just need to be written in a way where they're parsable outside the context of where they're rendered. One cool thing I found while testing is that <%
"hello world"
# ^^^^^^^^^^^ error: unused literal
%> So it will give a warning if you accidentally leave off the |
I've gone through all the rules and all the current auto corrections should be fine. Anything that changes stuff over the Original ECR: <% if true %>
<%= "hello" %>
<% end %> Parsed ECR (without loc pragmas): if true
__str__ << "\n "
("hello").to_s(__str__)
__str__ << "\n"
end "Corrected" source: if true
# __str__ << "\n "
# ("hello").to_s(__str__)
# __str__ << "\n"
end Could completely break or mangle the original ECR. This shouldn't be a problem with the current rules though. |
By specs I meant testing the ECR support, not adding tests to the rule specs. |
I thought having some tests that ensure functionality within an ECR file would be useful, but I can remove them if desired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
e83504e
to
3c90e04
Compare
This needs another go-around, see https://github.com/crystal-ameba/ameba/actions/runs/12782021496/job/35630866247#step:7:1 |
I've no idea what caused that that wouldn't also work locally... I can try moving the location of the |
Yeah alpine is still using Crystal 1.14 https://pkgs.alpinelinux.org/package/edge/community/x86_64/crystal |
Requires Crystal >= 1.15.0. Lints ECR files by default. Closes #509