Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(tag-check): Add example and explain all options #1383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 56 additions & 2 deletions docs/user-guide/rules/tags-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,61 @@ id: tags-check
title: tags-check
---

Allowing specify rules for any tag and validate that
Check if particular tags are self-closing or must include or exclude particular tags.

Level: `error`

## Config value

1. true: enable rule
2. false: disable rule
3. {}: configuration object, mapping values of tags to their respective configuration. Tags configuration can have properties of:

`selfclosing`

If an element is or is not self-closing, when it otherwise should be.

Level: `warn`

`attrsRequired`

If an element is missing an attribute that should exist.

Level: `error`

`redundantAttrs`

If an element has an attribute that is not necessary.

Level: `error`

`attrsOptional`

If an element has an attribute that is not included in the allowable set.

Level: `error`

### Example

```json
{
...
"tags-check": {
"a": {
"selfclosing": true,
"attrsRequired": ["href", "title"],
"redundantAttrs": ["alt"],
}
},
"script": {
"attrsOptional": [
["async", "async"],
["defer", "defer"],
],
},
...
}
```

The following pattern are **not** considered violations:

Expand All @@ -15,7 +69,7 @@ The following pattern are **not** considered violations:
<img src="bbb" title="aaa" alt="asd" />
```

The following pattern is considered violation:
The following pattern is considered a violation:

<!-- prettier-ignore -->
```html
Expand Down