-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi!
I made a slightly improved erb linter, here's the py file:
import json
import re
from SublimeLinter.lint import util, Linter, LintMatch
class ERBLint(Linter):
cmd = 'bundle exec erblint ${args} -f json ${temp_file}'
regex = None
multiline = True
tempfile_suffix = 'erb'
error_stream = util.STREAM_STDOUT
defaults = {
'selector': 'text.html.ruby, text.html.rails'
}
def get_code_and_message(self, s):
return re.match(r'^(?:(?P<code>\w+\/\w+):\s)?(?P<message>.*)$', s)
def find_errors(self, output):
content = json.loads(output)
for entry in content['files']:
if not entry['offenses']:
continue
for offense in entry['offenses']:
match = self.get_code_and_message(offense['message'])
yield LintMatch(
match=offense,
line=offense['location']['start_line'] - 1,
col=offense['location']['start_column'],
end_line=offense['location']['last_line'] - 1,
end_col=offense['location']['last_column'],
error_type='warning',
code=match.group('code'),
message=match.group('message')
)This has the following improvements over the current linter:
- More specific highlights within each line
- Separates rubocop's prefixes as "code" from the message
- Adds selector
text.html.rails - Uses
bundle exec(but probably should be made optional)
It's been working well for me so far, so decided to share.
If you want to use it, create a dir under your Sublime's "Packages" dir, like Packages/sublimelinter-custom-erblint, throw this file (name it linter.py), and if you have SublimeLinter installed, this should immediately start working.
Hopefully this will make its way into SublimeLinter-contrib-erblint eventually.
Metadata
Metadata
Assignees
Labels
No labels