-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flow: Improve comment types detection (#9563)
- Loading branch information
Showing
7 changed files
with
104 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#### Improve comment types detection (#9563 by @fisker) | ||
|
||
<!-- prettier-ignore --> | ||
```jsx | ||
// Input | ||
foo/*::<bar>*/(baz); | ||
class Foo { | ||
bar( data: Array<string>) {} | ||
} | ||
|
||
// Prettier master | ||
foo/*:: <bar> */(baz); | ||
class Foo { | ||
bar(data: Array/*:: <string> */) {} | ||
} | ||
|
||
// Prettier stable | ||
foo/*:: <bar> */(baz); | ||
class Foo { | ||
bar(data: Array<string>) {} | ||
} | ||
``` |
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
30 changes: 30 additions & 0 deletions
30
tests/flow/comments/babel-only/__snapshots__/jsfmt.spec.js.snap
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`type_annotations-3.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel-flow"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import type { OneType } from './oneFile.js' | ||
/*:: | ||
import type { HelloType } from './otherFile.js' | ||
*/ | ||
type PropTypes = {| | ||
TestComponent: React.AbstractComponent<any>, | ||
hello: HelloType, | ||
|}; | ||
=====================================output===================================== | ||
import type { OneType } from "./oneFile.js"; | ||
/*:: | ||
import type { HelloType } from './otherFile.js' | ||
*/ | ||
type PropTypes = {| | ||
TestComponent: React.AbstractComponent<any>, | ||
hello: HelloType, | ||
|}; | ||
================================================================================ | ||
`; |
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 @@ | ||
run_spec(__dirname, ["babel-flow"]); |
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,9 @@ | ||
import type { OneType } from './oneFile.js' | ||
/*:: | ||
import type { HelloType } from './otherFile.js' | ||
*/ | ||
|
||
type PropTypes = {| | ||
TestComponent: React.AbstractComponent<any>, | ||
hello: HelloType, | ||
|}; |
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,4 @@ | ||
foo/*::<bar>*/(baz); | ||
class Foo { | ||
bar( data: Array<string>) {} | ||
} |