-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathlinter.py
25 lines (22 loc) · 872 Bytes
/
linter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json
from SublimeLinter.lint import LintMatch, ComposerLinter
class Phpcs(ComposerLinter):
cmd = ('phpcs', '--report=json', '${args}', '-')
defaults = {
'selector': 'embedding.php, source.php - text.blade',
# we want auto-substitution of the filename,
# but `cmd` does not support that yet
'--stdin-path=': '${file}'
}
def find_errors(self, output):
data = json.loads(output)
for file_path, file_data in data["files"].items():
for error in file_data['messages']:
yield LintMatch(
filename=file_path,
line=error['line'] - 1,
col=error['column'] - 1,
error_type=error['type'].lower(),
code=error['source'],
message=error['message'],
)