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

Proposal: Warn on importing from a filename for which a directory also exists

Open
#919 1 comment 1 reaction 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

For example, let's say I have the following files:

```
| something/
|-- index.js
| something.js
| main.js
```

Inside `main.js`, I have the following code:

```js
import { helpfulFunction } from './something';

// do something with helpfulFunction()
```

This is a little dangerous, because did I mean `./something` or `./something/`? I don't think code should be split up like this—in this case, I would take the contents of `something.js` and move them to `something/index.js` and just import from there. A warning would be helpful to track down cases like this.

Contributor guide

Open the contributing guide

Research direction

Start by locating the import-resolution rule entry points and tests in eslint-plugin-import; the issue does not name specific files. Reproduce the example with something.js, something/index.js, and main.js, then determine how a warning should identify the ambiguous import. Done means the plugin warns when both a matching file and directory exist, with coverage for the shown case.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.