Skip to content

HAML linter is removing 1-line %div tags, resulting in broken syntax #1258

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

Closed
jacobtbz opened this issue Jul 21, 2022 · 3 comments · Fixed by ruby-syntax-tree/syntax_tree-haml#19

Comments

@jacobtbz
Copy link

jacobtbz commented Jul 21, 2022

Metadata

  • Operating system: macOS 12.4 (Apple M1 Pro)
  • Ruby version: 3.1.2
  • Node version: 18.6.0
  • Gems:
    prettier (3.1.2)
    syntax_tree (3.1.0)
    syntax_tree-haml (1.2.0)
    syntax_tree-rbs (0.5.0)
  • Packages:
"@prettier/plugin-ruby@^3.1.2":
  version "3.1.2"

prettier@>=2.3.0, prettier@^2.7.1:
  version "2.7.1"

pretty-quick@^3.1.3:
  version "3.1.3"

Input

%div Hi there

Current output

 Hi there

Expected output

%div Hi there

Current output isn't valid HAML because there's a space at the beginning. (And, also, it shouldn't remove a div.)

So I went over to https://github.com/prettier/plugin-haml to create an issue and found that the project has been archived. EDIT: I'm silly. Should have seen that that wasn't related to this project.

@kddnewton
Copy link
Member

HAML is a part of this project through https://github.com/ruby-syntax-tree/syntax_tree-haml. prettier/plugin-haml is not a maintained piece of this. haml-lint doesn't have anythign to do with this project.

What exactly do you have installed on your machine, and how are you running it?

@jacobtbz jacobtbz changed the title Since plugin-haml is archived, should it be removed from this project? HAML linter is removing 1-line %div tags, resulting in broken syntax Jul 22, 2022
@jacobtbz
Copy link
Author

jacobtbz commented Jul 22, 2022

Ah! Silly me - I should have been able to figure that out. Thank you for clarifying.

I updated the issue description with proper metadata.

Everything seems to work great, except for the issue I describe above.

Note that this is left untouched, though:

%div
  Hi there

so at least I have a workaround, but would be great if this could be fixed so

%div Hi there

would be left alone.

BTW, while I'm here, is there a rule that controls whether to put a space on the inside of curly braces?
(%p{class: foo} vs. %p{ class: foo })
(Is there somewhere where all Ruby/HAML rules are listed?)

@kddnewton
Copy link
Member

Okay this got fixed by the version 1.2.1 of syntax_tree-haml. If you update to that version of the gem everything should work properly.

As for your other question: there aren't really "rules" per-se in this project. It's not a linter, so it doesn't treat them that way. It's just a formatter, so it formats the same way every time regardless of what the input was.

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

Successfully merging a pull request may close this issue.

2 participants