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

ConsecutiveComments linter "good" example appears to have incorrect indenting #43

Closed
anselmbradford opened this issue Nov 25, 2014 · 6 comments
Labels

Comments

@anselmbradford
Copy link

The "good" example for the ConsecutiveComments linter has 3 spaces for all lines after the first. In practice this doesn't appear possible to do. Take the following partial snippet:

-# The email partial displays the email icon and address.
   e.g. [icon] admin@example.com

- if email.present?
  %section.email
    

With 3 spaces present for the second line of the comment, the page fails with a Haml::SyntaxError error of Inconsistent indentation: 2 spaces used for indentation, but the rest of the document was indented using 3 spaces..

A correctly functioning example instead uses 2 spaces for the lines after the first:

-# The email partial displays the email icon and address.
  e.g. [icon] admin@example.com

- if email.present?
  %section.email
    

Is there a recommended format that left-aligns all pertinent comment lines, something like the following for example?

-# |
  The email partial displays the email icon and address.
  e.g. [icon] admin@example.com
@sds
Copy link
Owner

sds commented Nov 30, 2014

Hey @anselmbradford, sorry for the delay in response.

You example works just fine for me—I don't get any syntax errors. You should be able to indent as many characters as you want, so the "good" example works as-is.

Which version of haml and haml-lint are you running?

@anselmbradford
Copy link
Author

Hey @sds haml 4.0.5 and haml-lint 0.8.0. This is the example file I showed that won't accept three spaces for line subsequent to the first. Do you see anything else that would cause an issue there? Thanks!

@sds
Copy link
Owner

sds commented Dec 1, 2014

Hey @anselmbradford,

That file parses just fine for me, both with haml-lint as well as haml itself (when I replace email with a literal string so haml can actually run it).

I'm not sure what other advice I can offer here--it seems like there's something about your system that is causing this issue. Can you get others to reproduce? What OS and Ruby version are you running?

@monfresh
Copy link

monfresh commented Dec 2, 2014

Hi @sds. What Ans is referring to is that in a HAML document, indentation must be consistent. The file he linked to already has consistent indentation, so it will parse fine. To reproduce the issue, you will need to add an extra space on line 2.

The problem is that most people will probably use 2 spaces of indentation within a document, and if they follow your comment example that uses 3 spaces of indentation, the parsing will break because of inconsistent indentation.

@sds sds added the question label Dec 3, 2014
@sds
Copy link
Owner

sds commented Dec 3, 2014

Thanks for the clarification @monfresh.

My mistake—the documentation is clearly incorrect in this case. I've updated it to the following example:

-#
  This is a comment
  spread over multiple lines that reads cleanly

@sds sds closed this as completed Dec 3, 2014
@anselmbradford
Copy link
Author

@sds FYI, I haven't double-checked, but I believe haml-lint may complain if there isn't a trailing space after -#, which may not be apparent in the updated example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants