Skip to content

import/order with named fails when exporting uses spread operator. #3145

@UnderKoen

Description

@UnderKoen

Rule:

'import/order': [
  'warn',
  {
    named: true,
  },
],

minimal repro case:

const test = {
  a: 1,
  browser: 2,
};

module.exports = {
  ...test,
  target: 'node',
};

Activity

ljharb

ljharb commented on Jan 17, 2025

@ljharb
Member

What does native node do when importing this module into ESM? I assume it breaks cjs-module-lexer's static analysis as well?

ljharb

ljharb commented on Jan 20, 2025

@ljharb
Member

By ignore, that means it won’t treat those as named imports, which would match the current behavior of this plugin?

UnderKoen

UnderKoen commented on Jan 20, 2025

@UnderKoen
Author

Currently it crashes. As node.right.properties[i].key is undefined. That why there is just an truthy check added in #3146

ljharb

ljharb commented on Jan 20, 2025

@ljharb
Member

aha :-) ok, i'll give that PR a review then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @ljharb@soryy708@UnderKoen

      Issue actions

        import/order with named fails when exporting uses spread operator. · Issue #3145 · import-js/eslint-plugin-import