@selective/lint

Apply selective rules to an HTML string

Usage no npm install needed!

<script type="module">
  import selectiveLint from 'https://cdn.skypack.dev/@selective/lint';
</script>

README

selective lint">

NPM Version Linux Build Status Windows Build status

Creates a Rehype plugin from JSON rules to check for HTML anti patterns and reports issues back as vFile messages

Installation

# npm
npm install @selective/lint

# yarn
yarn add @selective/lint

Usage

const rehype = require("rehype");
const lint = require("@selective/lint");
const { readFileSync } = require("fs");

rehype()
  .use(lint, [
    {
      name: "img-alt",
      description: "image tag must contain an alt property",
      recommended: "warn",
      selector: "img:not([alt])",
    },
  ])
  .process(readFileSync("somefile.html"), (err) => {
    console.error(err);
  });

References