javascript - 在不更改配置的情况下获取过去的 import/no-named-as-default lint 错误
问题描述
我收到 no-named-as-default eslint 错误。
遇到需要 Redux 功能的问题,我不能只使用命名导入。
在这里看到了类似的查询,但它们都涉及配置更改,例如修改 eslint 文件
或与 Babel 配置有关的事情。
示例:如何解决 eslint import/no-named-as-default
有没有办法在代码本身中实现它?
因为我无法更改任何配置。我可以一起放弃默认导入并使用
2x 命名导入(也许 1 带有别名?)。
但我似乎无法摆脱默认。当我删除它时,底部出口会抱怨。
如果组件上没有默认导入,也不确定 eslint 是否会开始抱怨。
如果我将其作为默认值导入,这就是 eslint 抱怨的组件。
export const IndicatorPage = ({setData}) => {
// logic
}
const mapDispatchToProps = {
setData: setIndicatorData
}
// ide complains if I remove this default. Plus even if I could drop default,
// wondering if that would be another lint error for not having defaults
export default connect(null, mapDispatchToProps)(IndicatorPage);
当我将其导入另一个组件时的示例。
这让 eslint 很高兴,但它破坏了我的 redux 功能。
import { IndicatorPage } from './IndicatorPage';
这使得 Redux 正常工作,但现在 eslint 抱怨......
import IndicatorPage from './IndicatorPage';
解决方案
推荐阅读
- windows - 如何在 Windows 批处理脚本中运行命令?
- javascript - $set 降低了 Vue 的性能
- flutter - 颤动文本中的制表符和制表位
- flask - flask sqlalchemy 一对一的关系问题
- reactjs - Material-UI 滑块未将名称道具暴露给 Formik
- javascript - React Native 读取 yaml 文件
- django - django 无法显示搜索结果
- mysql - mySQL 查询:查找包含关键字的内容以及具有该关键字的对象的数量
- angular - 如何更新特定用户的按钮点击记录?
- python - 如何从字典的键中计算对象?