Skip to content

import/export false positive with star reexports #703

@Jessidhia

Description

@Jessidhia

Sample code:

// index.js

export * from './core'
// Placed here to work around a webpack bug.
// https://github.com/webpack/webpack/issues/3588
export { default } from './core'

export * from './modules'

// export { default } from './core';
// disambiguate export
export { api } from './modules'
// (simplified) core.js that can reproduce the issue
export const api = {}
export default null
// (simplified) modules.js that can reproduce the issue
export const api = {}

As the api exports coming via the export * are not SameValue, the lint warning would be correct if not for the export { api } from './modules' at the bottom, which disambiguates the exports.

Explicit exports always take precedence over any star reexports, so no exports are duplicated.


Note that, if both export const api were set to, say, 'foo', they would all be SameValue, and so would be allowed by the spec even without the disambiguating reexport. I have no idea how the spec would deal with the case where they are mutable exports 😆

There might be value in actually having a warning for this case, but it probably should be in a separate rule, or configuration option.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions