diff --git a/package.json b/package.json index 8ea145a6d..d96c25aee 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "acorn": "8.15.0", "acorn-jsx": "5.3.2", "angular-estree-parser": "15.3.0", - "angular-html-parser": "10.3.0", + "angular-html-parser": "10.5.0", "camelcase": "9.0.0", "ci-info": "4.3.1", "cjk-regex": "3.4.0", diff --git a/src/language-html/print/angular-control-flow-block.js b/src/language-html/print/angular-control-flow-block.js index 5f9690403..d55fe5eb2 100644 --- a/src/language-html/print/angular-control-flow-block.js +++ b/src/language-html/print/angular-control-flow-block.js @@ -20,6 +20,11 @@ function printAngularControlFlowBlock(path, options, print) { docs.push("@", node.name); + if (isSwitchExhaustiveCheck(node)) { + docs.push(";"); + return docs; + } + if (node.parameters) { docs.push(" (", group(print("parameters")), ")"); } @@ -53,6 +58,10 @@ function shouldCloseBlock(node) { const isSwitchCaseBlock = (node) => node?.kind === "angularControlFlowBlock" && (node.name === "case" || node.name === "default"); + +const isSwitchExhaustiveCheck = (node) => + node?.kind === "angularControlFlowBlock" && node.name === "default never"; + // https://github.com/angular/angular/commit/0ad3adc7c6d4094f1e3432a3f2e3bdc9862cb4fa#diff-77a6f285c6ea13d6644ef635e7495e71134d1141af2650cb9ae5631ff1f38bf2R263 // https://github.com/prettier/prettier/issues/18563#issuecomment-3728354491 function isSwitchFallthroughCase(node) { diff --git a/tests/format/angular/control-flow/__snapshots__/format.test.js.snap b/tests/format/angular/control-flow/__snapshots__/format.test.js.snap index 57d672535..bc8ba2192 100644 --- a/tests/format/angular/control-flow/__snapshots__/format.test.js.snap +++ b/tests/format/angular/control-flow/__snapshots__/format.test.js.snap @@ -77,6 +77,32 @@ printWidth: 80 ================================================================================ `; +exports[`default-never.html format 1`] = ` +====================================options===================================== +parsers: ["angular"] +printWidth: 80 + | printWidth +=====================================input====================================== +@switch ( cond.kind) { + @default never; +} + +@switch ( cond.kind) { + @default never ; +} + +=====================================output===================================== +@switch (cond.kind) { + @default never; +} + +@switch (cond.kind) { + @default never; +} + +================================================================================ +`; + exports[`defer.html format 1`] = ` ====================================options===================================== parsers: ["angular"] diff --git a/tests/format/angular/control-flow/default-never.html b/tests/format/angular/control-flow/default-never.html new file mode 100644 index 000000000..9f954fd91 --- /dev/null +++ b/tests/format/angular/control-flow/default-never.html @@ -0,0 +1,7 @@ +@switch ( cond.kind) { + @default never; +} + +@switch ( cond.kind) { + @default never ; +} diff --git a/yarn.lock b/yarn.lock index 889779b78..aafcc381b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2861,10 +2861,10 @@ __metadata: languageName: node linkType: hard -"angular-html-parser@npm:10.3.0": - version: 10.3.0 - resolution: "angular-html-parser@npm:10.3.0" - checksum: 10/97078879db8f53fc9645d2cd8c748c9eb3770790ec96f249bd96e0ab9293f65506b7facd201c17f2f18884e82550f3c362972e7b3a5448b0e1fb2a6938e9ef4d +"angular-html-parser@npm:10.5.0": + version: 10.5.0 + resolution: "angular-html-parser@npm:10.5.0" + checksum: 10/8544df535e0b111b44fbf8996141c63a2024f50912b08efaf28c91002260ad8b71af650c10a41aa6e3a0fd8c8f9750f40d4030c39587904aa816e0c88a108727 languageName: node linkType: hard @@ -7518,7 +7518,7 @@ __metadata: acorn: "npm:8.15.0" acorn-jsx: "npm:5.3.2" angular-estree-parser: "npm:15.3.0" - angular-html-parser: "npm:10.3.0" + angular-html-parser: "npm:10.5.0" base64-arraybuffer-es6: "npm:3.1.0" browserslist: "npm:4.28.0" browserslist-to-esbuild: "npm:2.1.1"