【问题标题】:Why Eslint plugin for import order doesn't work in CRA?为什么用于导入订单的 Eslint 插件在 CRA 中不起作用?
【发布时间】:2021-08-01 22:55:22
【问题描述】:

我安装了eslint-plugin-import-order并将其添加到eslintConfig中的package.json

我遇到的错误:

Definition for rule 'import/order' was not found (import/order)

请帮我处理一下。

沙盒:https://codesandbox.io/s/elegant-elbakyan-pilnc

【问题讨论】:

    标签: javascript create-react-app eslint


    【解决方案1】:

    注意: eslint-plugin-import-order 已被弃用。请使用这个 https://github.com/benmosher/eslint-plugin-import

    创建一个.eslintrc.json 文件并添加如下插件。

    {
      ....,
      "extends": ["eslint:recommended", "plugin:import/errors", "plugin:import/warnings"],
    
      "plugins": ["import"],
      
      .....
    }
    

    重新启动一次本地服务器以确保反映更改。

    【讨论】:

    • 谢谢,我试过了,但没有成功。我的密码箱:codesandbox.io/s/elegant-elbakyan-pilnc
    • @bigbabyweb 这在codeandbox中不起作用但在我的vscode编辑器中完美运行似乎很奇怪。
    猜你喜欢
    • 2021-06-13
    • 1970-01-01
    • 2020-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    相关资源
    最近更新 更多