Open palexvs opened 4 years ago
Well that looks like rubocop can lint haml files directly because that's what you do on the command line. Interestingly we explicitly exclude haml portions here in the plugin. Look here https://github.com/SublimeLinter/SublimeLinter-rubocop/blob/9bf25c766db9f61a7f554818c5d63430e4697f8f/linter.py#L27
You can change the selector in the settings though. Maybe "source.ruby, text.haml".
Do you think this is wrong here from the beginning, or has rubocop changed?
You can change the selector in the settings though. Maybe "source.ruby, text.haml".
I tried to set source
but it does not change anything:
{
...
"linters": {
"rubocop": {
...
"source": "source.ruby, text.haml"
}
}
}
Do you think this is wrong here from the beginning, or has rubocop changed?
Tried to say, I have not used HAML for a while and just now tried to migrate on it but this issue blocks me
You can change the selector in the settings though. Maybe "source.ruby, text.haml".
Sorry, my mistake. If I set selector
it makes worsen:
{
...
"linters": {
"rubocop": {
...
"selector": "source.ruby, text.haml"
}
}
}
show.html.haml:
1:1 error rubocop:E Lint/Syntax: %div: unknown type of percent-literal (Using Ruby 2.6 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
1:6 error rubocop:E Lint/Syntax: unexpected token tSTRING_CONTENT (Using Ruby 2.6 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
2:3 error rubocop:E Lint/Syntax: %div: unknown type of percent-literal (Using Ruby 2.6 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
...
I reread your initial post. On the command line you tell it to lint the haml file but it reports 0 files inspected. So it basically ignores the file.
Probably worth it to look at the rubocop repo and even open an issue if this is somehow possible.
In command-line Rubocop returns 0 errors but SublimeLinter returns 2
Yeah sure, but it looks like it actually ignores the file. For that, you could set "exclude" to maybe "*.haml" in the settings.
The question is if we can somehow lint haml files.
If Rubocop ignores this file then what has generated these errors ruby: error syntax error - unexpected end-of-input, expecting then or ';' or '\n'
?
The default selector explicitly extracts parts of the haml file, the Ruby parts, and sends them separately to rubocop. It does not send the whole file. I don't know if that makes a lot of sense but it's how it's done here. Maybe a selector "source.ruby - text.haml source.ruby" was actually intended although I'm not 100% sure about the selector semantics from top of my head.
My current config SublimeLinter.sublime-settings
:
{
"debug": true,
"styles": [
{
"mark_style": "stippled_underline",
"priority": 1,
"scope": "source.ruby.rails keyword.control.ruby",
"icon": "pointer",
"types": [
"warning"
]
}
],
"linters": {
"rubocop": {
"use_bundle_exec": true,
"executable": "/Users/palexvs/.rbenv/shims/rubocop",
"selector": "source.ruby - text.haml source.ruby"
}
}
}
But still see
I have installed SublimeLinter-haml-lint
but see no changes.
Adding "excludes": "*/*.html.haml"
has haleped to suppress wrong errors from Ruby and Rubocop. But haml-lint
does not work still
Current config:
{
"debug": true,
"styles": [
{
"mark_style": "stippled_underline",
"priority": 1,
"scope": "source.ruby.rails keyword.control.ruby",
"icon": "pointer",
"types": [
"warning"
]
}
],
"linters": {
"rubocop": {
"use_bundle_exec": true,
"executable": "/Users/palexvs/.rbenv/shims/rubocop",
"selector": "source.ruby",
"excludes": "*/*.html.haml"
},
"ruby": {
"use_bundle_exec": true,
"executable": "/Users/palexvs/.rbenv/shims/rubocop",
"selector": "source.ruby",
"excludes": "*/*.html.haml"
}
}
}
+1
I tried this with @palexvs config above but am still seeing the errors
Well, generally the selector
we ship should already exclude haml files as it is source.ruby - text.html - text.haml
. That is with the default Ruby HAML syntax shipping with Sublime Text which is the only thing I have.
@palexvs overrides this selector which is probably not what you want. Also the excludes
value sets *.html.haml
which is a bit idiosyncratic. Maybe you use a different file extension, like just *.haml
?
I created a simple correct test HAML file in my rails project
test.html.haml
:but SublimeLinter highlights errors:![image](https://user-images.githubusercontent.com/1415597/85899667-41408d80-b7b3-11ea-8311-c0dc757a9ad3.png)
My config file:
If I run Rubocop manually I get no errors: