sds / haml-lint

Tool for writing clean and consistent HAML
MIT License
318 stars 101 forks source link

Rubocop 0.59.x Layout/EmptyLineAfterGuardClause almost unavoidable fired. #285

Closed carbonComputer closed 6 years ago

carbonComputer commented 6 years ago

Our app has several guards in haml like - return unlesssupported_browser?` This will always be triggered when we lint.

How do we workaround this issue?

sds commented 6 years ago

Recommend you disable the Layout/EmptyLineAfterGuardClause for any files in the directory in question. So if you store your HAML templates in app/views/*, you can write:

#.rubocop.yml
Layout/EmptyLineAfterGuardClause:
  exclude: 'app/views/**'

...or similar.

gingerlime commented 5 years ago

Bumped into the same issue. We have an empty line after the guard clause, but the cop still triggers.

Isn't there a way to fix the cop to work with HAML? it's still useful to have it for guard clauses in HAML, isn't it?

maddieholtzer commented 1 year ago

I know this is super late to the game but I think it is possible recent improvements to the project have fixed this issue. I was able to enforce Layout/EmptyLineAfterGuardClause in our views just now and was even able to autofix all the errors. We had originally disabled this rule in our views years ago seeing some similar issues to the one reported in this issue.

MaxLap commented 1 year ago

Oh, that makes sense. The new system does transfer blank lines from the HAML to the Ruby code that gets corrected.