24

I love syntastic for javascript but I am using the new ES6 module tranpiler and syntastic is not happy about these type of statements:

import Typeahead from './lib/components/ember-typeahead';

Is there anyway that I can keep syntastic quiet about this type of statement?

gnerkus
  • 11,357
  • 6
  • 47
  • 71
dagda1
  • 26,856
  • 59
  • 237
  • 450

2 Answers2

61

Syntastic will use JSHint to check JavaScript syntax if it's available (which I recommend over jslint).

JSHint supports es6 syntax with the esnext flag, which includes support for the export and import module syntax.

I suggest adding a .jshintrc file to your project to control JSHint's behavior (and thus Syntastic's) for your entire project:

{
  "esnext": true
}

Note: be careful, since using the esnext flag will add support for all of es6's new language sytax that JSHint currently supports, not just the module syntax.

Note: esnext has now been deprecated in favour of the esversion syntax.

{
  "esversion": 6
}
Guy
  • 10,931
  • 5
  • 36
  • 47
slindberg
  • 841
  • 10
  • 9
21

To work around this, I'd suggest the following steps as recommended here: Configure Vim for React:

Install eslint and babel-eslint:

npm install -g eslint babel-eslint

Create a local .eslintrc config in your project or a global ~/.eslintrc configuration:

{
    "parser": "babel-eslint",
    "env": {
        "browser": true,
        "node": true
    },
    "settings": {
        "ecmascript": 6
    },
    "rules": {
        "strict": 0 // you can add more rules if you want
    }
}

Finally, configure syntastic to use eslint:

let g:syntastic_javascript_checkers = ['eslint']
gnerkus
  • 11,357
  • 6
  • 47
  • 71
  • umm, all makes sense except for the last one.. where do you put `let g:syntastic_javascript_checkers = ['eslint']` ? sorry, bit of a newb in zed/syntastic – unsynchronized Jun 23 '16 at 14:20
  • 1
    in your .vimrc file which is normally located `~/.vimrc`. But you can have local .vimrc files too so could be elsewhere. – user115014 Jun 29 '16 at 15:50