Skip to content

Commit

Permalink
Update for luacheck >= 0.11.0
Browse files Browse the repository at this point in the history
* Remove 'channel' from default ignore list.
* Remove SublimeLinter inline options, use luacheck inline options.
* Use `--ranges` to highlight tokens correctly.
* Use `--codes` to distinguish warnings from errors.
* Use `--filename` to apply per-path config overrides correctly.
* Add version requirement.
  • Loading branch information
mpeterv authored and groteworld committed Jan 30, 2017
1 parent 1501b7d commit 8d0c87b
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Copyright (c) 2015-2017 The SublimeLinter Community
# Copyright (c) 2014 CorvisaCloud, LLC
#
# License: MIT
Expand All @@ -16,30 +17,21 @@ class Luacheck(Linter):
"""Provides an interface to luacheck."""

syntax = 'lua'
tempfile_suffix = 'lua'
defaults = {
'--ignore:,': ['channel'],
'--only:,': [],
'--limit=': None,
'--globals:,': [],
}
comment_re = r'\s*--'
inline_settings = 'limit'
inline_overrides = ('ignore', 'only', 'globals')
config_file = ('--config', '.luacheckrc', '~')
cmd = 'luacheck @ *'
regex = r'^(?P<filename>.+):(?P<line>\d+):(?P<col>\d+): (?P<message>.*)$'

def build_args(self, settings):
"""Return args, transforming --ignore, --only, and --globals args into a format luacheck understands."""
args = super().build_args(settings)

for arg in ('--ignore', '--only', '--globals'):
try:
index = args.index(arg)
values = args[index + 1].split(',')
args[index + 1:index + 2] = values
except ValueError:
pass

return args
cmd = 'luacheck - --formatter=plain --codes --ranges --filename @'

version_args = '--help'
version_re = r'[Ll]uacheck (?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 0.11.0, < 1.0.0'

regex = (
r'^.+:(?P<line>\d+):(?P<col>\d+)\-(?P<col_end>\d+): '
r'\((?:(?P<error>E)|(?P<warning>W))\d+\) '
r'(?P<message>.+)'
)

def split_match(self, match):
"""Patch regex matches to highlight token correctly."""
match, line, col, error, warning, msg, _ = super().split_match(match)
col_end = int(match.group(3))
token_len = col_end - col
return match, line, col, error, warning, msg, "." * token_len

2 comments on commit 8d0c87b

@landoncope
Copy link

@landoncope landoncope commented on 8d0c87b Feb 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Remove SublimeLinter inline options, use luacheck inline options."

Can you explain what this entails?

@mpeterv
Copy link
Contributor Author

@mpeterv mpeterv commented on 8d0c87b Feb 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@landoncope instead of a sublimelinter-specific config and inline options, use luacheck config and inline options.

Please sign in to comment.