Remove extra blank line in type alias (#18109)
This commit is contained in:
1 parent
7a20fe5c5f
commit
7eb39eafc0
5 files changed
+240
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#### Remove unexpected blank line before union types (#18109 by @jspereiramoura, @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```tsx
|
||||
// Input
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
|
||||
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
type A = // comment
|
||||
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
// Prettier stable
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
|
||||
|
||||
| Fooo1000
|
||||
| Baz2000
|
||||
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
type A = // comment
|
||||
|
||||
| Fooo1000
|
||||
| Baz2000
|
||||
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
// Prettier main
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
|
||||
| Fooo1000
|
||||
| Baz2000
|
||||
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
type A = // comment
|
||||
| Fooo1000
|
||||
| Baz2000
|
||||
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
```
|
||||
@@ -142,6 +142,7 @@ function chooseLayout(path, options, print, leftDoc, rightPropertyName) {
|
||||
node.type === "ImportAttribute" ||
|
||||
(rightNode.type === "CallExpression" &&
|
||||
rightNode.callee.name === "require") ||
|
||||
isUnionType(rightNode) ||
|
||||
// do not put values on a separate line from the key in json
|
||||
options.parser === "json5" ||
|
||||
options.parser === "jsonc" ||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
export type ButtonColor =
|
||||
| "primary"
|
||||
| "danger"
|
||||
| "warning"
|
||||
| "muted"
|
||||
| "success";
|
||||
export type Button__80 =
|
||||
| "primary"
|
||||
| "danger"
|
||||
| "warning"
|
||||
| "muted"
|
||||
| "success";
|
||||
|
||||
export type SupportOptionType =
|
||||
| "int"
|
||||
| "string"
|
||||
| "boolean"
|
||||
| "choice"
|
||||
| "path";
|
||||
export type SupportOption_80 =
|
||||
| "int"
|
||||
| "string"
|
||||
| "boolean"
|
||||
| "choice"
|
||||
| "path";
|
||||
|
||||
export type RenderContextType =
|
||||
| 'data'
|
||||
| 'header'
|
||||
| 'footer'
|
||||
| 'columnsSelector';
|
||||
export type RenderContext_80 =
|
||||
| 'data'
|
||||
| 'header'
|
||||
| 'footer'
|
||||
| 'columnsSelector';
|
||||
|
||||
export type PropertyNameNonComputed =
|
||||
| Identifier
|
||||
| NumberLiteral
|
||||
| StringLiteral;
|
||||
export type PropertyNameNon_____80 =
|
||||
| Identifier
|
||||
| NumberLiteral
|
||||
| StringLiteral;
|
||||
|
||||
type ClassLikeDeclaration =
|
||||
| TSESTree.ClassDeclaration
|
||||
| TSESTree.ClassExpression;
|
||||
type ClassLike________80 =
|
||||
| TSESTree.ClassDeclaration
|
||||
| TSESTree.ClassExpression;
|
||||
@@ -1,5 +1,102 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`81-characters.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
export type ButtonColor =
|
||||
| "primary"
|
||||
| "danger"
|
||||
| "warning"
|
||||
| "muted"
|
||||
| "success";
|
||||
export type Button__80 =
|
||||
| "primary"
|
||||
| "danger"
|
||||
| "warning"
|
||||
| "muted"
|
||||
| "success";
|
||||
|
||||
export type SupportOptionType =
|
||||
| "int"
|
||||
| "string"
|
||||
| "boolean"
|
||||
| "choice"
|
||||
| "path";
|
||||
export type SupportOption_80 =
|
||||
| "int"
|
||||
| "string"
|
||||
| "boolean"
|
||||
| "choice"
|
||||
| "path";
|
||||
|
||||
export type RenderContextType =
|
||||
| 'data'
|
||||
| 'header'
|
||||
| 'footer'
|
||||
| 'columnsSelector';
|
||||
export type RenderContext_80 =
|
||||
| 'data'
|
||||
| 'header'
|
||||
| 'footer'
|
||||
| 'columnsSelector';
|
||||
|
||||
export type PropertyNameNonComputed =
|
||||
| Identifier
|
||||
| NumberLiteral
|
||||
| StringLiteral;
|
||||
export type PropertyNameNon_____80 =
|
||||
| Identifier
|
||||
| NumberLiteral
|
||||
| StringLiteral;
|
||||
|
||||
type ClassLikeDeclaration =
|
||||
| TSESTree.ClassDeclaration
|
||||
| TSESTree.ClassExpression;
|
||||
type ClassLike________80 =
|
||||
| TSESTree.ClassDeclaration
|
||||
| TSESTree.ClassExpression;
|
||||
|
||||
=====================================output=====================================
|
||||
export type ButtonColor =
|
||||
| "primary"
|
||||
| "danger"
|
||||
| "warning"
|
||||
| "muted"
|
||||
| "success";
|
||||
export type Button__80 = "primary" | "danger" | "warning" | "muted" | "success";
|
||||
|
||||
export type SupportOptionType =
|
||||
| "int"
|
||||
| "string"
|
||||
| "boolean"
|
||||
| "choice"
|
||||
| "path";
|
||||
export type SupportOption_80 = "int" | "string" | "boolean" | "choice" | "path";
|
||||
|
||||
export type RenderContextType =
|
||||
| "data"
|
||||
| "header"
|
||||
| "footer"
|
||||
| "columnsSelector";
|
||||
export type RenderContext_80 = "data" | "header" | "footer" | "columnsSelector";
|
||||
|
||||
export type PropertyNameNonComputed =
|
||||
| Identifier
|
||||
| NumberLiteral
|
||||
| StringLiteral;
|
||||
export type PropertyNameNon_____80 = Identifier | NumberLiteral | StringLiteral;
|
||||
|
||||
type ClassLikeDeclaration =
|
||||
| TSESTree.ClassDeclaration
|
||||
| TSESTree.ClassExpression;
|
||||
type ClassLike________80 = TSESTree.ClassDeclaration | TSESTree.ClassExpression;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`comment.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "flow"]
|
||||
@@ -11,9 +108,49 @@ type A1 = /* 4 */ (
|
||||
| B
|
||||
)[]
|
||||
|
||||
type A2 = // dir, exp, arg, modifiers
|
||||
| [string]
|
||||
| [string, ExpressionNode]
|
||||
| [string, ExpressionNode, ExpressionNode]
|
||||
| [string, ExpressionNode, ExpressionNode, ObjectExpression]
|
||||
|
||||
type A3 = // dir, exp, arg, modifiers
|
||||
& [string]
|
||||
& [string, ExpressionNode]
|
||||
& [string, ExpressionNode, ExpressionNode]
|
||||
& [string, ExpressionNode, ExpressionNode, ObjectExpression]
|
||||
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
|
||||
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBl2 =
|
||||
Fooo1000 & Baz2000 & BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
=====================================output=====================================
|
||||
type A1 = /* 4 */ (A | B)[];
|
||||
|
||||
type A2 = // dir, exp, arg, modifiers
|
||||
| [string]
|
||||
| [string, ExpressionNode]
|
||||
| [string, ExpressionNode, ExpressionNode]
|
||||
| [string, ExpressionNode, ExpressionNode, ObjectExpression];
|
||||
|
||||
type A3 = // dir, exp, arg, modifiers
|
||||
[string] &
|
||||
[string, ExpressionNode] &
|
||||
[string, ExpressionNode, ExpressionNode] &
|
||||
[string, ExpressionNode, ExpressionNode, ObjectExpression];
|
||||
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
|
||||
| Fooo1000
|
||||
| Baz2000
|
||||
| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBl2 =
|
||||
Fooo1000 &
|
||||
Baz2000 &
|
||||
BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
|
||||
@@ -2,3 +2,21 @@ type A1 = /* 4 */ (
|
||||
| A
|
||||
| B
|
||||
)[]
|
||||
|
||||
type A2 = // dir, exp, arg, modifiers
|
||||
| [string]
|
||||
| [string, ExpressionNode]
|
||||
| [string, ExpressionNode, ExpressionNode]
|
||||
| [string, ExpressionNode, ExpressionNode, ObjectExpression]
|
||||
|
||||
type A3 = // dir, exp, arg, modifiers
|
||||
& [string]
|
||||
& [string, ExpressionNode]
|
||||
& [string, ExpressionNode, ExpressionNode]
|
||||
& [string, ExpressionNode, ExpressionNode, ObjectExpression]
|
||||
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla =
|
||||
Fooo1000 | Baz2000 | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
|
||||
type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBl2 =
|
||||
Fooo1000 & Baz2000 & BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong;
|
||||
Reference in new issue
Block a user