Fix SCSS parenthesized value group print (#16607)
This commit is contained in:
1 parent
60964140b0
commit
5cd15f2168
4 files changed
+58
-1
No files matched your search
@@ -0,0 +1,22 @@
|
||||
#### Fix error thrown when formatting SCSS file (#16607 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```scss
|
||||
// Input
|
||||
@if true {
|
||||
$newKey: ($key: ( $theme-name: $value ))
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
Error
|
||||
|
||||
// Prettier main
|
||||
@if true {
|
||||
$newKey: (
|
||||
$key:
|
||||
(
|
||||
$theme-name: $value,
|
||||
),
|
||||
);
|
||||
}
|
||||
```
|
||||
@@ -9,6 +9,12 @@ import {
|
||||
line,
|
||||
softline,
|
||||
} from "../../document/builders.js";
|
||||
import {
|
||||
DOC_TYPE_FILL,
|
||||
DOC_TYPE_GROUP,
|
||||
DOC_TYPE_INDENT,
|
||||
} from "../../document/constants.js";
|
||||
import { getDocType } from "../../document/utils.js";
|
||||
import isNextLineEmpty from "../../utils/is-next-line-empty.js";
|
||||
import isNonEmptyArray from "../../utils/is-non-empty-array.js";
|
||||
import { locEnd, locStart } from "../loc.js";
|
||||
@@ -91,7 +97,10 @@ function printParenthesizedValueGroup(path, options, print) {
|
||||
child.type === "value-comma_group" &&
|
||||
child.groups &&
|
||||
child.groups[0].type !== "value-paren_group" &&
|
||||
child.groups[2]?.type === "value-paren_group"
|
||||
child.groups[2]?.type === "value-paren_group" &&
|
||||
getDocType(doc) === DOC_TYPE_GROUP &&
|
||||
getDocType(doc.contents) === DOC_TYPE_INDENT &&
|
||||
getDocType(doc.contents.contents) === DOC_TYPE_FILL
|
||||
) {
|
||||
const { parts } = doc.contents.contents;
|
||||
parts[1] = group(parts[1]);
|
||||
|
||||
@@ -39,6 +39,29 @@ $icons: (
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-16594.scss format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["scss"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
@if true {
|
||||
$newKey: ($key: ( $theme-name: $value ))
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
@if true {
|
||||
$newKey: (
|
||||
$key:
|
||||
(
|
||||
$theme-name: $value,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`parens.scss format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["scss"]
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
@if true {
|
||||
$newKey: ($key: ( $theme-name: $value ))
|
||||
}
|
||||
Reference in new issue
Block a user