import-integrity/no-named-as-default
Ensures that default imports do not have the same name as a named export in the file being imported from.
Rule Details
If a default import or reexport is given the same name as a named export in the file being imported from, one of two things is likely happening: the developer made a mistake and meant to import the named export, or the developer is intentionally aliasing the default to shadow the named export and create confusion for future readers. Either way, the result is harder to read code.
Examples
The examples below assume:
// a.ts
export const a = 10;
export default 20;Incorrect
// b.ts
import a from './a';// c.ts
export { default as a } from './a';Correct
// b.ts
import aDefault from './a';// c.ts
export { default as aDefault } from './a';Any name that doesn't collide with a named export from the imported file works. aDefault is just one option.
Configuration
Options
This rule has no options.
When not to use this rule
We don't recommend disabling this rule. If you have a legitimate need to import the default with the same name as a named export, you can suppress the warning for the specific line with a disable comment, but the resulting code will be harder for others to read.