Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add trailing comma for grouped scss comments #15217

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions changelog_unreleased/scss/15217.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#### Do not add trailing comma for grouped scss comments (#15217 by @auvred)

<!-- prettier-ignore -->
```scss
/* Input */
$foo: (
'property': (),
// comment 1
// comment 2
)

/* Prettier stable */
$foo: (
"property": (),
// comment 1
// comment 2,
);

/* Prettier main */
$foo: (
"property": (),
// comment 1
// comment 2
);
```
4 changes: 4 additions & 0 deletions src/language-css/print/parenthesized-value-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ function printTrailingComma(path, options) {

if (
path.node.type !== "value-comment" &&
!(
path.node.type === "value-comma_group" &&
path.node.groups.every((group) => group.type === "value-comment")
) &&
shouldPrintTrailingComma(options) &&
path.callParent(() => isSCSSMapItemNode(path, options))
) {
Expand Down
38 changes: 38 additions & 0 deletions tests/format/scss/scss/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,17 @@ label {
div {
margin: - pow(2, 2) * 100px;
}
$foo: (
'property1': (),
// comment 1
// comment 2
'property2': 1,
/** comment 1 */
/* comment 2 */
);
=====================================output=====================================
@media #{$g-breakpoint-tiny} {
}
Expand Down Expand Up @@ -2631,6 +2642,14 @@ div {
margin: - pow(2, 2) * 100px;
}
$foo: (
"property1": (),
// comment 1
// comment 2
"property2": 1,
/** comment 1 */ /* comment 2 */
);
================================================================================
`;

Expand Down Expand Up @@ -3732,6 +3751,17 @@ label {
div {
margin: - pow(2, 2) * 100px;
}
$foo: (
'property1': (),
// comment 1
// comment 2
'property2': 1,
/** comment 1 */
/* comment 2 */
);
=====================================output=====================================
@media #{$g-breakpoint-tiny} {
}
Expand Down Expand Up @@ -4805,6 +4835,14 @@ div {
margin: - pow(2, 2) * 100px;
}
$foo: (
"property1": (),
// comment 1
// comment 2
"property2": 1,
/** comment 1 */ /* comment 2 */
);
================================================================================
`;

Expand Down
12 changes: 11 additions & 1 deletion tests/format/scss/scss/scss.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1088,4 +1088,14 @@ label {
// #5636
div {
margin: - pow(2, 2) * 100px;
}
}

$foo: (
'property1': (),
// comment 1
// comment 2

'property2': 1,
/** comment 1 */
/* comment 2 */
);