Skip to content

Commit 37d2937

Browse files
author
Shinigami
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 33ed9a1 commit 37d2937

35 files changed

+1340
-254
lines changed

Diff for: docs/user-guide/getting-started.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ yarn add --dev htmlhint
3838

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

45-
3\. Run HTMLHint on, for example, all the CSS files in your project:
45+
3\. Run HTMLHint on, for example, all the HTML files in your project:
4646

4747
```shell
4848
npx htmlhint "**/*.html"

Diff for: docs/user-guide/list-rules.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ title: List of rules
1717

1818
- [`attr-lowercase`](/docs/user-guide/rules/attr-lowercase): All attribute names must be in lowercase.
1919
- [`attr-no-duplication`](/docs/user-guide/rules/attr-no-duplication): Elements cannot have duplicate attributes.
20-
- [`attr-no-unnecessary-whitespace`](/docs/user-guide/rules/attr-no-unnecessary-whitespace.md): No spaces between attribute names and values.
20+
- [`attr-no-unnecessary-whitespace`](/docs/user-guide/rules/attr-no-unnecessary-whitespace): No spaces between attribute names and values.
2121
- [`attr-unsafe-chars`](/docs/user-guide/rules/attr-unsafe-chars): Attribute values cannot contain unsafe chars.
2222
- [`attr-value-double-quotes`](/docs/user-guide/rules/attr-value-double-quotes): Attribute values must be in double quotes.
23-
- [`attr-value-not-empty`](/docs/user-guide/rules/attr-not-empty): All attributes must have values.
23+
- [`attr-value-not-empty`](/docs/user-guide/rules/attr-value-not-empty): All attributes must have values.
2424
- [`alt-require`](/docs/user-guide/rules/alt-require): The alt attribute of an element must be present and alt attribute of area[href] and input[type=image] must have a value.
2525

2626
### Tags
2727

28-
- [`tags-check`](/docs/user-guide/rules/tags-check.md): Allowing specify rules for any tag and validate that
28+
- [`tags-check`](/docs/user-guide/rules/tags-check): Allowing specify rules for any tag and validate that
2929
- [`tag-pair`](/docs/user-guide/rules/tag-pair): Tag must be paired.
3030
- [`tag-self-close`](/docs/user-guide/rules/tag-self-close): Empty tags must be self closed.
3131
- [`tagname-lowercase`](/docs/user-guide/rules/tagname-lowercase): All html element names must be in lowercase.
32-
- [`empty-tag-not-self-closed`](/docs/user-guide/rules/empty-tag-not-self-closed): The empty tag should not be closed by self.
3332
- [`src-not-empty`](/docs/user-guide/rules/src-not-empty): The src attribute of an img(script,link) must have a value.
3433
- [`href-abs-or-rel`](/docs/user-guide/rules/href-abs-or-rel): An href attribute must be either absolute or relative.
3534

Diff for: docs/user-guide/rules/alt-require.md

+33-9
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,53 @@ keywords:
77
- accessiblity
88
---
99

10-
Alt of img must be present and alt of area[href] and input[type=image] must be set value.
10+
The `alt` attribute of an `<img>` element must be present and `alt` attribute of `area[href]` and `input[type=image]` must have a value.
11+
12+
## Possible Configuration Values
13+
14+
```json
15+
{
16+
"alt-require": "off",
17+
"alt-require": "warn",
18+
"alt-require": "error",
19+
"alt-require": ["off"],
20+
"alt-require": ["warn"],
21+
"alt-require": ["error"]
22+
}
23+
```
1124

12-
Level: warning
25+
## Default
1326

14-
## Config value
27+
```json
28+
{ "alt-require": "off" }
29+
```
1530

16-
1. true: enable rule
17-
2. false: disable rule
31+
---
1832

19-
The following pattern are **not** considered violations:
33+
## Examples
34+
35+
Examples of **correct** code for this rule:
2036

21-
<!-- prettier-ignore -->
2237
```html
2338
<img src="test.png" alt="test" />
2439
<input type="image" alt="test" />
2540
<area shape="circle" coords="180,139,14" href="test.html" alt="test" />
2641
```
2742

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

30-
<!-- prettier-ignore -->
3145
```html
3246
<img src="test.png" />
3347
<input type="image" />
3448
<area shape="circle" coords="180,139,14" href="test.html" />
3549
```
50+
51+
---
52+
53+
## When Not To Use It
54+
55+
If your project will not use `alt` on images.
56+
57+
## Version
58+
59+
This rule was introduced in HTMLHint `v0.9.1`.

Diff for: docs/user-guide/rules/attr-lowercase.md

+39-10
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,55 @@ id: attr-lowercase
33
title: attr-lowercase
44
---
55

6-
Attribute name must be lowercase.
6+
All attribute names must be in lowercase.
7+
8+
## Possible Configuration Values
9+
10+
```json
11+
{
12+
"attr-lowercase": "off",
13+
"attr-lowercase": "warn",
14+
"attr-lowercase": "error",
15+
"attr-lowercase": ["off"],
16+
"attr-lowercase": ["warn", { "exceptions": ["viewBox", "test"] }],
17+
"attr-lowercase": ["error", { "exceptions": ["viewBox", "test"] }]
18+
}
19+
```
20+
21+
## Default
22+
23+
```json
24+
{ "attr-lowercase": "error" }
25+
```
726

8-
Level: `error`
27+
## Options
928

10-
## Config value
29+
This rule has an object option:
30+
31+
- `"exceptions": ["viewBox", "test"]` ignore attributes `viewBox` and `test`.
32+
33+
---
1134

12-
1. true: enable rule
13-
2. false: disable rule
14-
3. ['viewBox', 'test']: Ignore some attr name
35+
## Examples
1536

16-
The following pattern are **not** considered violations:
37+
Examples of **correct** code for this rule:
1738

18-
<!-- prettier-ignore -->
1939
```html
2040
<img src="test.png" alt="test" />
2141
```
2242

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

25-
<!-- prettier-ignore -->
2645
```html
2746
<img src="test.png" alt="test" />
2847
```
48+
49+
---
50+
51+
## When Not To Use It
52+
53+
If your project will use `camelCase` attributes.
54+
55+
## Version
56+
57+
This rule was introduced in HTMLHint `v0.9.1`.

Diff for: 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`.

Diff for: 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`.

Diff for: 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`.

0 commit comments

Comments
 (0)