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

`import/order` not working well with direct parent index

Open
#483 2 comments 3 reactions 0 assignees View on GitHub
bug help wanted import/export ordering
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Hello there,

I'm trying to set up a config for the `import/order` but I have issues when using `..` path to match with direct parent index (e.g. `../index.js`).

This is the config I use:

``` js
'import/order': [ // Enforce a convention in module import order.
'warn',
{
'groups': [
'builtin',
['external', 'internal'],
['parent', 'sibling', 'index'],
],
'newlines-between': 'always',
},
],
```

And here is an example of where I get a wrong warning:

``` js
import moduleA from '../moduleA'; // import/order warning
import moduleB from '..';
```

It reports a warning on the first line: `import/order: There should be at least one empty line between import groups`. Thus, it is no more a problem when adding an ending `/` after module B's path:

``` js
import moduleA from '../moduleA';
import moduleB from '../';
// everything is fine
```

According to me it's a bug, as I don't have to declare `import moduleA from '../moduleA/` to match an `index.js` file. What's your thoughts on this?

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by reproducing the warning with the provided import/order configuration and the two import examples, then trace how parent and index paths are classified. Done means direct imports of `..` and `../index.js` are grouped consistently without requiring a trailing slash, with regression coverage for the reported examples.

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
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.