Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
|
0c6370f41a | ||
|
0ed3fbc596 | ||
|
b315667ebe | ||
|
0495a8be20 | ||
|
6ef54842de | ||
|
df76d8a51c |
14 changed files with 110 additions and 25 deletions
|
@ -1,9 +1,15 @@
|
||||||
" Author: Michiel Westerbeek <happylinks@gmail.com>
|
" Author: Michiel Westerbeek <happylinks@gmail.com>
|
||||||
" Description: Linter for GraphQL Schemas
|
" Description: Linter for GraphQL Schemas
|
||||||
|
|
||||||
|
function! ale_linters#graphql#gqlint#GetCommand(buffer) abort
|
||||||
|
return ale#path#BufferCdString(a:buffer)
|
||||||
|
\ . 'gqlint'
|
||||||
|
\ . ' --reporter=simple %t'
|
||||||
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('graphql', {
|
call ale#linter#Define('graphql', {
|
||||||
\ 'name': 'gqlint',
|
\ 'name': 'gqlint',
|
||||||
\ 'executable': 'gqlint',
|
\ 'executable': 'gqlint',
|
||||||
\ 'command': 'gqlint --reporter=simple %t',
|
\ 'command_callback': 'ale_linters#graphql#gqlint#GetCommand',
|
||||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||||
\})
|
\})
|
||||||
|
|
|
@ -9,26 +9,20 @@ function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort
|
||||||
|
|
||||||
" If it's empty, search for the cabal file
|
" If it's empty, search for the cabal file
|
||||||
if empty(l:project_file)
|
if empty(l:project_file)
|
||||||
let l:cabal_file = fnamemodify(bufname(a:buffer), ':p:h')
|
" Search all of the paths except for the root filesystem path.
|
||||||
let l:paths = ''
|
let l:paths = join(
|
||||||
|
\ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2],
|
||||||
while empty(matchstr(l:cabal_file, '^\(\/\|\(\w:\\\)\)$'))
|
\ ','
|
||||||
let l:cabal_file = fnamemodify(l:cabal_file, ':h')
|
\)
|
||||||
let l:paths = l:paths . l:cabal_file . ','
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let l:project_file = globpath(l:paths, '*.cabal')
|
let l:project_file = globpath(l:paths, '*.cabal')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Either extract the project directory or take the current working
|
" If we still can't find one, use the current file.
|
||||||
" directory
|
if empty(l:project_file)
|
||||||
if !empty(l:project_file)
|
let l:project_file = expand('#' . a:buffer . ':p')
|
||||||
let l:project_file = fnamemodify(l:project_file, ':h')
|
|
||||||
else
|
|
||||||
let l:project_file = expand('#' . a:buffer . ':p:h')
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return l:project_file
|
return fnamemodify(l:project_file, ':h')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#haskell#hie#GetCommand(buffer) abort
|
function! ale_linters#haskell#hie#GetCommand(buffer) abort
|
||||||
|
|
|
@ -155,7 +155,8 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
||||||
\}
|
\}
|
||||||
|
|
||||||
if has_key(l:error, 'extra')
|
if has_key(l:error, 'extra')
|
||||||
let l:errorToAdd.detail = s:GetDetails(l:error)
|
let l:errorToAdd.detail = l:errorToAdd.text
|
||||||
|
\ . "\n" . s:GetDetails(l:error)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:output, l:errorToAdd)
|
call add(l:output, l:errorToAdd)
|
||||||
|
|
|
@ -9,7 +9,7 @@ endfunction
|
||||||
call ale#linter#Define('scala', {
|
call ale#linter#Define('scala', {
|
||||||
\ 'name': 'scalac',
|
\ 'name': 'scalac',
|
||||||
\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'},
|
\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'},
|
||||||
\ 'command': '%e -Ystop-before:jvm %t',
|
\ 'command': '%e -Ystop-after:parser %t',
|
||||||
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
|
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
|
||||||
\ 'output_stream': 'stderr',
|
\ 'output_stream': 'stderr',
|
||||||
\})
|
\})
|
||||||
|
|
|
@ -8,20 +8,26 @@ function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
|
||||||
"
|
"
|
||||||
" "book.tex", line 37: possible unwanted space at "{"
|
" "book.tex", line 37: possible unwanted space at "{"
|
||||||
" "book.tex", line 38: missing `\ ' after "etc."
|
" "book.tex", line 38: missing `\ ' after "etc."
|
||||||
let l:pattern = '^".\+", line \(\d\+\): \(.\+\)$'
|
let l:pattern = '^"\(.\+\)", line \(\d\+\): \(.\+\)$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
" lacheck follows `\input{}` commands. If the cwd is not the same as the
|
" lacheck follows `\input{}` commands. If the cwd is not the same as the
|
||||||
" file in the buffer then it will fail to find the inputed items. We do not
|
" file in the buffer then it will fail to find the inputed items. We do not
|
||||||
" want warnings from those items anyway
|
" want warnings from those items anyway
|
||||||
if !empty(matchstr(l:match[2], '^Could not open ".\+"$'))
|
if !empty(matchstr(l:match[3], '^Could not open ".\+"$'))
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
" lacheck follows `\input{}` commands. We are only interested in
|
||||||
|
" reporting errors for the current buffer only.
|
||||||
|
if empty(matchstr(fnamemodify(l:match[1], ':t'), fnamemodify(bufname(a:buffer), ':t')))
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'text': l:match[2],
|
\ 'text': l:match[3],
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\})
|
\})
|
||||||
endfor
|
endfor
|
||||||
|
|
|
@ -121,7 +121,7 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort
|
||||||
let l:text = l:match[3]
|
let l:text = l:match[3]
|
||||||
|
|
||||||
if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore')
|
if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore')
|
||||||
if l:text is# 'File ignored because of a matching ignore pattern. Use "--no-ignore" to override.'
|
if l:text =~# '^File ignored'
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('graphql', 'gqlint')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(The linter should run from the directory of the file in the buffer):
|
||||||
|
AssertLinter 'gqlint',
|
||||||
|
\ ale#path#CdString(expand('%:p:h'))
|
||||||
|
\ . 'gqlint --reporter=simple'
|
||||||
|
\ . ' %t'
|
|
@ -6,7 +6,7 @@ After:
|
||||||
|
|
||||||
Given scala(An empty Scala file):
|
Given scala(An empty Scala file):
|
||||||
Execute(The default executable and command should be correct):
|
Execute(The default executable and command should be correct):
|
||||||
AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-before:jvm %t'
|
AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-after:parser %t'
|
||||||
|
|
||||||
Given scala.sbt(An empty SBT file):
|
Given scala.sbt(An empty SBT file):
|
||||||
Execute(scalac should not be run for sbt files):
|
Execute(scalac should not be run for sbt files):
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
Before:
|
||||||
|
call ale#assert#SetUpLinterTest('tex', 'lacheck')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
|
Execute(Executable should default to lacheck):
|
||||||
|
AssertLinter 'lacheck', ale#Escape('lacheck') . ' %t'
|
||||||
|
|
||||||
|
Execute(Should be able to set a custom executable):
|
||||||
|
let g:ale_tex_lacheck_executable = 'bin/foo'
|
||||||
|
|
||||||
|
AssertLinter 'bin/foo' , ale#Escape('bin/foo') . ' %t'
|
0
test/command_callback/tex_paths/sample1.tex
Normal file
0
test/command_callback/tex_paths/sample1.tex
Normal file
0
test/command_callback/tex_paths/sample2.tex
Normal file
0
test/command_callback/tex_paths/sample2.tex
Normal file
|
@ -342,6 +342,17 @@ Execute(eslint should warn about ignored files by default):
|
||||||
\ '/path/to/some/ignored.js:0:0: File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]',
|
\ '/path/to/some/ignored.js:0:0: File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [{
|
||||||
|
\ 'lnum': 0,
|
||||||
|
\ 'col': 0,
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ 'text': 'File ignored by default. Use "--ignore-pattern ''!node_modules/*''" to override.',
|
||||||
|
\ }],
|
||||||
|
\ ale#handlers#eslint#Handle(bufnr(''), [
|
||||||
|
\ '/path/to/some/ignored.js:0:0: File ignored by default. Use "--ignore-pattern ''!node_modules/*''" to override. [Warning]',
|
||||||
|
\ ])
|
||||||
|
|
||||||
Execute(eslint should not warn about ignored files when explicitly disabled):
|
Execute(eslint should not warn about ignored files when explicitly disabled):
|
||||||
let g:ale_javascript_eslint_suppress_eslintignore = 1
|
let g:ale_javascript_eslint_suppress_eslintignore = 1
|
||||||
|
|
||||||
|
@ -351,6 +362,12 @@ Execute(eslint should not warn about ignored files when explicitly disabled):
|
||||||
\ '/path/to/some/ignored.js:0:0: File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]',
|
\ '/path/to/some/ignored.js:0:0: File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale#handlers#eslint#Handle(bufnr(''), [
|
||||||
|
\ '/path/to/some/ignored.js:0:0: File ignored by default. Use "--ignore-pattern ''!node_modules/*''" to override. [Warning]',
|
||||||
|
\ ])
|
||||||
|
|
||||||
Execute(eslint should handle react errors correctly):
|
Execute(eslint should handle react errors correctly):
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
|
|
|
@ -499,7 +499,8 @@ Execute(The flow handler should handle extra errors):
|
||||||
\ 'col': 35,
|
\ 'col': 35,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'text': 'props of React element `New`: This type is incompatible with object type',
|
\ 'text': 'props of React element `New`: This type is incompatible with object type',
|
||||||
\ 'detail': 'Property `setVector` is incompatible: number This type is incompatible with function type ',
|
\ 'detail': 'props of React element `New`: This type is incompatible with object type'
|
||||||
|
\ . "\nProperty `setVector` is incompatible: number This type is incompatible with function type ",
|
||||||
\ }
|
\ }
|
||||||
\]
|
\]
|
||||||
|
|
||||||
|
|
36
test/handler/test_lacheck_handler.vader
Normal file
36
test/handler/test_lacheck_handler.vader
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
Before:
|
||||||
|
runtime ale_linters/tex/lacheck.vim
|
||||||
|
call ale#test#SetDirectory('/testplugin/test')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#linter#Reset()
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(The lacheck handler should parse lines correctly):
|
||||||
|
|
||||||
|
call ale#test#SetFilename('command_callback/tex_paths/sample1.tex')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ 'text': 'perhaps you should insert a `~'' before "\ref"'
|
||||||
|
\ }
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#tex#lacheck#Handle(bufnr(''), [
|
||||||
|
\ "** sample1:",
|
||||||
|
\ "\"sample1.tex\", line 1: perhaps you should insert a `~' before \"\\ref\""
|
||||||
|
\ ])
|
||||||
|
|
||||||
|
Execute(The lacheck handler should ignore errors from input files):
|
||||||
|
|
||||||
|
call ale#test#SetFilename('ale_test.tex')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#tex#lacheck#Handle(255, [
|
||||||
|
\ "** ale_input:",
|
||||||
|
\ "\"ale_input.tex\", line 1: perhaps you should insert a `~' before \"\\ref\""
|
||||||
|
\ ])
|
Reference in a new issue