fix: newline between front-matter and comment (#4701)
parent
56af3d621d
commit
03a2002348
|
@ -833,7 +833,8 @@ function printNodeSequence(path, options, print) {
|
|||
options.originalText,
|
||||
options.locStart(node.nodes[i + 1]),
|
||||
{ backwards: true }
|
||||
)) ||
|
||||
) &&
|
||||
node.nodes[i].type !== "front-matter") ||
|
||||
(node.nodes[i + 1].type === "css-atrule" &&
|
||||
node.nodes[i + 1].name === "else" &&
|
||||
node.nodes[i].type !== "css-comment")
|
||||
|
@ -842,7 +843,12 @@ function printNodeSequence(path, options, print) {
|
|||
} else {
|
||||
parts.push(hardline);
|
||||
if (
|
||||
isNextLineEmpty(options.originalText, pathChild.getValue(), options)
|
||||
isNextLineEmpty(
|
||||
options.originalText,
|
||||
pathChild.getValue(),
|
||||
options
|
||||
) &&
|
||||
node.nodes[i].type !== "front-matter"
|
||||
) {
|
||||
parts.push(hardline);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`comment_after.css 1`] = `
|
||||
---
|
||||
title: Title
|
||||
description: Description
|
||||
---
|
||||
/* comment */
|
||||
.something {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
---
|
||||
title: Title
|
||||
description: Description
|
||||
---
|
||||
|
||||
/* comment */
|
||||
.something {
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`empty.css 1`] = `
|
||||
---
|
||||
---
|
||||
|
@ -128,6 +148,26 @@ a {
|
|||
|
||||
`;
|
||||
|
||||
exports[`without-newline-after.css 1`] = `
|
||||
---
|
||||
title: Title
|
||||
description: Description
|
||||
---
|
||||
a {
|
||||
color: red;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
---
|
||||
title: Title
|
||||
description: Description
|
||||
---
|
||||
|
||||
a {
|
||||
color: red;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`yaml.css 1`] = `
|
||||
---
|
||||
title: Title
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
title: Title
|
||||
description: Description
|
||||
---
|
||||
/* comment */
|
||||
.something {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
title: Title
|
||||
description: Description
|
||||
---
|
||||
a {
|
||||
color: red;
|
||||
}
|
|
@ -10,7 +10,8 @@ something
|
|||
---
|
||||
something
|
||||
---
|
||||
/** @format */
|
||||
|
||||
/** @format */
|
||||
.class {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ exports[`empty-front-matter-with-pragma.css 1`] = `
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
---
|
||||
---
|
||||
/** @prettier */
|
||||
|
||||
/** @prettier */
|
||||
.class {
|
||||
display: none;
|
||||
}
|
||||
|
@ -42,7 +43,8 @@ something
|
|||
---
|
||||
something
|
||||
---
|
||||
/** @prettier */
|
||||
|
||||
/** @prettier */
|
||||
.class {
|
||||
display: none;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue