fix: newline between front-matter and comment (#4701)

master
Evilebot Tnawi 2018-06-15 16:27:41 +03:00 committed by GitHub
parent 56af3d621d
commit 03a2002348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 5 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -0,0 +1,7 @@
---
title: Title
description: Description
---
/* comment */
.something {
}

View File

@ -0,0 +1,7 @@
---
title: Title
description: Description
---
a {
color: red;
}

View File

@ -10,7 +10,8 @@ something
---
something
---
/** @format */
/** @format */
.class {
display: none;
}

View File

@ -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;
}