Skip to content

Feature: display the common group between two imports in the error message #471

@hugop95

Description

@hugop95

What rule do you want to change?

sort-imports (but can be applied to other rules that handle group as well)

Describe the problem

sort-imports's grouping behavior can be a bit confusing in some cases (see the latest issue #470), and it's not easy for users to see if an import actually belongs to the group they think they should.

Two imports from the same group that are misplaced will return the following error:
Expected "NEXT IMPORT" to come before "PREVIOUS IMPORT".

I suggest that we improve this error message to show the group both imports belong to:

Expected "NEXT_IMPORT" to come before "PREVIOUS_IMPORT" (both in group "COMMON_GROUP").

Additional details

  • When groups is [] or [unknown], the common group will always be unknown, so we should keep a simple error message in that case.

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions