【问题标题】:eslint-config-standard with @babel/plugin-proposal-class-properties带有@babel/plugin-proposal-class-properties 的 eslint-config-standard
【发布时间】:2019-05-16 10:33:53
【问题描述】:

问题

我正在使用 eslint-config-standard 设置 eslint。
我也在使用 @babel/plugin-proposal-class-properties 的 babel 插件。

我尝试通过“eslint index.js”命令对我的 javascript 文件进行 lint,但出现错误“[eslint]: Parsing error: Unexpected token =".

所以我安装了 babel-eslint,并像这样更新了文件“.eslintrc”:

{
    "extends": ["standard"],
    "parser": "babel-eslint",
    "rules": {
        "eol-last": 0
    }
}

上面的配置解决了“[eslint]: Parsing error: Unexpected token =”的错误,但是我遇到了新的问题,即eslint-config-standard配置不再起作用。

问题

我想将 eslint-config-standard 与实验性 JavaScript 代码一起使用。
但我不知道如何将它们一起使用以及是否可能。

如何一起使用?


附言对不起我的英语不好:(

【问题讨论】:

    标签: babeljs eslint babel-eslint


    【解决方案1】:

    是的,这是可能的。你只需要为用于 ESLint 和插件的 Babel 解析器安装一个包装器。

    https://github.com/babel/babel-eslint

    https://github.com/babel/eslint-plugin-babel

    $ npm install eslint babel-eslint eslint-plugin-babel --save-dev
    # or
    $ yarn add eslint babel-eslint eslint-plugin-babel -D
    

    然后,您需要在 .eslintrc 中添加

    "parser": "babel-eslint",
    "plugins": ["babel"],
    

    另外,如果它在第一次尝试时不起作用,您可能需要重新启动代码编辑器。祝你好运! :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-01
      • 2020-11-01
      • 1970-01-01
      • 2022-08-15
      • 2019-08-04
      • 1970-01-01
      • 2021-02-13
      相关资源
      最近更新 更多