import-js / import-js/eslint-plugin-import

no-named-as-default-member rule is broken in specific cases

Open
#1,952 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

import/no-named-as-default-member is broken in such a case:

// id-values-map.js

const ID_VALUE_MAP = {
  x: 4,
  y: 14,
};

const DEFAULT_ID = 'x';

export default ID_VALUE_MAP;
export { DEFAULT_ID };
// usage.js

import ID_VALUE_MAP, { DEFAULT_ID } from './id-values-map';

use(ID_VALUE_MAP[DEFAULT_ID]);
// ESLint: Caution: `ID_VALUE_MAP` also has a named export `DEFAULT_ID`. Check if you meant to write `import {DEFAULT_ID} from './id-values-map'` instead.(import/no-named-as-default-member)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the warning using the id-values-map.js and usage.js examples in the issue, then trace the import/no-named-as-default-member rule and its existing tests. The fix is done when importing the default object and accessing it with the named export no longer produces this false-positive warning, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.