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 &= and != to SpaceBeforeScript #203
Conversation
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.
There were a few things that I was concerned about, but I verified that they all work exactly the same as prior to this patch.
My only concern that I have left is that the changes are drafting this linter into a role that it handles incidentally. Since this is the "SpaceBeforeScript" linter, it seems odd to lint HTML [un]escapes with it. It's easy to put into this linter, but that is only because Haml represents these nodes as script nodes.
I wonder if it would be better to make a new linter that performs a very similar check but has a name that is more pertinent to this actual check. This seems preferable to me because, as it stands now, the name is confusing when paired with all the functionality that this adds.
@@ -10,7 +10,7 @@ def parsed_script | |||
HamlLint::ParsedRuby.new(HamlLint::RubyParser.new.parse(script)) | |||
end | |||
|
|||
# Returns the source for the script following the `-` marker. | |||
# Returns the source for the script following the `=` marker. |
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.
Good catch.
return unless document.source_lines[node.line - 1].lstrip.start_with?('=') | ||
record_lint(node, MESSAGE_FORMAT % '=') if missing_space?(node) | ||
line = document.source_lines[node.line - 1].lstrip | ||
return unless line.start_with?('=', '&=', '!=') |
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.
Huh. Today I learned that you can send multiple matchers to start_with?
. 👍
Yeah, there are few interesting differences, while in haml parser this 2 is "modifiers" to script, they behave differently, like changes in |
I agree with @michaelherold in that this might be better as a separate linter. |
Closing due to lack of response. I agree this should be a separate linter for clarity's sake. More than happy to merge once it's been extracted into a separate linter! |
No description provided.