Skip to content

TSLint named-imports-order and ESLint sort-imports don't order special chars (_) the same as organizeImports #37548

Closed

Description

TypeScript Version: 3.8.3

Search Terms:

  • named-imports-order organizeImports
  • named-imports-order

Code

// ordered using vscode organizeImports
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';

// ordered using tslint "named-imports-order": "case-insensitive" (this is the default)
// also tried "lowercase-first" and "lowercase-last" - it's worse
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';

Expected behavior:
They should sort _ the same.

Actual behavior:
TSLint seems to put _ first while organizeImports put it last. This is probably a general issue for non-alpha chars.

ESLint sort-imports also sorts special chars first.
Valid ESLint import order
Invalid ESLint import order

Activity

  1. snebjorn commented on Mar 2, 2023

    @snebjorn
    Author

    Wonder if this is solved by Case-Insensitive Import Sorting in Editors

  2. jakebailey commented on Mar 2, 2023

    @jakebailey
    Member

    I think so? If not, the unstable options might cover it too.

    cc Andrew Branch (@andrewbranch) to confirm.

  3. andrewbranch commented on Mar 7, 2023

    @andrewbranch
    Member

    This is probably a general issue for non-alpha chars.

    It was a problem only with the characters whose ASCII code is sandwiched between the uppercase and lowercase letters, of which only _ was a valid identifier character 😄

    And yeah, it should have been fixed by #51733. Let us know if it’s not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions