Skip to content

Sort import completions by distance from current module #41083

Closed
@dhoulb

Description

@dhoulb

The auto-import feature is amazing. Something I come across daily though is the import I want is nearly always the second or third choice.

In the screenshots below VS Code suggests to import db from ../../admin/helpers/db before ../helpers/db

I would propose that the ordering is sorted by distance from the current file. The following ESLint rule (that I use in most of my projects) does this correctly and presumably has code that can be reused: eslint-plugin-import/order (well, except we want the inverse of this — shortest distance first).

Screenshot 2020-10-13 at 14 14 46

Screenshot 2020-10-13 at 14 14 39

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions