Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix flow comments plugin issues (#10329)
* Fix issues in flow-comments to preserve comments and there order (fixes #10324) * Add support in flow-comments for extends in class declarations (fixes #10323, #10321) * Refactoring and cleanup of flow-comments plugin * Fix comments preservation logic of flow-comments * Fix flow-comments where comments are class identifier and extends keyword
- Loading branch information
1 parent
469a5a7
commit 64041e1
Showing
11 changed files
with
219 additions
and
85 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
1 change: 1 addition & 0 deletions
1
...transform-flow-comments/test/fixtures/flow-comments/class-extends-type-parameter/input.js
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 @@ | ||
class Foo extends Bar<T> {} |
3 changes: 3 additions & 0 deletions
3
...ransform-flow-comments/test/fixtures/flow-comments/class-extends-type-parameter/output.js
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,3 @@ | ||
class Foo extends Bar | ||
/*:: <T>*/ | ||
{} |
3 changes: 3 additions & 0 deletions
3
...comments/test/fixtures/flow-comments/class-type-parameter-extends-type-parameter/input.js
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,3 @@ | ||
class Foo<T> /* inner */ extends Bar<R> {} | ||
|
||
/*a*/class /*b*/Baz/*c*/<T>/*d*/extends /*e*/Bar/*f*/<R>/*g*/ {/*h*/}/*i*/ |
30 changes: 30 additions & 0 deletions
30
...omments/test/fixtures/flow-comments/class-type-parameter-extends-type-parameter/output.js
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,30 @@ | ||
class Foo | ||
/*:: <T>*/ | ||
|
||
/* inner */ | ||
extends Bar | ||
/*:: <R>*/ | ||
{} | ||
/*a*/ | ||
|
||
|
||
class | ||
/*b*/ | ||
Baz | ||
/*c*/ | ||
|
||
/*:: <T>*/ | ||
|
||
/*d*/ | ||
extends | ||
/*e*/ | ||
Bar | ||
/*f*/ | ||
|
||
/*:: <R>*/ | ||
|
||
/*g*/ | ||
{} | ||
/*h*/ | ||
|
||
/*i*/ |
1 change: 1 addition & 0 deletions
1
...transform-flow-comments/test/fixtures/flow-comments/class-type-parameter-extends/input.js
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 @@ | ||
class Foo<T> extends Bar {} |
3 changes: 3 additions & 0 deletions
3
...ransform-flow-comments/test/fixtures/flow-comments/class-type-parameter-extends/output.js
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,3 @@ | ||
class Foo | ||
/*:: <T>*/ | ||
extends Bar {} |
7 changes: 7 additions & 0 deletions
7
...ugin-transform-flow-comments/test/fixtures/flow-comments/preserve-comments-order/input.js
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,7 @@ | ||
/*a*/ | ||
type Foo = number; | ||
/*b*/ | ||
var foo; | ||
/*c*/ | ||
type Bar = number; | ||
/*d*/ |
11 changes: 11 additions & 0 deletions
11
...gin-transform-flow-comments/test/fixtures/flow-comments/preserve-comments-order/output.js
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 @@ | ||
/*a*/ | ||
|
||
/*:: type Foo = number;*/ | ||
|
||
/*b*/ | ||
var foo; | ||
/*c*/ | ||
|
||
/*:: type Bar = number;*/ | ||
|
||
/*d*/ |
Oops, something went wrong.