Skip to content

Commit 7a29f57

Browse files
mysticateamichalsnik
authored andcommitted
Breaking: enable HTML syntax errors by default (#233)
1 parent 09b8f90 commit 7a29f57

File tree

3 files changed

+255
-146
lines changed

3 files changed

+255
-146
lines changed

docs/rules/no-parsing-error.md

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,52 @@ Then reports syntax errors if exist.
3434
```json
3535
{
3636
"vue/no-parsing-error": [2, {
37-
"abrupt-closing-of-empty-comment": false,
38-
"absence-of-digits-in-numeric-character-reference": false,
39-
"cdata-in-html-content": false,
40-
"character-reference-outside-unicode-range": false,
41-
"control-character-in-input-stream": false,
42-
"control-character-reference": false,
43-
"eof-before-tag-name": false,
44-
"eof-in-cdata": false,
45-
"eof-in-comment": false,
46-
"eof-in-tag": false,
47-
"incorrectly-closed-comment": false,
48-
"incorrectly-opened-comment": false,
49-
"invalid-first-character-of-tag-name": false,
50-
"missing-attribute-value": false,
51-
"missing-end-tag-name": false,
52-
"missing-semicolon-after-character-reference": false,
53-
"missing-whitespace-between-attributes": false,
54-
"nested-comment": false,
55-
"noncharacter-character-reference": false,
56-
"noncharacter-in-input-stream": false,
57-
"null-character-reference": false,
58-
"surrogate-character-reference": false,
59-
"surrogate-in-input-stream": false,
60-
"unexpected-character-in-attribute-name": false,
61-
"unexpected-character-in-unquoted-attribute-value": false,
62-
"unexpected-equals-sign-before-attribute-name": false,
63-
"unexpected-null-character": false,
64-
"unexpected-question-mark-instead-of-tag-name": false,
65-
"unexpected-solidus-in-tag": false,
66-
"unknown-named-character-reference": false,
67-
"end-tag-with-attributes": false,
68-
"duplicate-attribute": false,
69-
"end-tag-with-trailing-solidus": false,
37+
"abrupt-closing-of-empty-comment": true,
38+
"absence-of-digits-in-numeric-character-reference": true,
39+
"cdata-in-html-content": true,
40+
"character-reference-outside-unicode-range": true,
41+
"control-character-in-input-stream": true,
42+
"control-character-reference": true,
43+
"eof-before-tag-name": true,
44+
"eof-in-cdata": true,
45+
"eof-in-comment": true,
46+
"eof-in-tag": true,
47+
"incorrectly-closed-comment": true,
48+
"incorrectly-opened-comment": true,
49+
"invalid-first-character-of-tag-name": true,
50+
"missing-attribute-value": true,
51+
"missing-end-tag-name": true,
52+
"missing-semicolon-after-character-reference": true,
53+
"missing-whitespace-between-attributes": true,
54+
"nested-comment": true,
55+
"noncharacter-character-reference": true,
56+
"noncharacter-in-input-stream": true,
57+
"null-character-reference": true,
58+
"surrogate-character-reference": true,
59+
"surrogate-in-input-stream": true,
60+
"unexpected-character-in-attribute-name": true,
61+
"unexpected-character-in-unquoted-attribute-value": true,
62+
"unexpected-equals-sign-before-attribute-name": true,
63+
"unexpected-null-character": true,
64+
"unexpected-question-mark-instead-of-tag-name": true,
65+
"unexpected-solidus-in-tag": true,
66+
"unknown-named-character-reference": true,
67+
"end-tag-with-attributes": true,
68+
"duplicate-attribute": true,
69+
"end-tag-with-trailing-solidus": true,
7070
"non-void-html-element-start-tag-with-trailing-solidus": false,
71-
"x-invalid-end-tag": false,
72-
"x-invalid-namespace": false
71+
"x-invalid-end-tag": true,
72+
"x-invalid-namespace": true
7373
}]
7474
}
7575
```
7676

77-
You can enable HTML syntax errors by opt-in.
77+
You can disable HTML syntax errors by options. Please see [WHATWG HTML spec](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors) to know the details of HTML syntax errors.
78+
Only `non-void-html-element-start-tag-with-trailing-solidus` is disabled by default because Vue.js supports self-closing tags.
7879

79-
For example, if `"x-invalid-end-tag": true` is given then this rule will catch the end tags of elements which have not opened.
80-
The error codes are defined in [WHATWG spec](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors), but this rule does not support all of those (E.g., it does not catch errors about DOCTYPE).
81-
Also, The codes which have `x-` prefix are original in this rule because errors in tree construction phase have not codified yet.
80+
> Note this rule does not support all of those (E.g., it does not catch errors about DOCTYPE).
81+
82+
The error codes which have `x-` prefix are original of this rule because errors in tree construction phase have not codified yet.
8283

8384
- `x-invalid-end-tag` enables the errors about the end tags of elements which have not opened.
8485
- `x-invalid-namespace` enables the errors about invalid `xmlns` attributes. See also [step 10. of "create an element for a token"](https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token).
85-
86-
> TODO(mysticatea): I will revisit errors in tree construction phase after those are codified.

lib/rules/no-parsing-error.js

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,43 @@
1010
// ------------------------------------------------------------------------------
1111

1212
// https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
13-
// TODO: Enable all by default.
1413
const DEFAULT_OPTIONS = Object.freeze(Object.assign(Object.create(null), {
15-
'abrupt-closing-of-empty-comment': false,
16-
'absence-of-digits-in-numeric-character-reference': false,
17-
'cdata-in-html-content': false,
18-
'character-reference-outside-unicode-range': false,
19-
'control-character-in-input-stream': false,
20-
'control-character-reference': false,
21-
'eof-before-tag-name': false,
22-
'eof-in-cdata': false,
23-
'eof-in-comment': false,
24-
'eof-in-tag': false,
25-
'incorrectly-closed-comment': false,
26-
'incorrectly-opened-comment': false,
27-
'invalid-first-character-of-tag-name': false,
28-
'missing-attribute-value': false,
29-
'missing-end-tag-name': false,
30-
'missing-semicolon-after-character-reference': false,
31-
'missing-whitespace-between-attributes': false,
32-
'nested-comment': false,
33-
'noncharacter-character-reference': false,
34-
'noncharacter-in-input-stream': false,
35-
'null-character-reference': false,
36-
'surrogate-character-reference': false,
37-
'surrogate-in-input-stream': false,
38-
'unexpected-character-in-attribute-name': false,
39-
'unexpected-character-in-unquoted-attribute-value': false,
40-
'unexpected-equals-sign-before-attribute-name': false,
41-
'unexpected-null-character': false,
42-
'unexpected-question-mark-instead-of-tag-name': false,
43-
'unexpected-solidus-in-tag': false,
44-
'unknown-named-character-reference': false,
45-
'end-tag-with-attributes': false,
46-
'duplicate-attribute': false,
47-
'end-tag-with-trailing-solidus': false,
14+
'abrupt-closing-of-empty-comment': true,
15+
'absence-of-digits-in-numeric-character-reference': true,
16+
'cdata-in-html-content': true,
17+
'character-reference-outside-unicode-range': true,
18+
'control-character-in-input-stream': true,
19+
'control-character-reference': true,
20+
'eof-before-tag-name': true,
21+
'eof-in-cdata': true,
22+
'eof-in-comment': true,
23+
'eof-in-tag': true,
24+
'incorrectly-closed-comment': true,
25+
'incorrectly-opened-comment': true,
26+
'invalid-first-character-of-tag-name': true,
27+
'missing-attribute-value': true,
28+
'missing-end-tag-name': true,
29+
'missing-semicolon-after-character-reference': true,
30+
'missing-whitespace-between-attributes': true,
31+
'nested-comment': true,
32+
'noncharacter-character-reference': true,
33+
'noncharacter-in-input-stream': true,
34+
'null-character-reference': true,
35+
'surrogate-character-reference': true,
36+
'surrogate-in-input-stream': true,
37+
'unexpected-character-in-attribute-name': true,
38+
'unexpected-character-in-unquoted-attribute-value': true,
39+
'unexpected-equals-sign-before-attribute-name': true,
40+
'unexpected-null-character': true,
41+
'unexpected-question-mark-instead-of-tag-name': true,
42+
'unexpected-solidus-in-tag': true,
43+
'unknown-named-character-reference': true,
44+
'end-tag-with-attributes': true,
45+
'duplicate-attribute': true,
46+
'end-tag-with-trailing-solidus': true,
4847
'non-void-html-element-start-tag-with-trailing-solidus': false,
49-
'x-invalid-end-tag': false,
50-
'x-invalid-namespace': false
48+
'x-invalid-end-tag': true,
49+
'x-invalid-namespace': true
5150
}))
5251

5352
/**

0 commit comments

Comments
 (0)