13
votes

I'm using Vim with the syntastic plugin and eslint.

When I save a JavaScript file, I can see errors come up just fine, but I can't get the warnings to show.

Here's what I have in my .vimrc:

let g:syntastic_javascript_checkers = ['eslint']

I installed eslint with:

npm install eslint -g

I'm running Linux Mint 17

How do I get warnings to appear?

2
Eslint reports warnings by default unless you use --quiet. Do you a .eslintrc file? - romainl
I do not see warnings with or without an .eslintrc file - Jonathan.Brink
What happens when you run eslint directly in your shell? - romainl
Thanks, I wasn't aware you could run it from the command line. Running "eslint /path/to/file.js" it returns the same results as I see in Vim...only errors, no warnings (even though I know the code has warnings...such as the "curly" rule) - Jonathan.Brink
OK. That's an eslint issue. Try their issue tracker or ask another question here without the vim tag and with a short code sample. - romainl

2 Answers

11
votes

It turns out the issue here was that the "warnings" I thought I had in my file were not actually warnings. When I put an actual warning in my file it showed up correctly.

Some advice I learned though was to first run the file on the command-line directly using eslint similar to this:

eslint /path/to/file.js

Then compare those results to what you see in Vim.

Another tip is that you can change rules on the fly with comment syntax like this:

/*eslint <rule>=1*/
8
votes

I really don't know if it will help you, but I will put it here. I had a similar problem but in my case it was related to the version of syntastic, so a simple git pull solved it. My vim configuration is somewhat canonical, so I will share that:

let g:syntastic_mode_map = { 'mode': 'active',
                            \ 'active_filetypes': ['python', 'javascript'],
                            \ 'passive_filetypes': [] }

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

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
let g:syntastic_javascript_checkers = ['eslint']

When you open your file that contains some mistakes, it should show that into the error window.