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 Jul 23, 2018
1 parent 3617be0 commit 40f7fc4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/orderedImportsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,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 40f7fc4

Please sign in to comment.