Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

ordered-imports doesn't work properly with path separator #3662

Closed
ratoaq2 opened this issue Jan 17, 2018 · 4 comments
Closed

ordered-imports doesn't work properly with path separator #3662

ratoaq2 opened this issue Jan 17, 2018 · 4 comments

Comments

@ratoaq2
Copy link

ratoaq2 commented Jan 17, 2018

Bug Report

  • TSLint version: 5.9.1
  • TypeScript version: 2.4.2
  • Running TSLint via: Node.js API and Atom

TypeScript code being linted

import { NgModule } from '@angular/core';
import { NgReduxRouterModule } from '@angular-redux/router';
import { NgRedux, NgReduxModule } from '@angular-redux/store';

with tslint.json configuration:

    "ordered-imports": [
      true,
      {
        "grouped-imports": true,
        "import-sources-order": "case-insensitive",
        "named-imports-order": "case-insensitive",
        "module-source-path": "full"
      }
    ]

Actual behavior

@angular-redux is happening before @angular

import { NgReduxRouterModule } from '@angular-redux/router';
import { NgRedux, NgReduxModule } from '@angular-redux/store';
import { NgModule } from '@angular/core';

Expected behavior

@angular should come before @angular-redux

import { NgModule } from '@angular/core';
import { NgReduxRouterModule } from '@angular-redux/router';
import { NgRedux, NgReduxModule } from '@angular-redux/store';
@ddagsan
Copy link

ddagsan commented May 29, 2018

Isn't there any solution?

@JoshuaKGoldberg
Copy link
Contributor

None so far. There are several rules that sort by names, and it'd be good to have a solid proposal on how to standardize their behavior. Should there be a unified "sort" function used by all rules for consistency? Should rules intentionally differ from each other to have better behavior per rule?

Related: #4063.

@abierbaum
Copy link
Contributor

In the meantime you could use #4134 to setup distinct ordered groups. So it would put "@angular" before "@angular-" packages for example. It would leave a break between them as groups though so it isn't quite what you need but may be something to consider.

@adidahiya
Copy link
Contributor

I'm not convinced that there should be special alphabetization behavior for ordered-imports. I think #4063 is the more important issue to tackle related to this. If you really want @angular/core to appear before @angular-redux/router (which is not the order produced by Array.prototype.sort([ '@angular-redux/router', '@angular/core' ])), you should use the grouping functionality introduced by #4134.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants