Git Product home page Git Product logo

Comments (6)

sds avatar sds commented on June 16, 2024

Hey @maxjacobson,

Those cops are ignored for a good reason: haml-lint takes some shortcuts when extracting Ruby code from a HAML template, which necessarily results in noise from those cops.

Can you give a specific example of a cop you want to disable?

If you still REALLY want to do this, you just need to redefine the entire list in your local .haml-lint.yml:

linters:
  RuboCop:
    ignored_cops: [] # NOT RECOMMENDED!

from haml-lint.

maxjacobson avatar maxjacobson commented on June 16, 2024

Hey @sds thanks for getting back to me!

there are a few nitpicky things I was hoping haml-lint would catch:

are you saying it doesn't analyze the file as it is, but first transforms it into some other ruby file, so it wouldn't catch those things necessarily anyway?

thanks!

from haml-lint.

sds avatar sds commented on June 16, 2024

Yes, as part of its preprocessing, haml-lint will convert HAML like this:

- if signed_in?(viewer)
  %span Stuff
  = link_to 'Sign Out', sign_out_path
- else
  .some-class{ class: my_method }= my_method
  = link_to 'Sign In', sign_in_path

...into Ruby like this:

if signed_in?(viewer)
  link_to 'Sign Out', sign_out_path
else
  { class: my_method }
  my_method
  link_to 'Sign In', sign_in_path
end

Notice that the Ruby is somewhat nonsensical. All haml-lint tries to do is preserve the ordering of declarations and uses of variables, as well as the order Ruby that code appears in the template. This means you probably won't have a translation that makes perfect sense.

For things like indentation, it may be possible to munge things into shape but I haven't looked too deeply into that. Right now if you have HAML like the following:

%tag{ some: 'hash', 
      attributes: 'here' }

...it will get extracted as:

{ some: 'hash', attributes: 'here' }

...losing some of the whitespace in the process. This makes it difficult to have it generate correct indentation.

For your request about final newlines, I think it's reasonable for haml-lint to support that first hand via a FinalNewline linter, since RuboCop won't have any idea whether your HAML template ends with a newline or not.

from haml-lint.

maxjacobson avatar maxjacobson commented on June 16, 2024

Makes total sense, thanks for explaining.

Adding a newline check would be super helpful! What do you think about checking for the presence of a tab character? I think most Rubyists are using spaces, not tabs, so checking for the presence of a tab file character in the source haml file might be useful as well 😄

from haml-lint.

sds avatar sds commented on June 16, 2024

Added a final newline check in 1635c07. Enforcing spaces instead of tabs in indentation was added in #81.

from haml-lint.

maxjacobson avatar maxjacobson commented on June 16, 2024

Awesome! Thanks a lot @sds

from haml-lint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.