Visual Studio Code error: (options.globals || []).reduce is not a function

Visual Studio Code error: (options.globals || []).reduce is not a function

我在编辑器中配置eslint,来自手册https://eslint.org/docs/user-guide/configuring#specifying-globals:

在我的配置中,它看起来像这样:

"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 那些。

建议用数组替换全局设置对象,考虑到这一点,我的配置如下所示:

"eslint.enable": true,
  "eslint.options": {
    "globals": [        
      "$",
      "moment"       
    ],
...

我希望有人能减少寻找问题解决方案的时间。