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

`import/order` ignores `pathGroups`

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

Description

Hi there,

I'm trying to use `import/order` with this setting:
```json
"import/order": [
"error",
{
"alphabetize": {
"order": "asc",
"caseInsensitive": false
},
"groups": [
["builtin", "external"],
["internal", "parent", "sibling", "index"]
],
"newlines-between": "always",
"pathGroups": [
{
"pattern": "app/**",
"group": "internal"
}
],
"distinctGroup": false
}
],
```

When I run the code, the linter orders the imports like this:
```ts
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ExternalUserPasswordResetModalComponent } from 'app/account/password-reset/external/external-user-password-reset-modal.component';
import { ArtemisSharedModule } from 'app/shared/shared.module';

import { accountState } from './account.route';
import { ActivateComponent } from './activate/activate.component';
```

When instead it should order it like this:
```ts
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { accountState } from './account.route';
import { ActivateComponent } from './activate/activate.component';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { ExternalUserPasswordResetModalComponent } from 'app/account/password-reset/external/external-user-password-reset-modal.component';
```

Can you tell me, why my `pathGroups` and my `groups` setting to not work?

Thanks!

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported import/order configuration and compare the actual and expected ordering shown in the issue. Start by tracing the import/order rule's handling of pathGroups, groups, and distinctGroup; done when the configuration produces the expected ordering or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
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.