error '_' is not defined no-undef

拜拜、爱过 提交于 2021-02-10 10:18:23

问题


I use eslint to check my code ,and a error happen -- "error '_' is not defined no-undef".

I write the code like this:

new webpack.ProvidePlugin({
    $: "jquery",//jquery
    jQuery: "jquery",
    "window.jQuery": "jquery",
    _:"lodash"//lodash
})

and get .eslintrc.js, part of it like this:

"env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "jquery":true,
},

before I add the jquery into ,it happen an error -- "error '_' is not defined no-undef". However, when I add lodash into ,just like that "'lodash':true".It doesn't work.

Can you help me?


回答1:


ESLint doesn't understand lodash library. you need to add a global section in your config.

"globals": { "_": true },



来源:https://stackoverflow.com/questions/45317154/error-is-not-defined-no-undef

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!