Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Node, SourceFile, TaggedTemplateExpression } from "typescript";
import { tsModule } from "../../ts-module.js";
import { findParent, getNodeAtPosition } from "../../util/ast-util.js";
import { findParent, getNodeAtPosition, leadingCommentsIncludes } from "../../util/ast-util.js";
import { TS_IGNORE_FLAG } from "../../constants.js";

/**
* Returns all virtual documents in a given file.
Expand Down Expand Up @@ -51,9 +52,10 @@ export function visitTaggedTemplateNodes(astNode: Node, context: TaggedTemplateV
const newContext = { ...context };
if (tsModule.ts.isTaggedTemplateExpression(astNode) && context.shouldCheckTemplateTag(astNode.tag.getText())) {
// Only visit the template expression if the leading comments does not include the ts-ignore flag.
//if (!leadingCommentsIncludes(astNode.getSourceFile().getText(), astNode.getFullStart(), TS_IGNORE_FLAG)) {
newContext.parent = astNode;
context.emitTaggedTemplateNode(astNode);
if (!leadingCommentsIncludes(astNode.getSourceFile().getText(), astNode.getFullStart(), TS_IGNORE_FLAG)) {
newContext.parent = astNode;
context.emitTaggedTemplateNode(astNode);
}
}

astNode.forEachChild(child => visitTaggedTemplateNodes(child, context));
Expand Down
5 changes: 5 additions & 0 deletions packages/lit-analyzer/src/test/rules/no-unclosed-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ tsTest("Don't report self closed tags", t => {
const { diagnostics } = getDiagnostics("html`<img />`", { rules: { "no-unclosed-tag": true } });
hasNoDiagnostics(t, diagnostics);
});

tsTest("Don't report unclosed tags when it's been ignored", t => {
const { diagnostics } = getDiagnostics("// @ts-ignore\nhtml`<div>`", { rules: { "no-unclosed-tag": true } });
hasNoDiagnostics(t, diagnostics);
});
Loading