-
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
challenge(formatter): highligh prettier reformat issue (#790)
- Loading branch information
Showing
18 changed files
with
532 additions
and
0 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
5 changes: 5 additions & 0 deletions
5
...s/biome_js_formatter/tests/specs/prettier/js/class-comment/misc.js.prettier-snap-original
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,5 @@ | ||
class x { | ||
focus() { // comment 1 | ||
// comment 2 | ||
} | ||
} |
174 changes: 174 additions & 0 deletions
174
..._js_formatter/tests/specs/prettier/js/comments/return-statement.js.prettier-snap-original
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,174 @@ | ||
function jsx() { | ||
return ( | ||
// Comment | ||
<div /> | ||
); | ||
} | ||
|
||
function unary() { | ||
return ( | ||
// Comment | ||
!!x | ||
); | ||
} | ||
|
||
function numericLiteralNoParen() { | ||
return 1337; // Comment | ||
} | ||
|
||
function logical() { | ||
return ( | ||
// Reason for 42 | ||
42 && 84 | ||
); | ||
} | ||
|
||
function binary() { | ||
return ( | ||
// Reason for 42 | ||
42 * 84 | ||
); | ||
} | ||
|
||
function binaryInBinaryLeft() { | ||
return ( | ||
// Reason for 42 | ||
42 * | ||
84 + | ||
2 | ||
); | ||
} | ||
|
||
function binaryInBinaryRight() { | ||
return ( | ||
// Reason for 42 | ||
42 + | ||
84 * 2 | ||
); | ||
} | ||
|
||
function conditional() { | ||
return ( | ||
// Reason for 42 | ||
42 | ||
? 1 | ||
: 2 | ||
); | ||
} | ||
|
||
function binaryInConditional() { | ||
return ( | ||
// Reason for 42 | ||
42 * 3 | ||
? 1 | ||
: 2 | ||
); | ||
} | ||
|
||
function call() { | ||
return ( | ||
// Reason for a | ||
a() | ||
); | ||
} | ||
|
||
function memberInside() { | ||
return ( | ||
// Reason for a.b | ||
a.b.c | ||
); | ||
} | ||
|
||
function memberOutside() { | ||
return ( | ||
// Reason for a | ||
a.b.c | ||
); | ||
} | ||
|
||
function memberInAndOutWithCalls() { | ||
return ( | ||
aFunction | ||
.b// Reason for a | ||
() | ||
.c.d() | ||
); | ||
} | ||
|
||
function excessiveEverything() { | ||
return ( | ||
// Reason for stuff | ||
a.b() * 3 + 4 ? ((a`hi`, 1) ? 1 : 1) : 1 | ||
); | ||
} | ||
|
||
// See https://github.com/prettier/prettier/issues/2392 | ||
// function sequenceExpression() { | ||
// return ( | ||
// // Reason for a | ||
// a | ||
// ), b | ||
// } | ||
|
||
function sequenceExpressionInside() { | ||
return ( | ||
// Reason for a | ||
a, b | ||
); | ||
} | ||
|
||
function taggedTemplate() { | ||
return ( | ||
// Reason for a | ||
a`b` | ||
); | ||
} | ||
|
||
function inlineComment() { | ||
return /* hi */ 42 || 42; | ||
} | ||
|
||
function multilineBlockSameLine() { | ||
return ( | ||
/** | ||
* @type {string} | ||
*/ "result" | ||
); | ||
} | ||
|
||
function multilineBlockNextLine() { | ||
return ( | ||
/** | ||
* @type {string} | ||
*/ | ||
"result" | ||
); | ||
} | ||
|
||
function multilineBlockSameLineJsx() { | ||
return ( | ||
/** | ||
* JSX Same line | ||
*/ <div></div> | ||
); | ||
} | ||
|
||
function multilineBlockNextLineJsx() { | ||
return ( | ||
/** | ||
* JSX Next line | ||
*/ | ||
<div></div> | ||
); | ||
} | ||
|
||
function singleLineBlockSameLine() { | ||
return /** Result -> */ "result"; | ||
} | ||
|
||
function singleLineBlockNextLine() { | ||
return ( | ||
/** Result below */ | ||
"result" | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
...matter/tests/specs/prettier/js/comments/tagged-template-literal.js.prettier-snap-original
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,14 @@ | ||
foo``; // comment | ||
|
||
foo // comment | ||
``; | ||
|
||
foo // comment | ||
` | ||
`; | ||
|
||
foo/* comment */ ` | ||
`; | ||
|
||
foo /* comment */` | ||
`; |
90 changes: 90 additions & 0 deletions
90
...specs/prettier/js/for/continue-and-break-comment-without-blocks.js.prettier-snap-original
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,90 @@ | ||
for (;;) | ||
continue; | ||
// comment | ||
|
||
for (;;) | ||
break; | ||
// comment | ||
|
||
for (const f of []) | ||
continue; | ||
// comment | ||
|
||
for (const f of []) | ||
break; | ||
// comment | ||
|
||
for (const f in {}) | ||
continue; | ||
// comment | ||
|
||
for (const f in {}) | ||
break; | ||
// comment | ||
|
||
for (;;) | ||
continue; // comment | ||
|
||
for (;;) | ||
break; // comment | ||
|
||
for (const f of []) | ||
continue; // comment | ||
|
||
for (const f of []) | ||
break; // comment | ||
|
||
for (const f in {}) | ||
continue; // comment | ||
|
||
for (const f in {}) | ||
break; // comment | ||
|
||
for (;;) continue; /* comment */ | ||
|
||
for (;;) break; /* comment */ | ||
|
||
for (const f of []) continue; /* comment */ | ||
|
||
for (const f of []) break; /* comment */ | ||
|
||
for (const f in {}) continue; /* comment */ | ||
|
||
for (const f in {}) break; /* comment */ | ||
|
||
for (;;) | ||
continue; | ||
/* comment */ | ||
|
||
for (;;) | ||
break; | ||
/* comment */ | ||
|
||
for (const f of []) | ||
continue; | ||
/* comment */ | ||
|
||
for (const f of []) | ||
break; | ||
/* comment */ | ||
|
||
for (const f in {}) | ||
continue; | ||
/* comment */ | ||
|
||
for (const f in {}) | ||
break; | ||
/* comment */ | ||
|
||
label1: for (;;) continue label1 /* comment */; | ||
|
||
label1: for (;;) | ||
continue label1; | ||
/* comment */ | ||
|
||
label1: for (;;) | ||
continue label1; // comment | ||
|
||
label1: for (;;) | ||
continue label1; | ||
// comment |
41 changes: 41 additions & 0 deletions
41
...formatter/tests/specs/prettier/js/last-argument-expansion/embed.js.prettier-snap-original
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,41 @@ | ||
foo( | ||
/* HTML */ `<!-- bar1 --> | ||
bar | ||
<!-- bar2 -->`, | ||
); | ||
foo(/* HTML */ ` | ||
<!-- bar1 --> | ||
bar | ||
<!-- bar2 --> | ||
`); | ||
foo( | ||
/* HTML */ `<div> | ||
<p>bar</p> | ||
foo | ||
</div>`, | ||
); | ||
foo(/* HTML */ ` | ||
<div> | ||
<p>bar</p> | ||
foo | ||
</div> | ||
`); | ||
foo(/* GraphQL */ ` | ||
query { | ||
foo { | ||
bar | ||
} | ||
} | ||
`); | ||
foo(/* ... */ css` | ||
color: magenta; | ||
`); | ||
const a = (b) => | ||
/* HTML */ `<!-- bar1 --> | ||
bar | ||
<!-- bar2 -->`; | ||
const c = (b) => /* HTML */ ` | ||
<!-- bar1 --> | ||
bar | ||
<!-- bar2 --> | ||
`; |
4 changes: 4 additions & 0 deletions
4
crates/biome_js_formatter/tests/specs/prettier/js/range/boundary.js.prettier-snap-original
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 = 1.0000;bar = 1.0;baz=1.0000; | ||
// The range will be 13~26 | ||
// `foo` ends at 13, should not format | ||
// `bar` ends at 26, should format |
7 changes: 7 additions & 0 deletions
7
...me_js_formatter/tests/specs/prettier/js/range/class-declaration.js.prettier-snap-original
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 @@ | ||
|
||
|
||
class a { | ||
b() {} | ||
} | ||
|
||
let x |
11 changes: 11 additions & 0 deletions
11
...js_formatter/tests/specs/prettier/js/range/multiple-statements2.js.prettier-snap-original
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 @@ | ||
call( | ||
1, 2,3 | ||
); | ||
|
||
call(1, 2, 3); | ||
|
||
call(1, 2, 3); | ||
|
||
call( | ||
1, 2,3 | ||
); |
6 changes: 6 additions & 0 deletions
6
crates/biome_js_formatter/tests/specs/prettier/js/range/nested3.js.prettier-snap-original
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,6 @@ | ||
try { | ||
1;if (condition) { | ||
body; | ||
} | ||
} | ||
catch (err) {} |
Oops, something went wrong.