Skip to content

Commit 08fe1c9

Browse files
committed
Rollback @prettier/plugin-xml (see prettier/plugin-xml#784)
craftercms/craftercms#7748
1 parent 619511b commit 08fe1c9

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

ui/app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@mui/x-data-grid": "^7.27.2",
7070
"@mui/x-date-pickers": "^7.27.1",
7171
"@mui/x-tree-view": "^7.26.0",
72-
"@prettier/plugin-xml": "3.4.1",
72+
"@prettier/plugin-xml": "3.3.0",
7373
"@reduxjs/toolkit": "^2.6.0",
7474
"@stomp/stompjs": "^7.0.0",
7575
"@tinymce/tinymce-react": "^5.1.1",

ui/app/src/utils/xml.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ export function serialize(doc: Node): string {
2828
return new XMLSerializer().serializeToString(doc);
2929
}
3030

31-
interface BeautifyOptions {
31+
export interface BeautifyOptions {
3232
tabWidth: number;
3333
printWidth: number;
34-
xmlWhitespaceSensitivity: 'ignore' | 'strict';
3534
xmlSelfClosingSpace: boolean;
35+
xmlWhitespaceSensitivity: 'strict' | 'preserve' | 'ignore';
36+
xmlSortAttributesByKey: boolean;
37+
xmlQuoteAttributes: 'preserve' | 'single' | 'double';
38+
singleAttributePerLine: boolean;
39+
bracketSameLine: boolean;
3640
}
3741

3842
export function beautify(xml: string): Promise<string>;
@@ -41,10 +45,13 @@ export function beautify(xml: string, options?: Partial<BeautifyOptions>): Promi
4145
return format(xml, {
4246
tabWidth: 2,
4347
printWidth: +Infinity,
48+
// @prettier/plugin-xml v3.3.1 breaks xmlWhitespaceSensitivity behaviour: encoded entities started
49+
// to get spaces in between the encoded `<`, `>`, and tag name, breaking the decoding.
50+
// Setting xmlWhitespaceSensitivity to 'preserve' would prevent the issue, but it has consequences
51+
// on the desired format result. See https://github.com/prettier/plugin-xml/issues/784.
4452
xmlWhitespaceSensitivity: 'ignore',
4553
xmlSelfClosingSpace: true,
4654
...options,
47-
// @ts-ignore
4855
parser: 'xml',
4956
plugins: [prettierXmlPlugin]
5057
});

yarn.lock

+12-1
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ __metadata:
15931593
"@mui/x-data-grid": "npm:^7.27.2"
15941594
"@mui/x-date-pickers": "npm:^7.27.1"
15951595
"@mui/x-tree-view": "npm:^7.26.0"
1596-
"@prettier/plugin-xml": "npm:3.4.1"
1596+
"@prettier/plugin-xml": "npm:3.3.0"
15971597
"@reduxjs/toolkit": "npm:^2.6.0"
15981598
"@rollup/plugin-swc": "npm:^0.4.0"
15991599
"@stomp/stompjs": "npm:^7.0.0"
@@ -3297,6 +3297,17 @@ __metadata:
32973297
languageName: node
32983298
linkType: hard
32993299

3300+
"@prettier/plugin-xml@npm:3.3.0":
3301+
version: 3.3.0
3302+
resolution: "@prettier/plugin-xml@npm:3.3.0"
3303+
dependencies:
3304+
"@xml-tools/parser": "npm:^1.0.11"
3305+
peerDependencies:
3306+
prettier: ^3.0.0
3307+
checksum: 10/0f33b044af7d7a79fdf73a4754aed56f73efbf200be24efa40ef5f52b849243ddfe5a27ec3f1ad7ffdc21b6b0015319509a37cd365f6f52466df41c0eeec3b4d
3308+
languageName: node
3309+
linkType: hard
3310+
33003311
"@prettier/plugin-xml@npm:3.4.1":
33013312
version: 3.4.1
33023313
resolution: "@prettier/plugin-xml@npm:3.4.1"

0 commit comments

Comments
 (0)