Writing plugins

A plugin must expose a single object:

module.exports = {
  /* ... */
};

Rules

See writing rules for details on how to write a rules.

To expose rules in the plugin use the plugin field. Each plugin should use a unique prefix for each rule.

const MyRule = require('./rules/my-rule.js');
const AnotherRule = require('./rules/another-rule.js');

module.exports = {
  rules: {
    "my-prefix/my-rule": MyRule,
    "my-prefix/another-rule": AnotherRule,
  },
};

This makes the rules accessable as usual when configuring in .htmlvalidate.json:

{
  "plugins": [
    "my-fancy-plugin",
  ],
  "rules": {
    "my-prefix/my-rule": "error"
  },
}