我根据手册https://eslint.org/docs/user-guide/configuring#specifying-globals在编辑器中配置 eslint :
在我的配置中,它看起来像这样:
"eslint.enable": true,
"eslint.options": {
"globals": {
"$": true,
"moment": true
},
...
使用这些设置,VS Code 会抛出错误:
(options.globals || []).reduce is not a function
如何在 VS Code 中设置全局 eslint 配置?
事实证明,解决方案非常出乎意料,可以在这里找到https://github.com/eslint/eslint/pull/6922
那些。建议用数组替换全局设置对象,现在考虑到这一点,我的配置如下所示:
我希望有人回答会减少找到问题解决方案的时间。