-
Notifications
You must be signed in to change notification settings - Fork 60
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
Linter ControlStatementSpacing raise incorrect =
#101
Comments
Long time no see :D In that code snippet there is one backslash Now, if I create a slim file with this content: div class='one \
two'
div = some_method and run the linter over it in master, I get this error:
"That's good, I can reproduce the bug", I thought. But when I try to add a test for it, the test passes without error! context 'multi-line attributes' do
let(:slim) { "div class='one \\n two'\ndiv = some_method" }
it { should_not report_lint }
end # Or even like this
context 'multi-line attributes' do
let(:slim) {
<<-END
div class='one \
two'
div = some_method
END
}
it { should_not report_lint }
end I'm not sure what could cause this behavior. I have nothing in my (Incidentally, in this example, the code line with the backslash ends on a comma, which also serves as a newline in the compiler. So, simply removing the backslash is a workaround to get the linter pass, without affecting the generated HTML.) |
Thanks for investigating! Given there is a workaround, I'm inclined to leave this issue open for someone with enough interest to fix. Will happily merge a pull request fixing the issue (though I am at a loss as to why it would not be reproducible in the test environment). |
I think this error is due to slim-lint escaping a line break when it's preceded by a backslash. You can test this by adding a character after the backslash and seeing the error disappear. To replicate it in a test, perhaps we could escape the slash: or used a non-escaped heredoc:
Either way, I think underlying is a real error that causes slim-lint's line count to be off by one for every line that ends in a backslash. Hopefully I have time to familiarize myself with the repository and pursue this - but I'll leave this comment just in case I don't. |
I put out a PR for a code that solves this problem. The problem seemed to be that https://github.com/sds/slim-lint/blob/main/lib/slim_lint/document.rb#L41 was creating source_line with a newline with or without a backslash. This is my first time submitting a PR to OSS, so I apologize if I am rude. |
This commit is to resolve issue #101 . I'm not familiar with OSS, so I apologize if I'm being impolite. I'm also using machine translation for English.
Implemented in #164. |
This commit is to resolve issue sds/slim-lint#101 . I'm not familiar with OSS, so I apologize if I'm being impolite. I'm also using machine translation for English.
・sds/slim-lint#101 ・上記(解決してるっぽいけど...)と同じように、`\`で改行している影響でlintに引っかかっているかも ・「=前後にスペースを入れろ」という指摘だがちゃんと修正しても同じ指摘が出続けてしまう ・いつか直すとして一旦ignore
lint対応 ・sds/slim-lint#101 ・上記(解決してるっぽいけど...)と同じように、`\`で改行している影響でlintに引っかかっているかも ・「=前後にスペースを入れろ」という指摘だがちゃんと修正しても同じ指摘が出続けてしまう ・いつか直すとして一旦ignore ・sds/slim-lint#101
It's weird why
ControlStatementSpacing
linter keeps raisingPlease add a space before and after the =
even I didn't see any isse.WARNINGS:
Dependencies:
The text was updated successfully, but these errors were encountered: