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

[import/order] option to either sort by export name or alias name

Open
#3,181 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted import/export ordering semver-minor
Dominant language
JavaScript
Stars
5.9k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Given the following configuration:
```js
"import/order": [
"error",
{
alphabetize: {
order: "asc",
},
named: true,
},
],
```

The following import statement will fail:
```js
import { b, a as c } from "lib"
```

That's because `a` is expected to be before `b`. However, since `a` is being renamed to `c`, I would like to be able to determine the order based on the alias name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the import/order rule and its alphabetize handling; inspect the existing rule tests to understand how named imports are currently ordered. Add a configuration choice for export-name versus alias-name ordering, then verify the reported import example and existing ordering cases behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.