Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit c04603e

Browse files
committed
New checker for JavaScript and TypeScript: lynt.
1 parent 89e485c commit c04603e

File tree

5 files changed

+166
-10
lines changed

5 files changed

+166
-10
lines changed

autoload/syntastic/preprocess.vim

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,44 @@ function! syntastic#preprocess#killEmpty(errors) abort " {{{2
251251
return filter(copy(a:errors), 'v:val !=# ""')
252252
endfunction " }}}2
253253

254+
function! syntastic#preprocess#lynt(errors) abort " {{{2
255+
let errs = join(a:errors, '')
256+
if errs ==# ''
257+
return []
258+
endif
259+
260+
let json = s:_decode_JSON(errs)
261+
262+
let out = []
263+
if type(json) == type([])
264+
for err in json
265+
if type(err) == type({}) && type(get(err, 'filePath')) == type('') && type(get(err, 'errors')) == type([])
266+
let fname = get(err, 'filePath')
267+
268+
for e in get(err, 'errors')
269+
if type(e) == type({})
270+
try
271+
let line = e['line']
272+
let col = e['column']
273+
let ecol = line == get(e, 'endLine') ? get(e, 'endColumn') : 0
274+
let msg = e['message'] . ' [' . e['ruleName'] . ']'
275+
276+
cal add(out, join([fname, line, col, ecol, msg], ':'))
277+
catch /\m^Vim\%((\a\+)\)\=:E716/
278+
call syntastic#log#warn('checker javascript/lynt: unrecognized error item ' . string(e))
279+
endtry
280+
else
281+
call syntastic#log#warn('checker javascript/lynt unrecognized error item ' . string(e))
282+
endif
283+
endfor
284+
endif
285+
endfor
286+
else
287+
call syntastic#log#warn('checker javascript/lynt unrecognized error format (crashed checker?)')
288+
endif
289+
return out
290+
endfunction " }}}2
291+
254292
function! syntastic#preprocess#perl(errors) abort " {{{2
255293
let out = []
256294

doc/syntastic-checkers.txt

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,9 +3408,10 @@ The following checkers are available for JavaScript (filetype "javascript"):
34083408
7. JSHint...................|syntastic-javascript-jshint|
34093409
8. JSLint...................|syntastic-javascript-jslint|
34103410
9. JSXHint..................|syntastic-javascript-jsxhint|
3411-
10. mixedindentlint.........|syntastic-javascript-mixedindentlint|
3412-
11. standard................|syntastic-javascript-standard|
3413-
12. tern-lint...............|syntastic-javascript-tern_lint|
3411+
10. Lynt....................|syntastic-javascript-lynt|
3412+
11. mixedindentlint.........|syntastic-javascript-mixedindentlint|
3413+
12. standard................|syntastic-javascript-standard|
3414+
13. tern-lint...............|syntastic-javascript-tern_lint|
34143415

34153416
------------------------------------------------------------------------------
34163417
1. Closure Compiler *syntastic-javascript-closurecompiler*
@@ -3640,7 +3641,7 @@ syntastic to call "JSLint" with no options.
36403641
------------------------------------------------------------------------------
36413642
9. JSXHint *syntastic-javascript-jsxhint*
36423643

3643-
Name: JSXHint
3644+
Name: jsxhint
36443645
Maintainer: Thomas Boyt <me@thomasboyt.com>
36453646

36463647
"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
37063707
https://github.com/jaxbot/syntastic-react
37073708

37083709
------------------------------------------------------------------------------
3709-
10. mixedindentlint *syntastic-javascript-mixedindentlint*
3710+
10. Lynt *syntastic-javascript-lynt*
3711+
3712+
Name: lynt
3713+
Maintainer: LCD 47 <lcd047@gmail.com>
3714+
3715+
"Lynt" is a JavaScript linter with support for TypeScript, Flow, and React.
3716+
See the project's page for more information:
3717+
3718+
https://github.com/saadq/lynt
3719+
3720+
Checker options~
3721+
3722+
This checker is initialised using the "makeprgBuild()" function and thus it
3723+
accepts the standard options described at |syntastic-config-makeprg|.
3724+
3725+
Note~
3726+
3727+
Automatically fixing errors (option "--fix") is not supported.
3728+
3729+
See also: |syntastic-typescript-lynt|.
3730+
3731+
------------------------------------------------------------------------------
3732+
11. mixedindentlint *syntastic-javascript-mixedindentlint*
37103733

37113734
Name: mixedindentlint
37123735
Maintainer: Payton Swick <payton@foolord.com>
@@ -3724,7 +3747,7 @@ accepts the standard options described at |syntastic-config-makeprg|.
37243747
See also: |syntastic-css-mixedindentlint|, |syntastic-scss-mixedindentlint|.
37253748

37263749
------------------------------------------------------------------------------
3727-
11. standard *syntastic-javascript-standard*
3750+
12. standard *syntastic-javascript-standard*
37283751

37293752
Name: standard
37303753
Maintainer: LCD 47 <lcd047@gmail.com>
@@ -3758,7 +3781,7 @@ example to use happiness (https://github.com/JedWatson/happiness) instead of
37583781
let g:syntastic_javascript_standard_generic = 1
37593782
<
37603783
------------------------------------------------------------------------------
3761-
12. tern-lint *syntastic-javascript-tern_lint*
3784+
13. tern-lint *syntastic-javascript-tern_lint*
37623785

37633786
Name: tern_lint
37643787
Maintainer: LCD 47 <lcd047@gmail.com>
@@ -6913,7 +6936,8 @@ SYNTAX CHECKERS FOR TYPESCRIPT *syntastic-checkers-typescript*
69136936
The following checkers are available for TypeScript (filetype "typescript"):
69146937

69156938
1. ESLint...................|syntastic-typescript-eslint|
6916-
2. TSLint...................|syntastic-typescript-tslint|
6939+
2. Lynt.....................|syntastic-typescript-lynt|
6940+
3. TSLint...................|syntastic-typescript-tslint|
69176941

69186942
------------------------------------------------------------------------------
69196943
1. ESLint *syntastic-typescript-eslint*
@@ -6944,7 +6968,29 @@ See also: |syntastic-html-eslint|, |syntastic-javascript-eslint|,
69446968
|syntastic-vue-eslint|.
69456969

69466970
------------------------------------------------------------------------------
6947-
2. TSLint *syntastic-typescript-tslint*
6971+
2. Lynt *syntastic-typescript-lynt*
6972+
6973+
Name: lynt
6974+
Maintainer: LCD 47 <lcd047@gmail.com>
6975+
6976+
"Lynt" is a JavaScript linter with support for TypeScript, Flow, and React.
6977+
See the project's page for more information:
6978+
6979+
https://github.com/saadq/lynt
6980+
6981+
Checker options~
6982+
6983+
This checker is initialised using the "makeprgBuild()" function and thus it
6984+
accepts the standard options described at |syntastic-config-makeprg|.
6985+
6986+
Note~
6987+
6988+
Automatically fixing errors (option "--fix") is not supported.
6989+
6990+
See also: |syntastic-javascript-lynt|.
6991+
6992+
------------------------------------------------------------------------------
6993+
3. TSLint *syntastic-typescript-tslint*
69486994

69496995
Name: tslint
69506996
Maintainer: Seon-Wook Park <seon.wook@swook.net>

plugin/syntastic.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if has('reltime')
1919
lockvar! g:_SYNTASTIC_START
2020
endif
2121

22-
let g:_SYNTASTIC_VERSION = '3.9.0-19'
22+
let g:_SYNTASTIC_VERSION = '3.9.0-20'
2323
lockvar g:_SYNTASTIC_VERSION
2424

2525
" Sanity checks {{{1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"============================================================================
2+
"File: lynt.vim
3+
"Description: Syntax checking plugin for syntastic
4+
"Maintainer: LCD 47 <lcd047@gmail.com>
5+
"License: This program is free software. It comes without any warranty,
6+
" to the extent permitted by applicable law. You can redistribute
7+
" it and/or modify it under the terms of the Do What The Fuck You
8+
" Want To Public License, Version 2, as published by Sam Hocevar.
9+
" See http://sam.zoy.org/wtfpl/COPYING for more details.
10+
"============================================================================
11+
12+
if exists('g:loaded_syntastic_javascript_lynt_checker')
13+
finish
14+
endif
15+
let g:loaded_syntastic_javascript_lynt_checker = 1
16+
17+
let s:save_cpo = &cpo
18+
set cpo&vim
19+
20+
function! SyntaxCheckers_javascript_lynt_GetLocList() dict
21+
let makeprg = self.makeprgBuild({ 'args_after': '--json' })
22+
23+
let errorformat = '%f:%l:%c:%n:%m'
24+
25+
let loclist = SyntasticMake({
26+
\ 'makeprg': makeprg,
27+
\ 'errorformat': errorformat,
28+
\ 'preprocess': 'lynt',
29+
\ 'defaults': {'type': 'E'},
30+
\ 'returns': [0, 1] })
31+
32+
for e in loclist
33+
if get(e, 'col', 0) && get(e, 'nr', 0)
34+
let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['nr']) . 'c'
35+
let e['nr'] = 0
36+
endif
37+
endfor
38+
39+
return loclist
40+
endfunction
41+
42+
call g:SyntasticRegistry.CreateAndRegisterChecker({
43+
\ 'filetype': 'javascript',
44+
\ 'name': 'lynt'})
45+
46+
let &cpo = s:save_cpo
47+
unlet s:save_cpo
48+
49+
" vim: set sw=4 sts=4 et fdm=marker:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"============================================================================
2+
"File: lynt.vim
3+
"Description: Syntax checking plugin for syntastic
4+
"Maintainer: LCD 47 <lcd047 at gmail dot com>
5+
"License: This program is free software. It comes without any warranty,
6+
" to the extent permitted by applicable law. You can redistribute
7+
" it and/or modify it under the terms of the Do What The Fuck You
8+
" Want To Public License, Version 2, as published by Sam Hocevar.
9+
" See http://sam.zoy.org/wtfpl/COPYING for more details.
10+
"
11+
"============================================================================
12+
13+
if exists('g:loaded_syntastic_typescript_lynt_checker')
14+
finish
15+
endif
16+
let g:loaded_syntastic_typescript_lynt_checker = 1
17+
18+
call g:SyntasticRegistry.CreateAndRegisterChecker({
19+
\ 'filetype': 'typescript',
20+
\ 'name': 'lynt',
21+
\ 'redirect': 'javascript/lynt'})
22+
23+
" vim: set sw=4 sts=4 et fdm=marker:

0 commit comments

Comments
 (0)