import { BaseRuleVisitor, getTagName, hasAttribute } from "./rule-utils.js";
class ImgRequireAltVisitor extends BaseRuleVisitor {
    visitHTMLOpenTagNode(node) {
        this.checkImgTag(node);
        super.visitHTMLOpenTagNode(node);
    }
    visitHTMLSelfCloseTagNode(node) {
        this.checkImgTag(node);
        super.visitHTMLSelfCloseTagNode(node);
    }
    checkImgTag(node) {
        const tagName = getTagName(node);
        if (tagName !== "img") {
            return;
        }
        if (!hasAttribute(node, "alt")) {
            this.addOffense('Missing required `alt` attribute on `<img>` tag. Add `alt=""` for decorative images or `alt="description"` for informative images.', node.tag_name.location, "error");
        }
    }
}
export class HTMLImgRequireAltRule {
    name = "html-img-require-alt";
    check(node) {
        const visitor = new ImgRequireAltVisitor(this.name);
        visitor.visit(node);
        return visitor.offenses;
    }
}
//# sourceMappingURL=html-img-require-alt.js.map