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

Rule proposal: no-rename-default

Open
#1,041 27 comments 36 reactions 0 assignees View on GitHub
accepted help wanted rule proposal
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Consider the following:

components/foo.js:

```jsx
export default class Foo extends React.Component {
render() {
// ...
}
}
```

widgets/foo.js:

```jsx
import FooComponent from '../components/foo';

export default class Foo extends BaseWidget {
constructor() {
super(FooComponent);
}

// ...
}
```

`Foo` (in components/foo.js) and `FooComponent` are exactly the same thing, but have been renamed via default import/export. When one thing has two or more names, it increases the difficulty of comprehending code, especially when there are many functions, classes, etc. that are renamed on import.

The proposal is to have a rule that generates a warning or error when a default `import` is given a different name than a default `export`.

Contributor guide

Open the contributing guide

Research direction

Use the components/foo.js and widgets/foo.js examples as the behavioral starting point, then locate the plugin's rule entry points and test conventions. Define the cases covered by the proposed warning or error, including when a default import name differs from its default export name, and add tests showing the completed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.