New checker for JavaScript and TypeScript: lynt.

This commit is contained in:
LCD 47 2018-11-02 18:14:47 +02:00
parent 89e485c7f8
commit c04603e1fd
5 changed files with 166 additions and 10 deletions

View File

@ -251,6 +251,44 @@ function! syntastic#preprocess#killEmpty(errors) abort " {{{2
return filter(copy(a:errors), 'v:val !=# ""') return filter(copy(a:errors), 'v:val !=# ""')
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#lynt(errors) abort " {{{2
let errs = join(a:errors, '')
if errs ==# ''
return []
endif
let json = s:_decode_JSON(errs)
let out = []
if type(json) == type([])
for err in json
if type(err) == type({}) && type(get(err, 'filePath')) == type('') && type(get(err, 'errors')) == type([])
let fname = get(err, 'filePath')
for e in get(err, 'errors')
if type(e) == type({})
try
let line = e['line']
let col = e['column']
let ecol = line == get(e, 'endLine') ? get(e, 'endColumn') : 0
let msg = e['message'] . ' [' . e['ruleName'] . ']'
cal add(out, join([fname, line, col, ecol, msg], ':'))
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker javascript/lynt: unrecognized error item ' . string(e))
endtry
else
call syntastic#log#warn('checker javascript/lynt unrecognized error item ' . string(e))
endif
endfor
endif
endfor
else
call syntastic#log#warn('checker javascript/lynt unrecognized error format (crashed checker?)')
endif
return out
endfunction " }}}2
function! syntastic#preprocess#perl(errors) abort " {{{2 function! syntastic#preprocess#perl(errors) abort " {{{2
let out = [] let out = []

View File

@ -3408,9 +3408,10 @@ The following checkers are available for JavaScript (filetype "javascript"):
7. JSHint...................|syntastic-javascript-jshint| 7. JSHint...................|syntastic-javascript-jshint|
8. JSLint...................|syntastic-javascript-jslint| 8. JSLint...................|syntastic-javascript-jslint|
9. JSXHint..................|syntastic-javascript-jsxhint| 9. JSXHint..................|syntastic-javascript-jsxhint|
10. mixedindentlint.........|syntastic-javascript-mixedindentlint| 10. Lynt....................|syntastic-javascript-lynt|
11. standard................|syntastic-javascript-standard| 11. mixedindentlint.........|syntastic-javascript-mixedindentlint|
12. tern-lint...............|syntastic-javascript-tern_lint| 12. standard................|syntastic-javascript-standard|
13. tern-lint...............|syntastic-javascript-tern_lint|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. Closure Compiler *syntastic-javascript-closurecompiler* 1. Closure Compiler *syntastic-javascript-closurecompiler*
@ -3640,7 +3641,7 @@ syntastic to call "JSLint" with no options.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
9. JSXHint *syntastic-javascript-jsxhint* 9. JSXHint *syntastic-javascript-jsxhint*
Name: JSXHint Name: jsxhint
Maintainer: Thomas Boyt <me@thomasboyt.com> Maintainer: Thomas Boyt <me@thomasboyt.com>
"JSXHint" is a wrapper around JSHint (http://jshint.com/) for "JSXHint" is a wrapper around JSHint (http://jshint.com/) for
@ -3706,7 +3707,29 @@ To get around this, "Syntastic-React" can be used as a replacement for
https://github.com/jaxbot/syntastic-react https://github.com/jaxbot/syntastic-react
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
10. mixedindentlint *syntastic-javascript-mixedindentlint* 10. Lynt *syntastic-javascript-lynt*
Name: lynt
Maintainer: LCD 47 <lcd047@gmail.com>
"Lynt" is a JavaScript linter with support for TypeScript, Flow, and React.
See the project's page for more information:
https://github.com/saadq/lynt
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
Note~
Automatically fixing errors (option "--fix") is not supported.
See also: |syntastic-typescript-lynt|.
------------------------------------------------------------------------------
11. mixedindentlint *syntastic-javascript-mixedindentlint*
Name: mixedindentlint Name: mixedindentlint
Maintainer: Payton Swick <payton@foolord.com> Maintainer: Payton Swick <payton@foolord.com>
@ -3724,7 +3747,7 @@ accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-css-mixedindentlint|, |syntastic-scss-mixedindentlint|. See also: |syntastic-css-mixedindentlint|, |syntastic-scss-mixedindentlint|.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
11. standard *syntastic-javascript-standard* 12. standard *syntastic-javascript-standard*
Name: standard Name: standard
Maintainer: LCD 47 <lcd047@gmail.com> Maintainer: LCD 47 <lcd047@gmail.com>
@ -3758,7 +3781,7 @@ example to use happiness (https://github.com/JedWatson/happiness) instead of
let g:syntastic_javascript_standard_generic = 1 let g:syntastic_javascript_standard_generic = 1
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
12. tern-lint *syntastic-javascript-tern_lint* 13. tern-lint *syntastic-javascript-tern_lint*
Name: tern_lint Name: tern_lint
Maintainer: LCD 47 <lcd047@gmail.com> Maintainer: LCD 47 <lcd047@gmail.com>
@ -6913,7 +6936,8 @@ SYNTAX CHECKERS FOR TYPESCRIPT *syntastic-checkers-typescript*
The following checkers are available for TypeScript (filetype "typescript"): The following checkers are available for TypeScript (filetype "typescript"):
1. ESLint...................|syntastic-typescript-eslint| 1. ESLint...................|syntastic-typescript-eslint|
2. TSLint...................|syntastic-typescript-tslint| 2. Lynt.....................|syntastic-typescript-lynt|
3. TSLint...................|syntastic-typescript-tslint|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1. ESLint *syntastic-typescript-eslint* 1. ESLint *syntastic-typescript-eslint*
@ -6944,7 +6968,29 @@ See also: |syntastic-html-eslint|, |syntastic-javascript-eslint|,
|syntastic-vue-eslint|. |syntastic-vue-eslint|.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
2. TSLint *syntastic-typescript-tslint* 2. Lynt *syntastic-typescript-lynt*
Name: lynt
Maintainer: LCD 47 <lcd047@gmail.com>
"Lynt" is a JavaScript linter with support for TypeScript, Flow, and React.
See the project's page for more information:
https://github.com/saadq/lynt
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
Note~
Automatically fixing errors (option "--fix") is not supported.
See also: |syntastic-javascript-lynt|.
------------------------------------------------------------------------------
3. TSLint *syntastic-typescript-tslint*
Name: tslint Name: tslint
Maintainer: Seon-Wook Park <seon.wook@swook.net> Maintainer: Seon-Wook Park <seon.wook@swook.net>

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.9.0-19' let g:_SYNTASTIC_VERSION = '3.9.0-20'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1

View File

@ -0,0 +1,49 @@
"============================================================================
"File: lynt.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047@gmail.com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"============================================================================
if exists('g:loaded_syntastic_javascript_lynt_checker')
finish
endif
let g:loaded_syntastic_javascript_lynt_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_javascript_lynt_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_after': '--json' })
let errorformat = '%f:%l:%c:%n:%m'
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'lynt',
\ 'defaults': {'type': 'E'},
\ 'returns': [0, 1] })
for e in loclist
if get(e, 'col', 0) && get(e, 'nr', 0)
let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['nr']) . 'c'
let e['nr'] = 0
endif
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'javascript',
\ 'name': 'lynt'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,23 @@
"============================================================================
"File: lynt.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_typescript_lynt_checker')
finish
endif
let g:loaded_syntastic_typescript_lynt_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'typescript',
\ 'name': 'lynt',
\ 'redirect': 'javascript/lynt'})
" vim: set sw=4 sts=4 et fdm=marker: