如何修复/禁用看似错误的“在模块中找不到命名的出口”错误?

时间:2019-03-07 03:57:32

标签: eslint es6-modules

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

/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 */似乎没有任何作用。

任何见识将不胜感激。有没有一种方法可以逐行禁用规则和/或“微动”事情,以便适当地报告事情?

1 个答案:

答案 0 :(得分:0)

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

module.exports = {
    'rules': {
        'import/export': 0
    }
}
相关问题