This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change normalisation of ordered-imports (#4064)
- Loading branch information
Showing
6 changed files
with
149 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/rules/ordered-imports/case-insensitive-legacy/test.ts.fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Named imports should be alphabetized. | ||
import {A, B} from 'foo'; | ||
import {A, B} from 'foo'; // failure | ||
|
||
// Case is irrelevant for named import ordering. | ||
import {A, bz, C} from 'foo'; // failure | ||
import {A, b, C} from 'zfoo'; | ||
|
||
// Underscores come first. | ||
import {_b, A, C, d} from 'zfoo'; // failure | ||
import {_b, A, C, d} from 'zfoo'; | ||
|
||
import {g} from "y"; // failure | ||
import { | ||
a as d, | ||
b as c, | ||
} from "z"; | ||
|
||
// Import sources should be alphabetized. | ||
import * as bar from 'bar'; | ||
import * as foo from 'foo'; | ||
|
||
import * as abc from 'abc'; | ||
import * as bar from 'bar'; // failure | ||
import * as foo from 'foo'; | ||
|
||
// ignore quotes | ||
import * as bar from 'bar'; | ||
import * as foo from "foo"; | ||
|
||
import * as bar from "bar"; | ||
import * as foo from 'foo'; | ||
|
||
// Case is irrelevant for source import ordering. | ||
import {A, B} from 'Bar'; | ||
import {A, B} from 'baz'; | ||
import {A, B} from 'Foo'; // should not fail | ||
|
||
// Other styles of import statements. | ||
import someDefault from "module"; | ||
import "something"; | ||
import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; | ||
|
||
// do not fix cases where a newline is missing | ||
import * as foo from 'foo'; import * as bar from 'bar'; | ||
|
||
import * as bar from 'bar'; | ||
import * as foo from 'foo'; |
61 changes: 61 additions & 0 deletions
61
test/rules/ordered-imports/case-insensitive-legacy/test.ts.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Named imports should be alphabetized. | ||
import {A, B} from 'foo'; | ||
import {B, A} from 'foo'; // failure | ||
~~~~ [ordered-imports] | ||
|
||
// Case is irrelevant for named import ordering. | ||
import {A, b, C} from 'zfoo'; | ||
import {bz, A, C} from 'foo'; // failure | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] | ||
~~~~~ [Named imports must be alphabetized.] | ||
|
||
// Underscores come first. | ||
import {A, _b, C, d} from 'zfoo'; // failure | ||
~~~~~ [Named imports must be alphabetized.] | ||
import {_b, A, C, d} from 'zfoo'; | ||
|
||
import { | ||
b as c, | ||
~~~~~~~ | ||
a as d, | ||
~~~~~~~~~~ [Named imports must be alphabetized.] | ||
} from "z"; | ||
import {g} from "y"; // failure | ||
~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] | ||
|
||
// Import sources should be alphabetized. | ||
import * as bar from 'bar'; | ||
import * as foo from 'foo'; | ||
|
||
import * as abc from 'abc'; | ||
import * as foo from 'foo'; | ||
import * as bar from 'bar'; // failure | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ordered-sources] | ||
|
||
// ignore quotes | ||
import * as bar from 'bar'; | ||
import * as foo from "foo"; | ||
|
||
import * as bar from "bar"; | ||
import * as foo from 'foo'; | ||
|
||
// Case is irrelevant for source import ordering. | ||
import {A, B} from 'Bar'; | ||
import {A, B} from 'baz'; | ||
import {A, B} from 'Foo'; // should not fail | ||
|
||
// Other styles of import statements. | ||
import someDefault, {nameA, nameBReallyLong as anotherName} from "./wherever"; | ||
import someDefault from "module"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] | ||
import "something"; | ||
|
||
// do not fix cases where a newline is missing | ||
import * as foo from 'foo'; import * as bar from 'bar'; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] | ||
|
||
import * as foo from 'foo'; | ||
import * as bar from 'bar'; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Import sources within a group must be alphabetized.] | ||
[ordered-imports]: Named imports must be alphabetized. | ||
[ordered-sources]: Import sources within a group must be alphabetized. |
11 changes: 11 additions & 0 deletions
11
test/rules/ordered-imports/case-insensitive-legacy/tslint.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"rules": { | ||
"ordered-imports": [ | ||
true, | ||
{ | ||
"import-sources-order": "case-insensitive-legacy", | ||
"named-imports-order": "case-insensitive-legacy" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters