【问题标题】:Visual Studio Code error: (options.globals || []).reduce is not a functionVisual Studio Code 错误:(options.globals || []).reduce 不是函数
【发布时间】:2018-01-28 06:59:33
【问题描述】:

我在编辑器中配置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 的全局配置?

【问题讨论】:

    标签: visual-studio-code eslint vscode-settings


    【解决方案1】:

    事实证明,解决方案出乎意料,在这里找到https://github.com/eslint/eslint/pull/6922 那些。

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-23
      • 2022-07-25
      • 1970-01-01
      • 1970-01-01
      • 2018-01-26
      • 2020-01-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多