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

Add &= and != to SpaceBeforeScript #203

Closed
wants to merge 1 commit into from
Closed

Add &= and != to SpaceBeforeScript #203

wants to merge 1 commit into from

Conversation

igas
Copy link

@igas igas commented Mar 19, 2017

No description provided.

Copy link
Collaborator

@michaelherold michaelherold left a 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.
Copy link
Collaborator

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?('=', '&=', '!=')
Copy link
Collaborator

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?. 👍

@igas
Copy link
Author

igas commented Mar 19, 2017

Yeah, there are few interesting differences, while in haml parser this 2 is "modifiers" to script, they behave differently, like changes in missing_space? for = some_code node text will include space, but with & / ! in front of it - don't. ¯\_(ツ)_/¯

@trotzig
Copy link
Contributor

trotzig commented Mar 20, 2017

I agree with @michaelherold in that this might be better as a separate linter.

@sds
Copy link
Owner

sds commented Jun 7, 2017

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!

@sds sds closed this Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants