fix: preserve empty lines between nested SCSS maps (#13931)

Co-authored-by: Jeremy Neander <jeremy.neander@glassdoor.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
authored and GitHub committed 2022-12-15 14:54:47 +08:00
1 parent d24d74930e
commit b50dfd1974
3 files changed
+47 -4

No files matched your search

+10 -4
View File
@@ -918,7 +918,8 @@ function genericPrint(path, options, print) {
path.map((childPath, index) => {
const child = childPath.getValue();
const isLast = index === node.groups.length - 1;
const printed = [print(), isLast ? "" : ","];
let printed = [print(), isLast ? "" : ","];
// Key/Value pair in open paren already indented
if (
@@ -931,7 +932,7 @@ function genericPrint(path, options, print) {
) {
const parts = getDocParts(printed[0].contents.contents);
parts[1] = group(parts[1]);
return group(dedent(printed));
printed = [group(dedent(printed))];
}
if (
@@ -939,9 +940,14 @@ function genericPrint(path, options, print) {
child.type === "value-comma_group" &&
isNonEmptyArray(child.groups)
) {
const last = getLast(child.groups);
let last = getLast(child.groups);
// `value-paren_group` does not have location info, but its closing parenthesis does.
if (!last.source && last.close) {
last = last.close;
}
if (
// `value-paren_group` missing location info
last.source &&
isNextLineEmpty(options.originalText, last, locEnd)
) {