[英]syntastic complaining about ES6 module syntax
I love syntastic for javascript but I am using the new ES6 module tranpiler and syntastic is not happy about these type of statements: 我喜欢javascript的syntastic但是我使用的是新的ES6模块tranpiler ,而且我对这些类型的语句不满意:
import Typeahead from './lib/components/ember-typeahead';
Is there anyway that I can keep syntastic quiet about this type of statement? 无论如何,我可以保持这种声明的语法安静吗?
Syntastic will use JSHint to check JavaScript syntax if it's available (which I recommend over jslint). Syntastic将使用JSHint检查JavaScript语法( 如果它可用) (我推荐使用jslint)。
JSHint supports es6 syntax with the esnext
flag , which includes support for the export
and import
module syntax. JSHint支持带有
esnext
标志的es6语法,该标志包括对export
和import
模块语法的支持。
I suggest adding a .jshintrc
file to your project to control JSHint's behavior (and thus Syntastic's) for your entire project: 我建议在项目中添加一个
.jshintrc
文件来控制整个项目的JSHint行为(以及Syntastic):
{
"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. 注意:要小心,因为使用
esnext
标志将添加对JSHint当前支持的所有 es6的新语言sytax的支持,而不仅仅是模块语法。
Note : esnext
has now been deprecated in favour of the esversion
syntax. 注 :
esnext
现在赞成的被弃用esversion
语法。
{
"esversion": 6
}
To work around this, I'd suggest the following steps as recommended here: Configure Vim for React : 要解决此问题,我建议按照此处的建议执行以下步骤: 为React配置Vim :
Install eslint
and babel-eslint
: 安装
eslint
和babel-eslint
:
npm install -g eslint babel-eslint
Create a local .eslintrc
config in your project or a global ~/.eslintrc
configuration: 在项目中创建本地
.eslintrc
配置或全局~/.eslintrc
配置:
{
"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
: 最后,配置
syntastic
使用eslint
:
let g:syntastic_javascript_checkers = ['eslint']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.