diff --git a/package.json b/package.json index 24f6e066e..0995693f7 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "acorn": "8.17.0", "acorn-jsx": "5.3.2", "angular-estree-parser": "15.5.0", - "angular-html-parser": "10.7.0", + "angular-html-parser": "10.8.0", "camelcase": "9.0.0", "ci-info": "4.4.0", "cjk-regex": "3.4.0", diff --git a/src/language-html/parse/parse-options.js b/src/language-html/parse/parse-options.js index 47574d008..fe2487272 100644 --- a/src/language-html/parse/parse-options.js +++ b/src/language-html/parse/parse-options.js @@ -25,6 +25,7 @@ const DEFAULT_PARSE_OPTIONS = { normalizeTagName: false, normalizeAttributeName: false, allowHtmComponentClosingTags: false, + allowInElementComments: false, isTagNameCaseSensitive: false, shouldParseFrontMatter: true, }; diff --git a/tests/config/format-test/verify-fixtures.js b/tests/config/format-test/verify-fixtures.js index 247cd1065..bf7a5dbdd 100644 --- a/tests/config/format-test/verify-fixtures.js +++ b/tests/config/format-test/verify-fixtures.js @@ -46,7 +46,11 @@ const categoryParsers = new Map([ ], [ "html", - { parsers: ["html"], verifyParsers: [], extensions: [".html", ".svg"] }, + { + parsers: ["html"], + verifyParsers: ["vue", "mjml", "lwc", "angular"], + extensions: [".html", ".svg"], + }, ], [ "mjml", diff --git a/tests/format/html/_errors_/in-element-comments/__snapshots__/format.test.js.snap b/tests/format/html/_errors_/in-element-comments/__snapshots__/format.test.js.snap new file mode 100644 index 000000000..d1aeb8d43 --- /dev/null +++ b/tests/format/html/_errors_/in-element-comments/__snapshots__/format.test.js.snap @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`block-comment.html format[angular] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 |
+ | ^^^^^^ + 2 | +Cause: Opening tag "div" not terminated." +`; + +exports[`block-comment.html format[html] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + | ^^^^^^ + 2 | +Cause: Opening tag "div" not terminated." +`; + +exports[`block-comment.html format[lwc] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + | ^^^^^^ + 2 | +Cause: Opening tag "div" not terminated." +`; + +exports[`block-comment.html format[mjml] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + | ^^^^^^ + 2 | +Cause: Opening tag "div" not terminated." +`; + +exports[`block-comment.html format[vue] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + | ^^^^^^ + 2 | +Cause: Opening tag "div" not terminated." +`; + +exports[`line-comment.html format[angular] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + 3 | +Cause: Opening tag "div" not terminated." +`; + +exports[`line-comment.html format[html] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + 3 | +Cause: Opening tag "div" not terminated." +`; + +exports[`line-comment.html format[lwc] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + 3 | +Cause: Opening tag "div" not terminated." +`; + +exports[`line-comment.html format[mjml] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + 3 | +Cause: Opening tag "div" not terminated." +`; + +exports[`line-comment.html format[vue] 1`] = ` +"Opening tag "div" not terminated. (1:1) +> 1 | + 3 | +Cause: Opening tag "div" not terminated." +`; diff --git a/tests/format/html/_errors_/in-element-comments/block-comment.html b/tests/format/html/_errors_/in-element-comments/block-comment.html new file mode 100644 index 000000000..b98b0116f --- /dev/null +++ b/tests/format/html/_errors_/in-element-comments/block-comment.html @@ -0,0 +1 @@ + diff --git a/tests/format/html/_errors_/in-element-comments/format.test.js b/tests/format/html/_errors_/in-element-comments/format.test.js new file mode 100644 index 000000000..2af3dd93d --- /dev/null +++ b/tests/format/html/_errors_/in-element-comments/format.test.js @@ -0,0 +1,8 @@ +runFormatTest(import.meta, [ + "html", + "vue", + "lwc", + "mjml", + // https://github.com/prettier/prettier/issues/18974 + "angular", +]); diff --git a/tests/format/html/_errors_/in-element-comments/line-comment.html b/tests/format/html/_errors_/in-element-comments/line-comment.html new file mode 100644 index 000000000..39d8c0744 --- /dev/null +++ b/tests/format/html/_errors_/in-element-comments/line-comment.html @@ -0,0 +1,2 @@ + diff --git a/yarn.lock b/yarn.lock index e75e6530f..5cec97c08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3053,10 +3053,10 @@ __metadata: languageName: node linkType: hard -"angular-html-parser@npm:10.7.0": - version: 10.7.0 - resolution: "angular-html-parser@npm:10.7.0" - checksum: 10/bd71365b60354fc1a58c309be249717a027f8616ce6d5b0bb716bb2aa32538f940c11c95e69ee62e0a39e6a85b31dd6b63a5fcc6c12b1e8e83a377388ceeeafd +"angular-html-parser@npm:10.8.0": + version: 10.8.0 + resolution: "angular-html-parser@npm:10.8.0" + checksum: 10/1417dbd93bec0b3b176a56ded0084cd07d67056327bce98faf9f9fda3fcde156c3c98cc975cfe8e5c4abbc3db47a2a3466be45c19df8e1a0531b3c949f7d4cb2 languageName: node linkType: hard @@ -8120,7 +8120,7 @@ __metadata: acorn: "npm:8.17.0" acorn-jsx: "npm:5.3.2" angular-estree-parser: "npm:15.5.0" - angular-html-parser: "npm:10.7.0" + angular-html-parser: "npm:10.8.0" base64-arraybuffer-es6: "npm:3.1.0" browserslist: "npm:4.28.2" browserslist-to-esbuild: "npm:2.1.1"