Skip to content

Using a custom html-validate rule #45

Answered by ext
Axel3005 asked this question in Q&A
Discussion options

You must be logged in to vote

To add custom rules you must create a plugin with the rule definitions.

Something similar to

/* CustomRule is a class inheriting from Rule, as per documentation */
const CustomRule = require("./rules/my-rule.js");

/* plugin which adds the "my-prefix/custom-rule" definition */
module.exports = {
  rules: {
    "my-prefix/custom-rule": AnotherRule,
  },
};

The plugin would be added like this:

       extends: [
         'html-validate:recommended',
       ],
+      plugins: [
+        "my-plugin" // npm package or local path
+      ],
       rules: {
-        "custom-rule": "error",
+        "my-prefix/custom-rule": "error",
         "no-raw-characters": "warn",

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by danielroe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #44 on April 19, 2021 11:04.