forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(51301): Fixing an unused import at the end of a line removes the …
…newline (microsoft#51320) * fix(51301): keep the line break after removing the unused identifier * preserve line breaks in import specifiers * preserve line breaks in parameters and destructuring elements * remove preserveLineBreak option
- Loading branch information
1 parent
754eeb2
commit 64d0d5a
Showing
23 changed files
with
489 additions
and
1 deletion.
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
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements2.ts
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,22 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f({ | ||
//// a, b, | ||
//// c, | ||
////}: any)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f({ | ||
a, | ||
c, | ||
}: any)` | ||
}); |
26 changes: 26 additions & 0 deletions
26
tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements3.ts
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,26 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f({ | ||
//// a, b, | ||
//// | ||
//// | ||
//// c, | ||
////}: any)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f({ | ||
a, | ||
c, | ||
}: any)` | ||
}); |
22 changes: 22 additions & 0 deletions
22
tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements4.ts
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,22 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f({ | ||
//// a, b, /* comment related to c */ | ||
//// c, | ||
////}: any)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f({ | ||
a, /* comment related to c */ | ||
c, | ||
}: any)` | ||
}); |
23 changes: 23 additions & 0 deletions
23
tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements5.ts
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,23 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f({ | ||
//// a, | ||
//// b, | ||
//// c, | ||
////}: any)|] { | ||
//// b; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'a'", | ||
newRangeContent: | ||
`function f({ | ||
b, | ||
c, | ||
}: any)` | ||
}); |
25 changes: 25 additions & 0 deletions
25
tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements6.ts
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,25 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f({ | ||
//// a, | ||
//// b, | ||
//// | ||
//// c, | ||
////}: any)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f({ | ||
a, | ||
c, | ||
}: any)` | ||
}); |
23 changes: 23 additions & 0 deletions
23
tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier1.ts
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,23 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
////[|import { | ||
//// a, b, c, d, | ||
//// e, f, | ||
////} from "fs";|] | ||
//// | ||
////a; | ||
////b; | ||
////c; | ||
////e; | ||
////f; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'd'", | ||
newRangeContent: | ||
`import { | ||
a, b, c, | ||
e, f, | ||
} from "fs";` | ||
}); |
31 changes: 31 additions & 0 deletions
31
tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier2.ts
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,31 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
////[|import { | ||
//// a, b, c, d, | ||
//// | ||
//// | ||
//// | ||
//// | ||
//// e, f, | ||
////} from "fs";|] | ||
//// | ||
////a; | ||
////b; | ||
////c; | ||
////e; | ||
////f; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'd'", | ||
newRangeContent: | ||
`import { | ||
a, b, c, | ||
e, f, | ||
} from "fs";` | ||
}); |
23 changes: 23 additions & 0 deletions
23
tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier3.ts
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,23 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
////[|import { | ||
//// a, b, c, d, /** comment related to e */ | ||
//// e, f, | ||
////} from "fs";|] | ||
//// | ||
////a; | ||
////b; | ||
////c; | ||
////e; | ||
////f; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'd'", | ||
newRangeContent: | ||
`import { | ||
a, b, c, /** comment related to e */ | ||
e, f, | ||
} from "fs";` | ||
}); |
21 changes: 21 additions & 0 deletions
21
tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier4.ts
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,21 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
////[|import { | ||
//// a, | ||
//// b, | ||
//// c, | ||
////} from "fs";|] | ||
//// | ||
////a; | ||
////c; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`import { | ||
a, | ||
c, | ||
} from "fs";` | ||
}); |
25 changes: 25 additions & 0 deletions
25
tests/cases/fourslash/codeFixUnusedIdentifier_importSpecifier5.ts
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,25 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
////[|import { | ||
//// a, | ||
//// b, | ||
//// | ||
//// | ||
//// c, | ||
////} from "fs";|] | ||
//// | ||
////a; | ||
////c; | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`import { | ||
a, | ||
c, | ||
} from "fs";` | ||
}); |
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
tests/cases/fourslash/codeFixUnusedIdentifier_parameter2.ts
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,22 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f( | ||
//// a: number, b: number, | ||
//// c: number, | ||
////)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f( | ||
a: number, | ||
c: number, | ||
)` | ||
}); |
26 changes: 26 additions & 0 deletions
26
tests/cases/fourslash/codeFixUnusedIdentifier_parameter3.ts
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,26 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f( | ||
//// a: number, b: number, | ||
//// | ||
//// // comment | ||
//// c: number, | ||
////)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f( | ||
a: number, | ||
// comment | ||
c: number, | ||
)` | ||
}); |
22 changes: 22 additions & 0 deletions
22
tests/cases/fourslash/codeFixUnusedIdentifier_parameter4.ts
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,22 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f( | ||
//// a: number, b: number, /* comment related to c */ | ||
//// c: number, | ||
////)|] { | ||
//// a; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'b'", | ||
newRangeContent: | ||
`function f( | ||
a: number, /* comment related to c */ | ||
c: number, | ||
)` | ||
}); |
23 changes: 23 additions & 0 deletions
23
tests/cases/fourslash/codeFixUnusedIdentifier_parameter5.ts
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,23 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noUnusedLocals: true | ||
// @noUnusedParameters: true | ||
|
||
////[|function f( | ||
//// a: number, | ||
//// b: number, | ||
//// c: number, | ||
////)|] { | ||
//// b; | ||
//// c; | ||
////} | ||
|
||
verify.codeFix({ | ||
index: 0, | ||
description: "Remove unused declaration for: 'a'", | ||
newRangeContent: | ||
`function f( | ||
b: number, | ||
c: number, | ||
)` | ||
}); |
Oops, something went wrong.