【问题标题】:How to install the openlayers config for eslint?如何为 eslint 安装 openlayers 配置?
【发布时间】:2018-10-10 18:20:44
【问题描述】:

https://github.com/openlayers/eslint-config-openlayers

按照此处的说明,我执行了以下操作。

在终端中我发出了这个命令:

npm install eslint eslint-config-openlayers --save-dev

然后我编辑了 .eslintrc.json 文件:

{
"extends": [
    "openlayers",
    "airbnb-base"
],
"env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "jquery": true
}
}

然而,我仍然收到来自 ESLint 的与 OpenLayers 相关的错误。例如,

'ol' is not defined. (no-undef)

【问题讨论】:

  • 在哪里?你能显示文件吗?
  • 并尝试在 airbnb-base 之后导入 openlayers,以便以 openlayers 设置为准。
  • 是 TypeScript 吗?还是你在使用 webpack?如果其中之一,您是否导入/需要“ol”?

标签: visual-studio-code openlayers eslint


【解决方案1】:

尝试将此添加到您的.eslintrc.json

"globals": {
    "ol": false
}

这告诉 linter ol 是在其他地方定义的,在你的情况下是在一个来自 html 的脚本中。 Details in the ESLint docs.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-27
    • 2017-07-06
    • 2018-08-20
    • 1970-01-01
    • 2017-11-27
    • 2013-10-21
    • 1970-01-01
    • 2020-02-09
    相关资源
    最近更新 更多