Skip to content

Commit f1c5dd7

Browse files
committed
Refactor to use @imports
1 parent 79d3de7 commit f1c5dd7

File tree

13 files changed

+34
-64
lines changed

13 files changed

+34
-64
lines changed

Diff for: lib/handle/comment.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/**
2-
* @typedef {import('hast').Comment} Comment
3-
* @typedef {import('hast').Parents} Parents
4-
*
5-
* @typedef {import('../index.js').State} State
2+
* @import {Comment, Parents} from 'hast'
3+
* @import {State} from '../index.js'
64
*/
75

86
import {stringifyEntities} from 'stringify-entities'

Diff for: lib/handle/doctype.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/**
2-
* @typedef {import('hast').Doctype} Doctype
3-
* @typedef {import('hast').Parents} Parents
4-
*
5-
* @typedef {import('../index.js').State} State
2+
* @import {Doctype, Parents} from 'hast'
3+
* @import {State} from '../index.js'
64
*/
75

8-
// Make VS code see references to the above types.
9-
''
10-
116
/**
127
* Serialize a doctype.
138
*

Diff for: lib/handle/element.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/**
2-
* @typedef {import('hast').Element} Element
3-
* @typedef {import('hast').Parents} Parents
4-
* @typedef {import('hast').Properties} Properties
5-
*
6-
* @typedef {import('../index.js').State} State
2+
* @import {Element, Parents, Properties} from 'hast'
3+
* @import {State} from '../index.js'
74
*/
85

96
import {ccount} from 'ccount'

Diff for: lib/handle/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/**
2-
* @typedef {import('hast').Nodes} Nodes
3-
* @typedef {import('hast').Parents} Parents
4-
*
5-
* @typedef {import('../index.js').State} State
2+
* @import {Nodes, Parents} from 'hast'
3+
* @import {State} from '../index.js'
64
*/
75

86
import {zwitch} from 'zwitch'

Diff for: lib/handle/raw.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
2-
* @typedef {import('hast').Parents} Parents
3-
*
4-
* @typedef {import('mdast-util-to-hast').Raw} Raw
5-
*
6-
* @typedef {import('../index.js').State} State
2+
* @import {Parents} from 'hast'
3+
* @import {Raw} from 'mdast-util-to-hast'
4+
* @import {State} from '../index.js'
75
*/
86

97
import {text} from './text.js'

Diff for: lib/handle/root.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/**
2-
* @typedef {import('hast').Parents} Parents
3-
* @typedef {import('hast').Root} Root
4-
*
5-
* @typedef {import('../index.js').State} State
2+
* @import {Parents, Root} from 'hast'
3+
* @import {State} from '../index.js'
64
*/
75

8-
// Make VS code see references to the above types.
9-
''
10-
116
/**
127
* Serialize a root.
138
*

Diff for: lib/handle/text.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/**
2-
* @typedef {import('hast').Parents} Parents
3-
* @typedef {import('hast').Text} Text
4-
*
5-
* @typedef {import('mdast-util-to-hast').Raw} Raw
6-
*
7-
* @typedef {import('../index.js').State} State
2+
* @import {Parents, Text} from 'hast'
3+
* @import {Raw} from 'mdast-util-to-hast'
4+
* @import {State} from '../index.js'
85
*/
96

107
import {stringifyEntities} from 'stringify-entities'

Diff for: lib/index.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/**
2-
* @typedef {import('hast').Nodes} Nodes
3-
* @typedef {import('hast').Parents} Parents
4-
* @typedef {import('hast').RootContent} RootContent
5-
*
6-
* @typedef {import('property-information').Schema} Schema
7-
*
8-
* @typedef {import('stringify-entities').Options} StringifyEntitiesOptions
2+
* @import {Nodes, Parents, RootContent} from 'hast'
3+
* @import {Schema} from 'property-information'
4+
* @import {Options as StringifyEntitiesOptions} from 'stringify-entities'
95
*/
106

117
/**
@@ -77,10 +73,10 @@
7773
* Leave attributes unquoted if that results in less bytes (default: `false`).
7874
*
7975
* Not used in the SVG space.
80-
* @property {Quote | null | undefined} [quote='"']
81-
* Preferred quote to use (default: `'"'`).
8276
* @property {boolean | null | undefined} [quoteSmart=false]
8377
* Use the other quote if that results in less bytes (default: `false`).
78+
* @property {Quote | null | undefined} [quote='"']
79+
* Preferred quote to use (default: `'"'`).
8480
* @property {Space | null | undefined} [space='html']
8581
* When an `<svg>` element is found in the HTML space, this package already
8682
* automatically switches to and from the SVG space when entering and exiting
@@ -138,18 +134,18 @@
138134
*
139135
* @typedef State
140136
* Info passed around about the current state.
141-
* @property {(node: Nodes, index: number | undefined, parent: Parents | undefined) => string} one
142-
* Serialize one node.
143137
* @property {(node: Parents | undefined) => string} all
144138
* Serialize the children of a parent node.
145-
* @property {Settings} settings
146-
* User configuration.
147-
* @property {Schema} schema
148-
* Current schema.
149-
* @property {Quote} quote
150-
* Preferred quote.
151139
* @property {Quote} alternative
152140
* Alternative quote.
141+
* @property {(node: Nodes, index: number | undefined, parent: Parents | undefined) => string} one
142+
* Serialize one node.
143+
* @property {Quote} quote
144+
* Preferred quote.
145+
* @property {Schema} schema
146+
* Current schema.
147+
* @property {Settings} settings
148+
* User configuration.
153149
*/
154150

155151
import {htmlVoidElements} from 'html-void-elements'

Diff for: lib/omission/closing.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* @typedef {import('hast').Element} Element
3-
* @typedef {import('hast').Parents} Parents
2+
* @import {Element, Parents} from 'hast'
43
*/
54

65
import {whitespace} from 'hast-util-whitespace'

Diff for: lib/omission/omission.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* @typedef {import('hast').Element} Element
3-
* @typedef {import('hast').Parents} Parents
2+
* @import {Element, Parents} from 'hast'
43
*/
54

65
/**

Diff for: lib/omission/opening.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* @typedef {import('hast').Element} Element
3-
* @typedef {import('hast').Parents} Parents
2+
* @import {Element, Parents} from 'hast'
43
*/
54

65
import {whitespace} from 'hast-util-whitespace'

Diff for: lib/omission/util/siblings.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* @typedef {import('hast').Parents} Parents
3-
* @typedef {import('hast').RootContent} RootContent
2+
* @import {Parents, RootContent} from 'hast'
43
*/
54

65
import {whitespace} from 'hast-util-whitespace'

Diff for: test/raw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @typedef {import('mdast-util-to-hast')} DoNotTouchThisRegistersRawInTheTree
2+
* @import {} from 'mdast-util-to-hast'
33
*/
44

55
import assert from 'node:assert/strict'

0 commit comments

Comments
 (0)