配置 eslint 使用默认导入
Configure eslint to use the default import
我正在尝试为 @material-ui 配置 eslint,具体情况如下:
我想这样导入:import Typography from '@material-ui/core/Typography';
并禁用导入,例如:import { Typography } from '@material-ui/core';
我已将 no-restricted-imports
规则配置为:
"no-restricted-imports": [
"error",
{
"patterns": ["@material-ui/core", "!@material-ui/core/*"]
}
]
按照我的逻辑,它应该像这样工作:禁止从 @material-ui/core
除了 @material-ui/core/*
之外的所有导入。我做错了什么以及如何根据我的情况配置它?
我使用了路径:
{
...
"no-restricted-imports": [
"error",
{
paths: [
{ name: "@material-ui/core", message: "no named import from material ui core" },
{ name: "@material-ui/lab", message: "no named import from material ui lab" },
],
},
],
}
我正在尝试为 @material-ui 配置 eslint,具体情况如下:
我想这样导入:import Typography from '@material-ui/core/Typography';
并禁用导入,例如:import { Typography } from '@material-ui/core';
我已将 no-restricted-imports
规则配置为:
"no-restricted-imports": [
"error",
{
"patterns": ["@material-ui/core", "!@material-ui/core/*"]
}
]
按照我的逻辑,它应该像这样工作:禁止从 @material-ui/core
除了 @material-ui/core/*
之外的所有导入。我做错了什么以及如何根据我的情况配置它?
我使用了路径:
{
...
"no-restricted-imports": [
"error",
{
paths: [
{ name: "@material-ui/core", message: "no named import from material ui core" },
{ name: "@material-ui/lab", message: "no named import from material ui lab" },
],
},
],
}