import-js / import-js/eslint-plugin-import
`no-unused-modules` erroneously flags `as default` exports
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
## Issue Description
The `no-unused-modules` rule incorrectly reports exports as unused when they use the `export { X as default }` syntax, even when the default export is properly imported and used by other modules.
This appears to be a bug in how the plugin resolves default exports that are created via the re-export syntax rather than inline default export declarations.
## Minimal Reproduction
**test-export.ts**
```typescript
export function testHandler() {
return 'result';
}
export { testHandler as default };
```
**test-import.ts**
```typescript
import handler from './test-export';
console.log(handler());
```
**Current behavior**: `eslint-plugin-import` reports `export function testHandler` in `test-export.ts` as unused.
**Expected behavior**: The rule should recognize that:
1. `testHandler` is re-exported as the default export
2. The default export is imported and used in `test-import.ts`
3. Therefore, neither the named export nor the re-export as default should be flagged as unused
## Configuration
```json
{
"import/no-unused-modules": ["error", { "unusedExports": true }]
}
```
## Environment
- **eslint-plugin-import version**: 2.31.0
- **Node version**: 22.13.1
- **npm version**: 10.9.2
Contributor guide
Research direction
Start with the minimal reproduction in the issue and the `import/no-unused-modules` configuration using `unusedExports: true`. Trace how `export { testHandler as default }` is resolved when `test-import.ts` imports and calls the default export. Done when the rule no longer reports the named export or default re-export as unused.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100