Commit 7fbf433f authored by David Sveningsson's avatar David Sveningsson

fix(rules): add contextual documentation for `deprecated`

parent fc2aa511
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`rule deprecated should contain contextual documentation 1`] = `
Object {
"description": "HTML5 has deprecated the \`<center>\` element. It should not be used in new code.",
"url": "https://html-validate.org/rules/deprecated.html",
}
`;
exports[`rule deprecated should contain documentation 1`] = `
Object {
"description": "HTML5 deprecated many old elements and they should not be used in new code.",
"description": "HTML5 has deprecated many old elements and they should not be used in new code.",
"url": "https://html-validate.org/rules/deprecated.html",
}
`;
......
......@@ -50,4 +50,10 @@ describe("rule deprecated", () => {
it("should contain documentation", () => {
expect(htmlvalidate.getRuleDocumentation("deprecated")).toMatchSnapshot();
});
it("should contain contextual documentation", () => {
expect(
htmlvalidate.getRuleDocumentation("deprecated", null, "center")
).toMatchSnapshot();
});
});
......@@ -2,13 +2,17 @@ import { sliceLocation } from "../context";
import { TagOpenEvent } from "../event";
import { Rule, RuleDocumentation, ruleDocumentationUrl } from "../rule";
class Deprecated extends Rule {
public documentation(): RuleDocumentation {
return {
class Deprecated extends Rule<string> {
public documentation(context?: string): RuleDocumentation {
const doc: RuleDocumentation = {
description:
"HTML5 deprecated many old elements and they should not be used in new code.",
"HTML5 has deprecated many old elements and they should not be used in new code.",
url: ruleDocumentationUrl(__filename),
};
if (context) {
doc.description = `HTML5 has deprecated the \`<${context}>\` element. It should not be used in new code.`;
}
return doc;
}
public setup(): void {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment