Skip to content

Commit

Permalink
Change normalisation of ordered-imports
Browse files Browse the repository at this point in the history
This makes it consistent with TypeScript's Organize Imports command

Fixes palantir#4063
  • Loading branch information
Andrew Boyton committed Nov 7, 2018
1 parent 191f5e4 commit fa78d7c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/rules/orderedImportsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
isStringLiteral,
} from "tsutils";
import * as ts from "typescript";

import * as Lint from "../index";

export class Rule extends Lint.Rules.AbstractRule {
Expand Down Expand Up @@ -135,7 +134,7 @@ export class Rule extends Lint.Rules.AbstractRule {
type Transform = (x: string) => string;
const TRANSFORMS = new Map<string, Transform>([
["any", () => ""],
["case-insensitive", x => x.toLowerCase()],
["case-insensitive", x => x.toUpperCase()],
["lowercase-first", flipCase],
["lowercase-last", x => x],
["full", x => x],
Expand Down
4 changes: 4 additions & 0 deletions test/rules/ordered-imports/case-insensitive/test.ts.fix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {A, B} from 'foo'; // failure
import {A, bz, C} from 'foo'; // failure
import {A, b, C} from 'zfoo';

// Underscores come last.
import {A, C, _b} from 'zfoo'; // failure
import {A, C, _b} from 'zfoo';

import {g} from "y"; // failure
import {
a as d,
Expand Down
5 changes: 5 additions & 0 deletions test/rules/ordered-imports/case-insensitive/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {bz, A, C} from 'foo'; // failure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.]
~~~~~ [Named imports must be alphabetized.]

// Underscores come last.
import {A, _b, C} from 'zfoo'; // failure
~~~~~ [Named imports must be alphabetized.]
import {A, C, _b} from 'zfoo';

import {
b as c,
~~~~~~~
Expand Down

0 comments on commit fa78d7c

Please sign in to comment.