https://github.com/posthtml/posthtml-lint
PostHTML plugin to lint static markup
https://github.com/posthtml/posthtml-lint
lint posthtml posthtml-plugin
Last synced: 11 months ago
JSON representation
PostHTML plugin to lint static markup
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-lint
- Owner: posthtml
- License: mit
- Created: 2019-06-30T02:36:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T02:50:14.000Z (about 3 years ago)
- Last Synced: 2024-10-29T21:06:06.520Z (over 1 year ago)
- Topics: lint, posthtml, posthtml-plugin
- Language: TypeScript
- Size: 1.41 MB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# posthtml-lint 
[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Build][build]][build-badge]
[![Coverage][codecov-shield]][codecov]
## [Changelog](CHANGELOG.md)
`posthtml-lint` is a [PostHTML](https://github.com/posthtml/posthtml) plugin to lint static markup.
Currently supported rules include `no-duplicate-ids`, `no-duplicate-tags`, `no-empty-tags` and `no-missing-attributes`.
**Before:**
```html
Title
Title
```
**After:**
```bash
# Output printed to the terminal
There are ...
```
## Install
```bash
yarn add -D posthtml-lint
# OR
npm i posthtml-lint
```
## Usage
```js
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](https://github.com/posthtml/posthtml/tree/master/docs) and [contribution guide](CONTRIBUTING.md).
### License
[MIT](LICENSE)
[npm]: https://img.shields.io/npm/v/posthtml-lint.svg?color=blue
[npm-url]: https://npmjs.com/package/posthtml-lint
[deps]: https://david-dm.org/posthtml/posthtml-lint.svg
[deps-url]: https://david-dm.org/posthtml/posthtml-lint
[build]: https://travis-ci.com/posthtml/posthtml-lint.svg?branch=master
[build-badge]: https://travis-ci.com/posthtml/posthtml-lint
[codecov]: https://codecov.io/gh/posthtml/posthtml-lint
[codecov-shield]: https://img.shields.io/codecov/c/github/posthtml/posthtml-lint.svg