Comments (6)
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.
Hey @sds thanks for getting back to me!
there are a few nitpicky things I was hoping haml-lint would catch:
- the newline character at end of file thing
- tabs instead of spaces for indentation
- 4 spaces instead of 2 spaces for indentation
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.
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.
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.
Added a final newline check in 1635c07. Enforcing spaces instead of tabs in indentation was added in #81.
from haml-lint.
Awesome! Thanks a lot @sds
from haml-lint.
Related Issues (20)
- False positive Rails/HttpStatus HOT 2
- Failing spec on main branch HOT 2
- Add support to Haml 6.2
- `haml-lint:disable` is ignored when line breaks on commas are present
- Add `-s`/`--stdin` option support HOT 2
- Allow Haml 6.3 HOT 3
- Haml 6.2 actions are not listed among required checks HOT 1
- Failing spec on main (local environment, up to date rubocop)
- Issue with Rubocop `Layout/IndentationConsistency` interaction with haml comment blocks HOT 2
- Version 0.53.0 has not been pushed to Rubygems HOT 1
- RuboCop: Lint/Syntax: unexpected token tSYMBOL and kEND HOT 5
- 0.54.0: Too many files open HOT 4
- Layout/ArgumentAlignment - False positive? HOT 2
- Feature Suggestion: require strict locals
- Possible false positives with Rails/FindEach
- Lint/Syntax: unexpected token kDO_BLOCK | Lint/Syntax: unexpected token kEND HOT 1
- False positive with Layout/SpaceInsideParens for multi-line attributes HOT 7
- Allow multiple reporters?
- False positive on the `UnnecessaryStringOutput` cop HOT 1
- Style/IfUnlessModifier - Potential False Positive as of 0.46.0 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haml-lint.