Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

syntastic complaining about ES6 module syntax

Tags:

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?

like image 802
dagda1 Avatar asked Nov 23 '13 09:11

dagda1


People also ask

Does node support ES6 syntax?

Node js doesn't support ES6 import directly.

What is an ES6 module?

An ES6 module is a file containing JS code. There's no special module keyword; a module mostly reads just like a script. There are two differences. ES6 modules are automatically strict-mode code, even if you don't write "use strict"; in them. You can use import and export in modules.

How many parts are there in an ES6 module?

The ES6 module standard has two parts: Declarative syntax (for importing and exporting) Programmatic loader API: to configure how modules are loaded and to conditionally load modules.

How does JavaScript ES6 work?

A module is nothing more than a chunk of JavaScript code written in a file. By default, variables and functions of a module are not available for use. Variables and functions within a module should be exported so that they can be accessed from within other files. Modules in ES6 work only in strict mode.


1 Answers

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 } 
like image 124
slindberg Avatar answered Oct 18 '22 17:10

slindberg