gpt4 book ai didi

eslint - 如何修复/禁用看似错误的 "No named exports found in module"错误?

转载 作者:行者123 更新时间:2023-12-04 13:01:52 28 4
gpt4 key购买 nike

我正在整理我的代码,我在几个地方得到了这个:

/Users/zane/playground/react-waiter/js/components/index.js
1:15 error No named exports found in module './utils' import/export
2:15 error No named exports found in module './widgets' import/export

/Users/zane/playground/react-waiter/js/index.js
1:15 error No named exports found in module './components' import/export

我相信该报告是误报,因为当我运行代码时,一切正常,我确实可以导入导出的项目。

编码:
// js/index.js
export * from './components'
export * from './settings'
export * from './utils'
// js/components/index.js
export * from './utils'
export * from './widgets'
// js/components/utils/index.js
export * from './Waiter'
// js/components/utils/Waiter.jsx
...
const Waiter = (props) => { ... }

export { Waiter }

然后对 widgets 使用相同的模式模块,从文件导出并从索引重新导出的单个常量。我做了
试试 export const Waiter = ... , 和 export * from './utils/index'结果相同。

我经常使用这种模式,在重新导出索引文件时出现问题,没有其他问题。

作为一种解决方法,我将 eslint 配置设置为将这些更改为警告,这样它们就不会停止 CI 过程,但仍然会报告真正的问题。

我假设在某个时候(明显的)错误将被修复。这将是一个小问题,但是 /* eslint-disable import/export */好像没有效果。

任何见解将不胜感激。有没有办法在每行和/或“摇晃”事物的基础上禁用规则,以便 eslint 正确报告事物?

最佳答案

要禁用此规则,您的 .eslintrc.js应该有:

module.exports = {
'rules': {
'import/export': 0
}
}

关于eslint - 如何修复/禁用看似错误的 "No named exports found in module"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55035818/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com