13

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?

Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
  • 2
    Eslint reports warnings by default unless you use `--quiet`. Do you a `.eslintrc` file? – romainl Dec 23 '14 at 20:38
  • I do not see warnings with or without an .eslintrc file – Jonathan.Brink Dec 23 '14 at 21:04
  • 2
    What happens when you run eslint directly in your shell? – romainl Dec 23 '14 at 21:18
  • 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 Dec 24 '14 at 01:16
  • 3
    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 Dec 24 '14 at 08:20
  • Thanks for the help with this. Turns out the rules for the code I was running were meant to be errors. When I add the JavaScript comment /*eslint =1*/ I'm seeing the warnings now, on the command line as well as in vim. – Jonathan.Brink Dec 24 '14 at 13:59

2 Answers2

11

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*/
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
8

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.

ruhanbidart
  • 4,564
  • 1
  • 26
  • 13