From 53f7b563d01058ea19b4eef8ca3efbf6d671b5a5 Mon Sep 17 00:00:00 2001 From: Andrew Jakubowicz Date: Mon, 8 Jan 2024 10:51:40 -0800 Subject: [PATCH] add regression test and fix self closing custom-element in another test --- .../src/test/rules/no-nullable-attribute-binding.ts | 2 +- packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/lit-analyzer/src/test/rules/no-nullable-attribute-binding.ts b/packages/lit-analyzer/src/test/rules/no-nullable-attribute-binding.ts index 3e788653..b0fed9a4 100644 --- a/packages/lit-analyzer/src/test/rules/no-nullable-attribute-binding.ts +++ b/packages/lit-analyzer/src/test/rules/no-nullable-attribute-binding.ts @@ -11,7 +11,7 @@ tsTest("Cannot assign 'undefined' in attribute binding", t => { tsTest("Can assign 'undefined' in property binding", t => { const { diagnostics } = getDiagnostics([ makeElement({ slots: ["foo: number | undefined"] }), - 'html``' + 'html``' ]); hasNoDiagnostics(t, diagnostics); }); diff --git a/packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts b/packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts index 3ce43a9e..fee9ecbb 100644 --- a/packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts +++ b/packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts @@ -30,6 +30,14 @@ tsTest("Report unclosed 'p' tag that is implicitly closed via tag omission conta hasDiagnostic(t, diagnostics, "no-unclosed-tag"); }); +// Regeression test for https://github.com/runem/lit-analyzer/issues/283 +tsTest("Report 'p' tag that is implicitly closed via tag omission containing a space", t => { + // Note, the browser will parse this case into: `

` which can be + // unexpected, but technically means the first `

` tag is not explicitly closed. + const { diagnostics } = getDiagnostics("html`

`", { rules: { "no-unclosed-tag": true } }); + hasDiagnostic(t, diagnostics, "no-unclosed-tag"); +}); + // Self-closing tags do not exist in HTML. They are only valid in SVG and MathML. tsTest("Report non-void element using self closing syntax", t => { const { diagnostics } = getDiagnostics("html`

`", { rules: { "no-unclosed-tag": true } });