【发布时间】:2019-12-21 01:43:10
【问题描述】:
我在 React 中有一个项目,使用 Material UI,我正在应用 their suggested methods 之一来减小我的包大小。
基本上,我需要安装babel-plugin-transform-imports 包并更新我们导入组件的方式:
// Replace this (Option 1):
import Button from "@material-ui/core/Button";
// Whith this (Option 2):
import { Button } from "@material-ui/core";
一切正常,但是,我想防止将来出现“错误”导入(选项 1)。
有没有办法自定义 ESLint 规则,在从 Material UI 包导入时强制选项 2 导入ONLY?
我正在阅读有关创建自定义 ESLint 规则的信息,但希望避免使用该路线。
【问题讨论】:
标签: reactjs import material-ui eslint