我使用webpack.DefinePlugin
注入全局常量作为我的构建管道的一部分。然而jshint抱怨常量“未定义”。
从我的webpack.config.js:
plugins: [
new webpack.DefinePlugin({
__ALEX__: JSON.stringify('alex.com')
}),
导致:
WARNING in ./src/Main.js
jshint results in errors
'__ALEX__' is not defined. @ line 12 char 30
lock: new Thing(__ALEX__)
在注入常量后让jshint查看代码的正确方法是什么?
将以下内容添加到.eslintrc
{
"globals": {
"__ALEX__": true
},
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true
}
}
没有添加parser
和parsterOptions
字段,我得到了奇怪的ECMA Script 16错误。