Skip to content

Commit f1a7472

Browse files
authored
Merge branch 'main' into feature/cmt--empty-allow-func
2 parents 81b7e66 + 717731d commit f1a7472

31 files changed

Lines changed: 889 additions & 237 deletions

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- name: Setup Node.js
2727
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
2828
with:
29+
node-version: "24"
2930
cache: "yarn"
3031

3132
- name: Install Dependencies

.vscode/settings.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][json5][markdown][yaml][css][html]": {
2+
"[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][json5][markdown][yaml][css][html][vue]": {
33
"editor.defaultFormatter": "prettier.prettier-vscode",
44
"editor.formatOnSave": true,
55
},

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,10 @@ You can run `FULL_TEST=1 jest` for a more robust test run, which includes the fo
127127
- **BOM** - checks that adding BOM (`U+FEFF`) to the input affects the output in only one way: the BOM is preserved.
128128
129129
Usually there is no need to run these extra checks locally, since they're run on the CI anyway.
130+
131+
## AI usage policy
132+
133+
- Only submit code you fully understand and have tested.
134+
- Be prepared to explain your changes.
135+
- Do not ignore our issue and PR templates.
136+
- Low-quality AI content will be closed immediately.

changelog_unreleased/scss/18535.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#### Fix comment print in maps (#18535 by @kovsu)
2+
3+
<!-- prettier-ignore -->
4+
```scss
5+
// Input
6+
$map: (
7+
// comment
8+
);
9+
10+
// Prettier stable
11+
$map: (// comment);
12+
13+
// Prettier main
14+
$map: (
15+
// comment
16+
);
17+
```

src/cli/options/create-minimist-options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export default function createMinimistOptions(detailedOptions) {
22
const booleanNames = [];
3-
const stringNames = [];
3+
// Numeric-looking arguments will be returned as numbers unless opts.string or opts.boolean contains that argument name.
4+
// To disable numeric conversion for non-option arguments, add '_' to opts.string.
5+
// https://github.com/minimistjs/minimist#const-argv--parseargsargs-opts
6+
const stringNames = ["_"];
47
const defaultValues = {};
58

69
for (const option of detailedOptions) {

src/cli/options/parse-cli-arguments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function parseArgv(rawArguments, detailedOptions, logger, keys) {
2828
return [option.forwardToApi || camelCase(key), value];
2929
}),
3030
),
31-
_: normalized._?.map(String),
31+
_: normalized._,
3232
get __raw() {
3333
return argv;
3434
},

src/language-css/print/parenthesized-value-group.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
indent,
1313
join,
1414
line,
15+
lineSuffixBoundary,
1516
softline,
1617
} from "../../document/index.js";
1718
import isNextLineEmpty from "../../utilities/is-next-line-empty.js";
@@ -131,6 +132,7 @@ function printParenthesizedValueGroup(path, options, print) {
131132

132133
return parts;
133134
}, "groups");
135+
134136
const isKey = isKeyInValuePairNode(node, parent);
135137
const isConfiguration = isConfigurationNode(node, parent);
136138
const isSCSSMapItem = isSCSSMapItemNode(path, options);
@@ -142,6 +144,7 @@ function printParenthesizedValueGroup(path, options, print) {
142144
node.open ? print("open") : "",
143145
indent([softline, join(line, parts)]),
144146
softline,
147+
lineSuffixBoundary,
145148
node.close ? print("close") : "",
146149
],
147150
{

src/language-css/printer-postcss.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
indent,
88
join,
99
line,
10+
lineSuffix,
11+
lineSuffixBoundary,
1012
removeLines,
1113
softline,
1214
} from "../document/index.js";
@@ -208,7 +210,7 @@ function genericPrint(path, options, print) {
208210
"@",
209211
node.name,
210212
": ",
211-
node.value ? print("value") : "",
213+
node.value ? [print("value"), lineSuffixBoundary] : "",
212214
node.raws.between.trim() ? node.raws.between.trim() + " " : "",
213215
node.nodes
214216
? [
@@ -506,9 +508,10 @@ function genericPrint(path, options, print) {
506508
case "value-root":
507509
return print("group");
508510

509-
case "value-comment":
510-
return options.originalText.slice(locStart(node), locEnd(node));
511-
511+
case "value-comment": {
512+
const text = options.originalText.slice(locStart(node), locEnd(node));
513+
return node.inline ? lineSuffix(text.trimEnd()) : text;
514+
}
512515
case "value-comma_group":
513516
return printCommaSeparatedValueGroup(path, options, print);
514517

tests/format/scss/map/__snapshots__/format.test.js.snap

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,14 @@ $map: (
10271027
),
10281028
);
10291029
1030+
$map: (
1031+
/* comment */
1032+
);
1033+
1034+
$map: (
1035+
// comment
1036+
);
1037+
10301038
=====================================output=====================================
10311039
$map: (
10321040
/* comment */ key1: value,
@@ -1046,6 +1054,12 @@ $map: (
10461054
)
10471055
);
10481056
1057+
$map: (/* comment */);
1058+
1059+
$map: (
1060+
// comment
1061+
);
1062+
10491063
================================================================================
10501064
`;
10511065

@@ -1076,6 +1090,14 @@ $map: (
10761090
),
10771091
);
10781092
1093+
$map: (
1094+
/* comment */
1095+
);
1096+
1097+
$map: (
1098+
// comment
1099+
);
1100+
10791101
=====================================output=====================================
10801102
$map: (
10811103
/* comment */ key1: value,
@@ -1095,6 +1117,12 @@ $map: (
10951117
)
10961118
);
10971119
1120+
$map: (/* comment */);
1121+
1122+
$map: (
1123+
// comment
1124+
);
1125+
10981126
================================================================================
10991127
`;
11001128

tests/format/scss/map/comment.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ $map: (
1717
key: value,
1818
),
1919
);
20+
21+
$map: (
22+
/* comment */
23+
);
24+
25+
$map: (
26+
// comment
27+
);

0 commit comments

Comments
 (0)