All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Jose Soto <jose@tighten.co>
3 " Description: Tighten Opinionated PHP Linting
4 " Website: https://github.com/tightenco/tlint
6 call ale#Set('php_tlint_executable', 'tlint')
7 call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0))
8 call ale#Set('php_tlint_options', '')
10 function! ale_linters#php#tlint#GetProjectRoot(buffer) abort
11 let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json')
13 if !empty(l:composer_path)
14 return fnamemodify(l:composer_path, ':h')
17 let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
19 return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
22 function! ale_linters#php#tlint#GetExecutable(buffer) abort
23 return ale#path#FindExecutable(a:buffer, 'php_tlint', [
29 function! ale_linters#php#tlint#GetCommand(buffer) abort
30 let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer)
31 let l:options = ale#Var(a:buffer, 'php_tlint_options')
33 return ale#node#Executable(a:buffer, l:executable)
34 \ . (!empty(l:options) ? ' ' . l:options : '')
38 function! ale_linters#php#tlint#Handle(buffer, lines) abort
39 " Matches against lines like the following:
41 " ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.`
42 " 22 : ` $something = 'a'.'name';`
45 let l:messages_pattern = '^\! \(.*\)'
47 let l:pattern = '^\(\d\+\) \:'
48 let l:temp_messages = []
50 for l:message in ale#util#GetMatches(a:lines, l:messages_pattern)
51 call add(l:temp_messages, l:message)
56 for l:match in ale#util#GetMatches(a:lines, l:pattern)
57 let l:num = l:match[1]
58 let l:text = l:temp_messages[l:loop_count]
65 \ 'sub_type': 'style',
74 call ale#linter#Define('php', {
76 \ 'executable': function('ale_linters#php#tlint#GetExecutable'),
77 \ 'command': function('ale_linters#php#tlint#GetCommand'),
78 \ 'callback': 'ale_linters#php#tlint#Handle',
79 \ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'),