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

Defining internal-regex and import/external-module-folders together yields unexpected errors

Open
#2,139 2 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

In our monorepo we store our internal packages under `./packages`

So we tried a config like this:

```js
rules: {
'import/order': 'warn',
},
settings: {
'import/internal-regex': '^internal-', // This makes importing monorepo packages get treated as though they were 'relative-parent-imports'
'import/external-module-folders': ['node_modules', 'packages'],
}
```

But that makes a non-relative import throw this unexpected error

```js
import { foo } from 'internal-utils';
^--- // Relative imports from parent directories are not allowed.
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the configuration shown with the import/order rule, then trace how import/internal-regex and import/external-module-folders classify the internal-utils import together. Done means this non-relative import no longer receives the parent-directory error, with a regression check for the reported configuration.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.