You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 10b10c5
Browse filesBrowse the repository at this point in the historyBrowse files
Prettier's output crosses user content (the value the comment precedes, then the `;`) or changes line (own-lined in TS).
210
+
Prettier's output crosses user content (the value the comment precedes, then the `;`) or changes line (own-lined).
210
211
An end-of-line line comment right after `=`/`:` keeps its position (`= // c` + mandatory break).
211
-
Block comments glued after the operator before it stay there, in order;
212
-
Prettier prints the line comment first and the block on the value's line, crossing the block.
213
-
A line comment before the operator rides its `line_suffix` past the operator and gets the same break;
214
-
Prettier flushes it past the value.
215
-
Comments the left side defers (own-line, or a block ending its line) lead the value, the line comment follows them in source order, as Prettier prints type aliases;
216
-
for JS values, Prettier flushes the line comment past the value after a block (`const v = /* c */ 1; // d`) and before an own-line one.
212
+
Block comments glued after the operator before it stay there, in order; Prettier prints the line comment first and the block on the value's line, crossing the block.
213
+
A line comment before the operator rides its `line_suffix` past the operator and gets the same break; Prettier flushes it past the value.
214
+
A single-line block comment ending the left side's line trails the left side; Prettier moves it across the operator.
215
+
Comments the left side defers (own-line, or a multiline block ending its line) lead the value, the line comment follows them in source order, as Prettier prints type aliases; for JS values, Prettier prints the line comment before them.
217
216
218
217
```ts
219
218
// input
@@ -223,6 +222,10 @@ const v2 = /* c */ // d
223
222
1;
224
223
const v3 // c
225
224
=1;
225
+
const v4 /* c */
226
+
=1;
227
+
const v5 =// c
228
+
{ a: 1 };
226
229
typeAlias=// c
227
230
"VALUE";
228
231
@@ -233,6 +236,9 @@ const v2 = /* c */ // d
233
236
1;
234
237
const v3 =// c
235
238
1;
239
+
const v4 /* c */=1;
240
+
const v5 =// c
241
+
{ a: 1 };
236
242
typeAlias=// c
237
243
"VALUE";
238
244
@@ -241,14 +247,19 @@ const v1 = 1; // c
241
247
const v2 =// d
242
248
/* c */1;
243
249
const v3 =1; // c
250
+
const v4 =/* c */1;
251
+
const v5 =
252
+
// c
253
+
{ a: 1 };
244
254
typeAlias=
245
255
// c
246
256
"VALUE";
247
257
```
248
258
249
-
Prettier treats the same shape three ways:
259
+
Prettier treats the same shape differently:
250
260
251
-
- JS keeps it only when the right-hand side breaks and flushes it past a fitting one (the prettier/prettier#14617-family attachment artifact)
261
+
- JS keeps it only when the right-hand side breaks and flushes it past a fitting one (the prettier/prettier#14617-family attachment artifact),
262
+
except an object, array or template value, which gets it own-lined (`handleAssignmentLikeComments`)
252
263
- TS type aliases and union-valued property signatures get it own-lined (the 3.9 union rewrite)
253
264
- simple-typed property signatures get it flushed past the member and its `;` separator
0 commit comments