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

New `import/order` group for package imports

Open
#2,891 1 comment 3 reactions 0 assignees View on GitHub
`exports` support
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Using Node.js supports [subpath imports](https://nodejs.org/api/packages.html#subpath-imports). Using the `"imports"` field in `package.json`, a user can specify how these imports are resolved from within a package. These imports must always start with a `#`.

For example, given this `package.json`:

```jsonc
{
"imports": {
"#path": {
"browser": "path-browserify",
"default": "path"
}
}
}
```

This file uses the `path-browserify` package in the browser, but `path` in other contexts.

```js
import path from '#path'
```

I think it makes sense to dedicate a new group to this in the `import/order` rule. I’ll name it `subpath-imports` for now. If an import starts with a `#`, it belongs in the `subpath-imports` group.

Contributor guide

Open the contributing guide

Research direction

Start with the import/order rule entry point and the Node.js subpath-imports documentation linked in the issue. Trace how import source prefixes are grouped, then verify that a #path import is recognized as subpath-imports and that existing ordering behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript, node.js
Domain
tooling
Issue type
Feature
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.