import-js / import-js/eslint-plugin-import
[question] Enforce internal/parent import order with alias
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
I can't find a way to enforce import order to internal / parent using aliases. Maybe it is just not possible.
Example:
```
--- src
|--- folderA
|--- fileA1.ts
|--- fileA2.ts
|--- folderB
|--- folderC
|--- fileC1.ts
|--- fileB1.ts
|--- fileB2.ts
```
Set an alias in my `tsconfig.json`
```json
{
"compilerOptions": {
...
"baseUrl": "./",
"paths": {
"@src/*": ["src/*"],
}
}
}
```
In `fileC1.ts`
```ts
import { foo } from '@src/folderA/fileA1'
import { bar } from '@src/folderB/fileB1'
```
I would really love to be able to enforce the import from `B` (parent) to happen after import `A` (internal) but I'm not sure it is possible since I believe that `alias` would "hide" it.
Thanks in advance!
Contributor guide
Research direction
Start by reviewing the import-order rule and how it interprets the tsconfig.json paths alias. Reproduce the example imports in fileC1.ts and determine whether the alias can distinguish internal from parent imports. Done should be a documented supported behavior or a clearly scoped change with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100