Skip to content

Commit 19c8833

Browse files
committed
docs: documentation for new configuration structure (#447)
* docs: new configuration structure for alt-require * docs: new configuration structure for attr-lowercase * docs: new configuration structure for attr-no-duplication * docs: new configuration structure for attr-no-unnecessary-whitespace * docs: update getting started * docs: add missing rules * docs: fix broken links * docs: new configuration structure for attr-sorted * docs: remove unnecessary prettier-ignore * docs: new configuration structure for attr-unsafe-chars * docs: new configuration structure for attr-value-double-quotes * docs: new configuration structure for attr-value-not-empty * docs: use texts from rules * docs: new configuration structure for attr-value-single-quotes * docs: new configuration structure for attr-whitespace * docs: new configuration structure for doctype-first * docs: new configuration structure for doctype-html5 * docs: remove empty-tag-not-self-closed * docs: new configuration structure for head-script-disabled * docs: new configuration structure for href-abs-or-rel * docs: new configuration structure for id-class-ad-disabled * docs: new configuration structure for id-class-value * docs: new configuration structure for id-unique * docs: new configuration structure for inline-script-disabled * docs: new configuration structure for inline-style-disabled * docs: new configuration structure for input-requires-label * docs: new configuration structure * docs: update doc attr-whitespace * docs: update doc tags-check * docs: update doc tagname-specialchars * docs: update doc
1 parent 6f933cf commit 19c8833

30 files changed

+1156
-219
lines changed

docs/user-guide/getting-started.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ yarn add --dev htmlhint
3838

3939
```shell
4040
{
41-
"attr-value-not-empty": false
41+
"attr-value-not-empty": "off"
4242
}
4343
```
4444

docs/user-guide/list-rules.md

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ title: List of rules
3030
- [`tag-pair`](/docs/user-guide/rules/tag-pair): Tag must be paired.
3131
- [`tag-self-close`](/docs/user-guide/rules/tag-self-close): Empty tags must be self closed.
3232
- [`tagname-lowercase`](/docs/user-guide/rules/tagname-lowercase): All html element names must be in lowercase.
33-
- [`empty-tag-not-self-closed`](/docs/user-guide/rules/empty-tag-not-self-closed): The empty tag should not be closed by self.
3433
- [`src-not-empty`](/docs/user-guide/rules/src-not-empty): The src attribute of an img(script,link) must have a value.
3534
- [`href-abs-or-rel`](/docs/user-guide/rules/href-abs-or-rel): An href attribute must be either absolute or relative.
3635

docs/user-guide/rules/attr-no-duplication.md

+33-9
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,49 @@ id: attr-no-duplication
33
title: attr-no-duplication
44
---
55

6-
The same attribute can't be specified twice.
6+
Elements cannot have duplicate attributes.
7+
8+
## Possible Configuration Values
9+
10+
```json
11+
{
12+
"attr-no-duplication": "off",
13+
"attr-no-duplication": "warn",
14+
"attr-no-duplication": "error",
15+
"attr-no-duplication": ["off"],
16+
"attr-no-duplication": ["warn"],
17+
"attr-no-duplication": ["error"]
18+
}
19+
```
720

8-
Level: `error`
21+
## Default
922

10-
## Config value
23+
```json
24+
{ "attr-no-duplication": "error" }
25+
```
1126

12-
1. true: enable rule
13-
2. false: disable rule
27+
---
1428

15-
The following pattern are **not** considered violations:
29+
## Examples
30+
31+
Examples of **correct** code for this rule:
1632

17-
<!-- prettier-ignore -->
1833
```html
1934
<img src="a.png" />
2035
```
2136

22-
The following pattern is considered violation:
37+
Examples of **incorrect** code for this rule:
2338

24-
<!-- prettier-ignore -->
2539
```html
2640
<img src="a.png" src="b.png" />
2741
```
42+
43+
---
44+
45+
## When Not To Use It
46+
47+
You always want to use this rule.
48+
49+
## Version
50+
51+
This rule was introduced in HTMLHint `v0.9.6`.

docs/user-guide/rules/attr-no-unnecessary-whitespace.md

+38-7
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,56 @@ title: attr-no-unnecessary-whitespace
55

66
No spaces between attribute names and values.
77

8-
Level: `error`
8+
## Possible Configuration Values
9+
10+
```json
11+
{
12+
"attr-no-unnecessary-whitespace": "off",
13+
"attr-no-unnecessary-whitespace": "warn",
14+
"attr-no-unnecessary-whitespace": "error",
15+
"attr-no-unnecessary-whitespace": ["off"],
16+
"attr-no-unnecessary-whitespace": ["warn", { "exceptions": ["test"] }],
17+
"attr-no-unnecessary-whitespace": ["error", { "exceptions": ["test"] }]
18+
}
19+
```
20+
21+
## Default
922

10-
## Config value
23+
```json
24+
{ "attr-no-unnecessary-whitespace": "error" }
25+
```
1126

12-
1. true: enable rule
13-
2. false: disable rule
27+
## Options
1428

15-
The following pattern are **not** considered violations:
29+
This rule has an object option:
30+
31+
- `"exceptions": ['test']` ignore some attribute names.
32+
33+
---
34+
35+
## Examples
36+
37+
Examples of **correct** code for this rule:
1638

17-
<!-- prettier-ignore -->
1839
```html
1940
<div title="a"></div>
2041
```
2142

22-
The following pattern is considered violation:
43+
Examples of **incorrect** code for this rule:
2344

2445
<!-- prettier-ignore -->
2546
```html
2647
<div title = "a"></div>
2748
<div title= "a"></div>
2849
<div title ="a"></div>
2950
```
51+
52+
---
53+
54+
## When Not To Use It
55+
56+
If your project will use spaces between attribute names and values.
57+
58+
## Version
59+
60+
This rule was introduced in HTMLHint `v0.13.0`.

docs/user-guide/rules/attr-sorted.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
id: attr-sorted
3+
title: attr-sorted
4+
---
5+
6+
Attribute tags must be in proper order.
7+
8+
## Possible Configuration Values
9+
10+
```json
11+
{
12+
"attr-sorted": "off",
13+
"attr-sorted": "warn",
14+
"attr-sorted": "error",
15+
"attr-sorted": ["off"],
16+
"attr-sorted": ["warn"],
17+
"attr-sorted": ["error"]
18+
}
19+
```
20+
21+
## Default
22+
23+
```json
24+
{ "attr-sorted": "off" }
25+
```
26+
27+
---
28+
29+
## Examples
30+
31+
Examples of **correct** code for this rule:
32+
33+
```html
34+
<img alt="test" src="test.png" />
35+
```
36+
37+
Examples of **incorrect** code for this rule:
38+
39+
```html
40+
<img src="test.png" alt="test" />
41+
```
42+
43+
---
44+
45+
## When Not To Use It
46+
47+
If your project will use attributes in an unsorted order.
48+
49+
## Version
50+
51+
This rule was introduced in HTMLHint `v0.11.0`.

docs/user-guide/rules/attr-unsafe-chars.md

+37-13
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,61 @@ id: attr-unsafe-chars
33
title: attr-unsafe-chars
44
---
55

6-
Attribute value cannot use unsafe chars.
6+
Attribute values cannot contain unsafe chars.
77

8-
regexp: `/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/`
8+
Checks against regexp pattern: `/[\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/`
99

10-
Level: `warning`
10+
## Possible Configuration Values
1111

12-
## Config value
12+
```json
13+
{
14+
"attr-unsafe-chars": "off",
15+
"attr-unsafe-chars": "warn",
16+
"attr-unsafe-chars": "error",
17+
"attr-unsafe-chars": ["off"],
18+
"attr-unsafe-chars": ["warn"],
19+
"attr-unsafe-chars": ["error"]
20+
}
21+
```
22+
23+
## Default
24+
25+
```json
26+
{ "attr-unsafe-chars": "off" }
27+
```
28+
29+
---
1330

14-
1. true: enable rule
15-
2. false: disable rule
31+
## Examples
1632

17-
The following pattern are **not** considered violations:
33+
Examples of **correct** code for this rule:
1834

19-
<!-- prettier-ignore -->
2035
```html
2136
<li>
2237
<a href="https://vimeo.com/album/1951235/video/56931059">Sud Web 2012</a>
2338
</li>
2439
```
2540

26-
The following pattern is considered violation:
41+
Examples of **incorrect** code for this rule:
2742

28-
<!-- prettier-ignore -->
2943
```html
3044
<li>
31-
<a href="https://vimeo.com/album/1951235/video/56931059‎\u0009‎"
32-
>Sud Web 2012</a
33-
>
45+
<a href="https://vimeo.com/album/1951235/video/56931059‎\u0009‎">
46+
Sud Web 2012
47+
</a>
3448
</li>
3549
```
3650

3751
:::tip
3852
The unsafe chars is in the tail of the href attribute.
3953
:::
54+
55+
---
56+
57+
## When Not To Use It
58+
59+
If your project will use unsafe chars.
60+
61+
## Version
62+
63+
This rule was introduced in HTMLHint `v0.9.6`.

docs/user-guide/rules/attr-value-double-quotes.md

+33-8
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,50 @@ id: attr-value-double-quotes
33
title: attr-value-double-quotes
44
---
55

6-
Attribute value must closed by double quotes.
6+
Attribute values must be in double quotes.
7+
8+
## Possible Configuration Values
9+
10+
```json
11+
{
12+
"attr-value-double-quotes": "off",
13+
"attr-value-double-quotes": "warn",
14+
"attr-value-double-quotes": "error",
15+
"attr-value-double-quotes": ["off"],
16+
"attr-value-double-quotes": ["warn"],
17+
"attr-value-double-quotes": ["error"]
18+
}
19+
```
20+
21+
## Default
722

8-
Level: `error`
23+
```json
24+
{ "attr-value-double-quotes": "error" }
25+
```
926

10-
## Config value
27+
---
1128

12-
1. true: enable rule
13-
2. false: disable rule
29+
## Examples
1430

15-
The following pattern are **not** considered violations:
31+
Examples of **correct** code for this rule:
1632

17-
<!-- prettier-ignore -->
1833
```html
1934
<a href="" title="abc"></a>
2035
```
2136

22-
The following pattern is considered violation:
37+
Examples of **incorrect** code for this rule:
2338

2439
<!-- prettier-ignore -->
2540
```html
2641
<a href='' title='abc'></a>
2742
```
43+
44+
---
45+
46+
## When Not To Use It
47+
48+
If your project will use single quotes for attribute values.
49+
50+
## Version
51+
52+
This rule was introduced in HTMLHint `v0.9.1`.

docs/user-guide/rules/attr-value-not-empty.md

+33-9
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,49 @@ id: attr-value-not-empty
33
title: attr-value-not-empty
44
---
55

6-
Attribute must set value.
6+
All attributes must have values.
7+
8+
## Possible Configuration Values
9+
10+
```json
11+
{
12+
"attr-value-not-empty": "off",
13+
"attr-value-not-empty": "warn",
14+
"attr-value-not-empty": "error",
15+
"attr-value-not-empty": ["off"],
16+
"attr-value-not-empty": ["warn"],
17+
"attr-value-not-empty": ["error"]
18+
}
19+
```
720

8-
Level: `warning`
21+
## Default
922

10-
## Config value
23+
```json
24+
{ "attr-lowercase": "off" }
25+
```
1126

12-
1. true: enable rule
13-
2. false: disable rule
27+
---
1428

15-
The following pattern are **not** considered violations:
29+
## Examples
30+
31+
Examples of **correct** code for this rule:
1632

17-
<!-- prettier-ignore -->
1833
```html
1934
<input type="button" disabled="disabled" />
2035
```
2136

22-
The following pattern is considered violation:
37+
Examples of **incorrect** code for this rule:
2338

24-
<!-- prettier-ignore -->
2539
```html
2640
<input type="button" disabled />
2741
```
42+
43+
---
44+
45+
## When Not To Use It
46+
47+
If your project will use attributes that doesn't need a value.
48+
49+
## Version
50+
51+
This rule was introduced in HTMLHint `v0.9.1`.

0 commit comments

Comments
 (0)