|
1 | 1 | /** |
2 | | - * @typedef {import('hast').Root} Root |
3 | | - * @typedef {import('parse5').ParserError} ParserError |
4 | | - * @typedef {import('vfile').Value} Value |
5 | | - */ |
6 | | - |
7 | | -/** |
8 | | - * @typedef {keyof errors} ErrorCode |
9 | | - * Known names of parse errors. |
10 | | - * |
11 | | - * @typedef {Partial<Record<ErrorCode, ErrorSeverity | null | undefined>>} ErrorOptions |
12 | | - * Options that define the severity of errors. |
13 | | - * |
14 | | - * @typedef {boolean | 0 | 1 | 2} ErrorSeverity |
15 | | - * Error severity: |
16 | | - * |
17 | | - * * `0` or `false` |
18 | | - * — turn the parse error off |
19 | | - * * `1` or `true` |
20 | | - * — turn the parse error into a warning |
21 | | - * * `2` |
22 | | - * — turn the parse error into an actual error: processing stops. |
23 | | - * |
24 | | - * @typedef ExtraOptions |
25 | | - * Options that define how to parse HTML. |
26 | | - * @property {boolean | null | undefined} [fragment=false] |
27 | | - * Specify whether to parse a fragment, instead of a complete document |
28 | | - * (default: `false`). |
29 | | - * |
30 | | - * In document mode, unopened `html`, `head`, and `body` elements are opened |
31 | | - * in just the right places. |
32 | | - * @property {OnError | null | undefined} [onerror] |
33 | | - * Call `onerror` with parse errors while parsing (optional). |
34 | | - * |
35 | | - * > 👉 **Note**: parse errors are currently being added to HTML. |
36 | | - * > Not all errors emitted by parse5 (or us) are specced yet. |
37 | | - * > Some documentation may still be missing. |
38 | | - * |
39 | | - * Specific rules can be turned off by setting them to `false` (or `0`). |
40 | | - * The default, when `emitParseErrors: true`, is `true` (or `1`), and means |
41 | | - * that rules emit as warnings. |
42 | | - * Rules can also be configured with `2`, to turn them into fatal errors. |
43 | | - * |
44 | | - * @typedef {Omit<import('hast-util-from-parse5').Options, 'file'>} FromParse5Options |
45 | | - * Options that can be passed through to `hast-util-from-parse5`. |
46 | | - * |
47 | | - * @callback OnError |
48 | | - * Handle parse errors. |
49 | | - * @param {VFileMessage} error |
50 | | - * Message. |
51 | | - * @returns {undefined | void} |
52 | | - * Nothing. |
53 | | - * |
54 | | - * Note: `void` included until TS infers `undefined` nicely. |
55 | | - * |
56 | | - * @typedef {FromParse5Options & ErrorOptions & ExtraOptions} Options |
57 | | - * Configuration. |
| 2 | + * @import {Root} from 'hast' |
| 3 | + * @import {ParserError} from 'parse5' |
| 4 | + * @import {Value} from 'vfile' |
| 5 | + * @import {ErrorCode, Options} from './types.js' |
58 | 6 | */ |
59 | 7 |
|
60 | 8 | import {ok as assert} from 'devlop' |
|
0 commit comments