import-js / import-js/eslint-plugin-import
no-named-as-default-member rule is broken in specific cases
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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