Reputation: 8374
I have installed syntastic plugin in vim and installed eslint in npm globally. Below is the snippet of my .vimrc for syntastic configuration:
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_javascript_checkers = ["eslint"]
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
Here's the result when I run :SyntasticInfo javascript,
Syntastic version: 3.6.0-64 (Vim 704, CYGWIN_NT-6.3)
Info for filetype: javascript
Global mode: active
Filetype javascript is active
Available checker: eslint
Currently enabled checker: eslint
Assume I have following project structure, there're some custom rules activated in .eslintrc
, and the definition of those rules are in .eslintrules
dir:
xxx_project:
|--.eslintrc
|--.eslintrules
|-- rule1.js
|-- rule2.js
|-- ...
|-- src
|-- abc.js
Everytime I run :SyntasticCheck on some source file, nothing happens. So I try running eslint against some js file directly in command line. There're some errors threw indicating cannot find definition of some custom rules.
So I think eslint has found the configuration file, but it doesn't know where the --rulesdir is.
Can someone help here? As far as I know, the --rulesdir option is only available in command line.
Upvotes: 5
Views: 1707
Reputation: 5851
Edit:
function! ESLintArgs()
let rules = findfile('.eslintrules', '.;')
return rules != '' ? '--rulesdir ' . shellescape(fnamemodify(rules, ':p:h')) : ''
endfunction
autocmd FileType javascript let b:syntastic_javascript_eslint_args = ESLintArgs()
This tries to find a file named .eslintrules
and sets --ruledir
to its base directory.
Upvotes: 6