首页 > 解决方案 > 为什么用于导入订单的 Eslint 插件在 CRA 中不起作用?

问题描述

我安装eslint-plugin-import-order并添加eslintConfigpackage.json.

我有错误:

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

请帮我处理它。

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

标签: javascriptcreate-react-appeslint

解决方案


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

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

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

  "plugins": ["import"],
  
  .....
}

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


推荐阅读