import { BaseRuleVisitor } from "./rule-utils.js";
class TagNameLowercaseVisitor extends BaseRuleVisitor {
    visitHTMLOpenTagNode(node) {
        this.checkTagName(node);
        this.visitChildNodes(node);
    }
    visitHTMLCloseTagNode(node) {
        this.checkTagName(node);
        this.visitChildNodes(node);
    }
    visitHTMLSelfCloseTagNode(node) {
        this.checkTagName(node);
        this.visitChildNodes(node);
    }
    checkTagName(node) {
        const tagName = node.tag_name?.value;
        if (!tagName)
            return;
        if (tagName !== tagName.toLowerCase()) {
            let type = node.type;
            if (node.type == "AST_HTML_OPEN_TAG_NODE")
                type = "Opening";
            if (node.type == "AST_HTML_CLOSE_TAG_NODE")
                type = "Closing";
            if (node.type == "AST_HTML_SELF_CLOSE_TAG_NODE")
                type = "Self-closing";
            this.addOffense(`${type} tag name \`${tagName}\` should be lowercase. Use \`${tagName.toLowerCase()}\` instead.`, node.tag_name.location, "error");
        }
    }
}
export class HTMLTagNameLowercaseRule {
    name = "html-tag-name-lowercase";
    check(node) {
        const visitor = new TagNameLowercaseVisitor(this.name);
        visitor.visit(node);
        return visitor.offenses;
    }
}
//# sourceMappingURL=html-tag-name-lowercase.js.map