posthtml-lint
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

posthtml-lint

NPM Deps Build Coverage

Changelog

posthtml-lint is a PostHTML plugin to lint static markup.

Currently supported rules include no-duplicate-ids, no-duplicate-tags, no-empty-tags and no-missing-attributes.

Before:

<head>
  <title>Title</title>
  <title>Title</title>
</head>
<body>
  <a>Link</a>
</body>

After:

# Output printed to the terminal 
There are ...

Install

yarn add -D posthtml-lint
# OR 
npm i posthtml-lint

Usage

const fs = require('fs');
const posthtml = require('posthtml');
const { lint } = require('posthtml-lint');
 
const html = fs.readFileSync('./index.html');
 
posthtml()
  .use(lint())
  .process(html)
  .then(result => fs.writeFileSync('./after.html', result.html));

Options

Name Kind Description
noDuplicateIds boolean (default true) Disallow duplicate ids
noDuplicateTags boolean (default true) Disallow duplicate occurrences of the html, head, title and body tags
noEmptyTags boolean (default true) Disallow empty tags for tags that are not self-closing
noMissingAttributes boolean (default true) Disallow tags with missing required attributes.

Contributing

See PostHTML Guidelines and contribution guide.

License

MIT

Package Sidebar

Install

npm i posthtml-lint

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

12.9 kB

Total Files

17

Last publish

Collaborators

  • metonym