|
| 1 | +/** |
| 2 | + * @typedef ErrorInfo |
| 3 | + * Info on a `parse5` error. |
| 4 | + * @property {string} reason |
| 5 | + * Reason of error. |
| 6 | + * @property {string} description |
| 7 | + * More info on error. |
| 8 | + * @property {false} [url] |
| 9 | + * Turn off if this is not documented in the html5 spec (optional). |
| 10 | + */ |
| 11 | + |
1 | 12 | export const errors = { |
| 13 | + /** @type {ErrorInfo} */ |
2 | 14 | abandonedHeadElementChild: { |
3 | 15 | reason: 'Unexpected metadata element after head', |
4 | 16 | description: |
5 | 17 | 'Unexpected element after head. Expected the element before `</head>`', |
6 | 18 | url: false |
7 | 19 | }, |
| 20 | + /** @type {ErrorInfo} */ |
8 | 21 | abruptClosingOfEmptyComment: { |
9 | 22 | reason: 'Unexpected abruptly closed empty comment', |
10 | 23 | description: 'Unexpected `>` or `->`. Expected `-->` to close comments' |
11 | 24 | }, |
| 25 | + /** @type {ErrorInfo} */ |
12 | 26 | abruptDoctypePublicIdentifier: { |
13 | 27 | reason: 'Unexpected abruptly closed public identifier', |
14 | 28 | description: |
15 | 29 | 'Unexpected `>`. Expected a closing `"` or `\'` after the public identifier' |
16 | 30 | }, |
| 31 | + /** @type {ErrorInfo} */ |
17 | 32 | abruptDoctypeSystemIdentifier: { |
18 | 33 | reason: 'Unexpected abruptly closed system identifier', |
19 | 34 | description: |
20 | 35 | 'Unexpected `>`. Expected a closing `"` or `\'` after the identifier identifier' |
21 | 36 | }, |
| 37 | + /** @type {ErrorInfo} */ |
22 | 38 | absenceOfDigitsInNumericCharacterReference: { |
23 | 39 | reason: 'Unexpected non-digit at start of numeric character reference', |
24 | 40 | description: |
25 | 41 | 'Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references' |
26 | 42 | }, |
| 43 | + /** @type {ErrorInfo} */ |
27 | 44 | cdataInHtmlContent: { |
28 | 45 | reason: 'Unexpected CDATA section in HTML', |
29 | 46 | description: |
30 | 47 | 'Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead' |
31 | 48 | }, |
| 49 | + /** @type {ErrorInfo} */ |
32 | 50 | characterReferenceOutsideUnicodeRange: { |
33 | 51 | reason: 'Unexpected too big numeric character reference', |
34 | 52 | description: |
35 | 53 | 'Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)' |
36 | 54 | }, |
| 55 | + /** @type {ErrorInfo} */ |
37 | 56 | closingOfElementWithOpenChildElements: { |
38 | 57 | reason: 'Unexpected closing tag with open child elements', |
39 | 58 | description: |
40 | 59 | 'Unexpectedly closing tag. Expected other tags to be closed first', |
41 | 60 | url: false |
42 | 61 | }, |
| 62 | + /** @type {ErrorInfo} */ |
43 | 63 | controlCharacterInInputStream: { |
44 | 64 | reason: 'Unexpected control character', |
45 | 65 | description: |
46 | 66 | 'Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace' |
47 | 67 | }, |
| 68 | + /** @type {ErrorInfo} */ |
48 | 69 | controlCharacterReference: { |
49 | 70 | reason: 'Unexpected control character reference', |
50 | 71 | description: |
51 | 72 | 'Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace' |
52 | 73 | }, |
| 74 | + /** @type {ErrorInfo} */ |
53 | 75 | disallowedContentInNoscriptInHead: { |
54 | 76 | reason: 'Disallowed content inside `<noscript>` in `<head>`', |
55 | 77 | description: |
56 | 78 | 'Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`', |
57 | 79 | url: false |
58 | 80 | }, |
| 81 | + /** @type {ErrorInfo} */ |
59 | 82 | duplicateAttribute: { |
60 | 83 | reason: 'Unexpected duplicate attribute', |
61 | 84 | description: |
62 | 85 | 'Unexpectedly double attribute. Expected attributes to occur only once' |
63 | 86 | }, |
| 87 | + /** @type {ErrorInfo} */ |
64 | 88 | endTagWithAttributes: { |
65 | 89 | reason: 'Unexpected attribute on closing tag', |
66 | 90 | description: 'Unexpected attribute. Expected `>` instead' |
67 | 91 | }, |
| 92 | + /** @type {ErrorInfo} */ |
68 | 93 | endTagWithTrailingSolidus: { |
69 | 94 | reason: 'Unexpected slash at end of closing tag', |
70 | 95 | description: 'Unexpected `%c-1`. Expected `>` instead' |
71 | 96 | }, |
| 97 | + /** @type {ErrorInfo} */ |
72 | 98 | endTagWithoutMatchingOpenElement: { |
73 | 99 | reason: 'Unexpected unopened end tag', |
74 | 100 | description: 'Unexpected end tag. Expected no end tag or another end tag', |
75 | 101 | url: false |
76 | 102 | }, |
| 103 | + /** @type {ErrorInfo} */ |
77 | 104 | eofBeforeTagName: { |
78 | 105 | reason: 'Unexpected end of file', |
79 | 106 | description: 'Unexpected end of file. Expected tag name instead' |
80 | 107 | }, |
| 108 | + /** @type {ErrorInfo} */ |
81 | 109 | eofInCdata: { |
82 | 110 | reason: 'Unexpected end of file in CDATA', |
83 | 111 | description: 'Unexpected end of file. Expected `]]>` to close the CDATA' |
84 | 112 | }, |
| 113 | + /** @type {ErrorInfo} */ |
85 | 114 | eofInComment: { |
86 | 115 | reason: 'Unexpected end of file in comment', |
87 | 116 | description: 'Unexpected end of file. Expected `-->` to close the comment' |
88 | 117 | }, |
| 118 | + /** @type {ErrorInfo} */ |
89 | 119 | eofInDoctype: { |
90 | 120 | reason: 'Unexpected end of file in doctype', |
91 | 121 | description: |
92 | 122 | 'Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)' |
93 | 123 | }, |
| 124 | + /** @type {ErrorInfo} */ |
94 | 125 | eofInElementThatCanContainOnlyText: { |
95 | 126 | reason: 'Unexpected end of file in element that can only contain text', |
96 | 127 | description: 'Unexpected end of file. Expected text or a closing tag', |
97 | 128 | url: false |
98 | 129 | }, |
| 130 | + /** @type {ErrorInfo} */ |
99 | 131 | eofInScriptHtmlCommentLikeText: { |
100 | 132 | reason: 'Unexpected end of file in comment inside script', |
101 | 133 | description: 'Unexpected end of file. Expected `-->` to close the comment' |
102 | 134 | }, |
| 135 | + /** @type {ErrorInfo} */ |
103 | 136 | eofInTag: { |
104 | 137 | reason: 'Unexpected end of file in tag', |
105 | 138 | description: 'Unexpected end of file. Expected `>` to close the tag' |
106 | 139 | }, |
| 140 | + /** @type {ErrorInfo} */ |
107 | 141 | incorrectlyClosedComment: { |
108 | 142 | reason: 'Incorrectly closed comment', |
109 | 143 | description: 'Unexpected `%c-1`. Expected `-->` to close the comment' |
110 | 144 | }, |
| 145 | + /** @type {ErrorInfo} */ |
111 | 146 | incorrectlyOpenedComment: { |
112 | 147 | reason: 'Incorrectly opened comment', |
113 | 148 | description: 'Unexpected `%c`. Expected `<!--` to open the comment' |
114 | 149 | }, |
| 150 | + /** @type {ErrorInfo} */ |
115 | 151 | invalidCharacterSequenceAfterDoctypeName: { |
116 | 152 | reason: 'Invalid sequence after doctype name', |
117 | 153 | description: 'Unexpected sequence at `%c`. Expected `public` or `system`' |
118 | 154 | }, |
| 155 | + /** @type {ErrorInfo} */ |
119 | 156 | invalidFirstCharacterOfTagName: { |
120 | 157 | reason: 'Invalid first character in tag name', |
121 | 158 | description: 'Unexpected `%c`. Expected an ASCII letter instead' |
122 | 159 | }, |
| 160 | + /** @type {ErrorInfo} */ |
123 | 161 | misplacedDoctype: { |
124 | 162 | reason: 'Misplaced doctype', |
125 | 163 | description: 'Unexpected doctype. Expected doctype before head', |
126 | 164 | url: false |
127 | 165 | }, |
| 166 | + /** @type {ErrorInfo} */ |
128 | 167 | misplacedStartTagForHeadElement: { |
129 | 168 | reason: 'Misplaced `<head>` start tag', |
130 | 169 | description: |
131 | 170 | 'Unexpected start tag `<head>`. Expected `<head>` directly after doctype', |
132 | 171 | url: false |
133 | 172 | }, |
| 173 | + /** @type {ErrorInfo} */ |
134 | 174 | missingAttributeValue: { |
135 | 175 | reason: 'Missing attribute value', |
136 | 176 | description: |
137 | 177 | 'Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead' |
138 | 178 | }, |
| 179 | + /** @type {ErrorInfo} */ |
139 | 180 | missingDoctype: { |
140 | 181 | reason: 'Missing doctype before other content', |
141 | 182 | description: 'Expected a `<!doctype html>` before anything else', |
142 | 183 | url: false |
143 | 184 | }, |
| 185 | + /** @type {ErrorInfo} */ |
144 | 186 | missingDoctypeName: { |
145 | 187 | reason: 'Missing doctype name', |
146 | 188 | description: 'Unexpected doctype end at `%c`. Expected `html` instead' |
147 | 189 | }, |
| 190 | + /** @type {ErrorInfo} */ |
148 | 191 | missingDoctypePublicIdentifier: { |
149 | 192 | reason: 'Missing public identifier in doctype', |
150 | 193 | description: 'Unexpected `%c`. Expected identifier for `public` instead' |
151 | 194 | }, |
| 195 | + /** @type {ErrorInfo} */ |
152 | 196 | missingDoctypeSystemIdentifier: { |
153 | 197 | reason: 'Missing system identifier in doctype', |
154 | 198 | description: |
155 | 199 | 'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)' |
156 | 200 | }, |
| 201 | + /** @type {ErrorInfo} */ |
157 | 202 | missingEndTagName: { |
158 | 203 | reason: 'Missing name in end tag', |
159 | 204 | description: 'Unexpected `%c`. Expected an ASCII letter instead' |
160 | 205 | }, |
| 206 | + /** @type {ErrorInfo} */ |
161 | 207 | missingQuoteBeforeDoctypePublicIdentifier: { |
162 | 208 | reason: 'Missing quote before public identifier in doctype', |
163 | 209 | description: 'Unexpected `%c`. Expected `"` or `\'` instead' |
164 | 210 | }, |
| 211 | + /** @type {ErrorInfo} */ |
165 | 212 | missingQuoteBeforeDoctypeSystemIdentifier: { |
166 | 213 | reason: 'Missing quote before system identifier in doctype', |
167 | 214 | description: 'Unexpected `%c`. Expected `"` or `\'` instead' |
168 | 215 | }, |
| 216 | + /** @type {ErrorInfo} */ |
169 | 217 | missingSemicolonAfterCharacterReference: { |
170 | 218 | reason: 'Missing semicolon after character reference', |
171 | 219 | description: 'Unexpected `%c`. Expected `;` instead' |
172 | 220 | }, |
| 221 | + /** @type {ErrorInfo} */ |
173 | 222 | missingWhitespaceAfterDoctypePublicKeyword: { |
174 | 223 | reason: 'Missing whitespace after public identifier in doctype', |
175 | 224 | description: 'Unexpected `%c`. Expected ASCII whitespace instead' |
176 | 225 | }, |
| 226 | + /** @type {ErrorInfo} */ |
177 | 227 | missingWhitespaceAfterDoctypeSystemKeyword: { |
178 | 228 | reason: 'Missing whitespace after system identifier in doctype', |
179 | 229 | description: 'Unexpected `%c`. Expected ASCII whitespace instead' |
180 | 230 | }, |
| 231 | + /** @type {ErrorInfo} */ |
181 | 232 | missingWhitespaceBeforeDoctypeName: { |
182 | 233 | reason: 'Missing whitespace before doctype name', |
183 | 234 | description: 'Unexpected `%c`. Expected ASCII whitespace instead' |
184 | 235 | }, |
| 236 | + /** @type {ErrorInfo} */ |
185 | 237 | missingWhitespaceBetweenAttributes: { |
186 | 238 | reason: 'Missing whitespace between attributes', |
187 | 239 | description: 'Unexpected `%c`. Expected ASCII whitespace instead' |
188 | 240 | }, |
| 241 | + /** @type {ErrorInfo} */ |
189 | 242 | missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers: { |
190 | 243 | reason: |
191 | 244 | 'Missing whitespace between public and system identifiers in doctype', |
192 | 245 | description: 'Unexpected `%c`. Expected ASCII whitespace instead' |
193 | 246 | }, |
| 247 | + /** @type {ErrorInfo} */ |
194 | 248 | nestedComment: { |
195 | 249 | reason: 'Unexpected nested comment', |
196 | 250 | description: 'Unexpected `<!--`. Expected `-->`' |
197 | 251 | }, |
| 252 | + /** @type {ErrorInfo} */ |
198 | 253 | nestedNoscriptInHead: { |
199 | 254 | reason: 'Unexpected nested `<noscript>` in `<head>`', |
200 | 255 | description: |
201 | 256 | 'Unexpected `<noscript>`. Expected a closing tag or a meta element', |
202 | 257 | url: false |
203 | 258 | }, |
| 259 | + /** @type {ErrorInfo} */ |
204 | 260 | nonConformingDoctype: { |
205 | 261 | reason: 'Unexpected non-conforming doctype declaration', |
206 | 262 | description: |
207 | 263 | 'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`', |
208 | 264 | url: false |
209 | 265 | }, |
| 266 | + /** @type {ErrorInfo} */ |
210 | 267 | nonVoidHtmlElementStartTagWithTrailingSolidus: { |
211 | 268 | reason: 'Unexpected trailing slash on start tag of non-void element', |
212 | 269 | description: 'Unexpected `/`. Expected `>` instead' |
213 | 270 | }, |
| 271 | + /** @type {ErrorInfo} */ |
214 | 272 | noncharacterCharacterReference: { |
215 | 273 | reason: |
216 | 274 | 'Unexpected noncharacter code point referenced by character reference', |
217 | 275 | description: 'Unexpected code point. Do not use noncharacters in HTML' |
218 | 276 | }, |
| 277 | + /** @type {ErrorInfo} */ |
219 | 278 | noncharacterInInputStream: { |
220 | 279 | reason: 'Unexpected noncharacter character', |
221 | 280 | description: 'Unexpected code point `%x`. Do not use noncharacters in HTML' |
222 | 281 | }, |
| 282 | + /** @type {ErrorInfo} */ |
223 | 283 | nullCharacterReference: { |
224 | 284 | reason: 'Unexpected NULL character referenced by character reference', |
225 | 285 | description: 'Unexpected code point. Do not use NULL characters in HTML' |
226 | 286 | }, |
| 287 | + /** @type {ErrorInfo} */ |
227 | 288 | openElementsLeftAfterEof: { |
228 | 289 | reason: 'Unexpected end of file', |
229 | 290 | description: 'Unexpected end of file. Expected closing tag instead', |
230 | 291 | url: false |
231 | 292 | }, |
| 293 | + /** @type {ErrorInfo} */ |
232 | 294 | surrogateCharacterReference: { |
233 | 295 | reason: 'Unexpected surrogate character referenced by character reference', |
234 | 296 | description: |
235 | 297 | 'Unexpected code point. Do not use lone surrogate characters in HTML' |
236 | 298 | }, |
| 299 | + /** @type {ErrorInfo} */ |
237 | 300 | surrogateInInputStream: { |
238 | 301 | reason: 'Unexpected surrogate character', |
239 | 302 | description: |
240 | 303 | 'Unexpected code point `%x`. Do not use lone surrogate characters in HTML' |
241 | 304 | }, |
| 305 | + /** @type {ErrorInfo} */ |
242 | 306 | unexpectedCharacterAfterDoctypeSystemIdentifier: { |
243 | 307 | reason: 'Invalid character after system identifier in doctype', |
244 | 308 | description: 'Unexpected character at `%c`. Expected `>`' |
245 | 309 | }, |
| 310 | + /** @type {ErrorInfo} */ |
246 | 311 | unexpectedCharacterInAttributeName: { |
247 | 312 | reason: 'Unexpected character in attribute name', |
248 | 313 | description: |
249 | 314 | 'Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter' |
250 | 315 | }, |
| 316 | + /** @type {ErrorInfo} */ |
251 | 317 | unexpectedCharacterInUnquotedAttributeValue: { |
252 | 318 | reason: 'Unexpected character in unquoted attribute value', |
253 | 319 | description: 'Unexpected `%c`. Quote the attribute value to include it' |
254 | 320 | }, |
| 321 | + /** @type {ErrorInfo} */ |
255 | 322 | unexpectedEqualsSignBeforeAttributeName: { |
256 | 323 | reason: 'Unexpected equals sign before attribute name', |
257 | 324 | description: 'Unexpected `%c`. Add an attribute name before it' |
258 | 325 | }, |
| 326 | + /** @type {ErrorInfo} */ |
259 | 327 | unexpectedNullCharacter: { |
260 | 328 | reason: 'Unexpected NULL character', |
261 | 329 | description: |
262 | 330 | 'Unexpected code point `%x`. Do not use NULL characters in HTML' |
263 | 331 | }, |
| 332 | + /** @type {ErrorInfo} */ |
264 | 333 | unexpectedQuestionMarkInsteadOfTagName: { |
265 | 334 | reason: 'Unexpected question mark instead of tag name', |
266 | 335 | description: 'Unexpected `%c`. Expected an ASCII letter instead' |
267 | 336 | }, |
| 337 | + /** @type {ErrorInfo} */ |
268 | 338 | unexpectedSolidusInTag: { |
269 | 339 | reason: 'Unexpected slash in tag', |
270 | 340 | description: |
271 | 341 | 'Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value' |
272 | 342 | }, |
| 343 | + /** @type {ErrorInfo} */ |
273 | 344 | unknownNamedCharacterReference: { |
274 | 345 | reason: 'Unexpected unknown named character reference', |
275 | 346 | description: |
|
0 commit comments