Skip to content

Commit 67ef76c

Browse files
committed
Update @types/hast, @types/mdast, utilities
1 parent 7c40cb6 commit 67ef76c

File tree

8 files changed

+46
-38
lines changed

8 files changed

+46
-38
lines changed

lib/footer.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function footer(state) {
5757
backReference.children.push({
5858
type: 'element',
5959
tagName: 'sup',
60+
properties: {},
6061
children: [{type: 'text', value: String(referenceIndex)}]
6162
})
6263
}

lib/handlers/footnote.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @typedef {import('hast').Element} Element
3-
* @typedef {import('mdast').Footnote} Footnote
3+
* @typedef {import('mdast').Node} Node
44
* @typedef {import('../state.js').State} State
55
*/
66

@@ -17,7 +17,7 @@ import {footnoteReference} from './footnote-reference.js'
1717
*
1818
* @param {State} state
1919
* Info passed around.
20-
* @param {Footnote} node
20+
* @param {Node} node
2121
* mdast node.
2222
* @returns {Element}
2323
* hast node.
@@ -33,6 +33,7 @@ export function footnote(state, node) {
3333
footnoteById[identifier] = {
3434
type: 'footnoteDefinition',
3535
identifier,
36+
// @ts-expect-error: to do: remove this.
3637
children: [{type: 'paragraph', children: node.children}],
3738
position: node.position
3839
}

lib/handlers/table.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function table(state, node) {
4545

4646
const start = pointStart(node.children[1])
4747
const end = pointEnd(node.children[node.children.length - 1])
48-
if (start.line && end.line) body.position = {start, end}
48+
if (start && end) body.position = {start, end}
4949
tableContent.push(body)
5050
}
5151

lib/state.js

-5
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,6 @@ function applyData(from, to) {
444444
export function one(state, node, parent) {
445445
const type = node && node.type
446446

447-
// Fail on non-nodes.
448-
if (!type) {
449-
throw new Error('Expected node, got `' + node + '`')
450-
}
451-
452447
if (own.call(state.handlers, type)) {
453448
return state.handlers[type](state, node, parent)
454449
}

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@
3535
"index.js"
3636
],
3737
"dependencies": {
38-
"@types/hast": "^2.0.0",
39-
"@types/mdast": "^3.0.0",
40-
"mdast-util-definitions": "^5.0.0",
41-
"micromark-util-sanitize-uri": "^1.1.0",
38+
"@types/hast": "^3.0.0",
39+
"@types/mdast": "^4.0.0",
40+
"mdast-util-definitions": "^6.0.0",
41+
"micromark-util-sanitize-uri": "^2.0.0",
4242
"trim-lines": "^3.0.0",
43-
"unist-util-generated": "^2.0.0",
44-
"unist-util-position": "^4.0.0",
45-
"unist-util-visit": "^4.0.0"
43+
"unist-util-generated": "^3.0.0",
44+
"unist-util-position": "^5.0.0",
45+
"unist-util-visit": "^5.0.0"
4646
},
4747
"devDependencies": {
4848
"@types/node": "^20.0.0",
4949
"c8": "^8.0.0",
5050
"hast-util-to-html": "^8.0.4",
5151
"hastscript": "^7.0.0",
52-
"mdast-util-from-markdown": "^1.0.0",
53-
"mdast-util-gfm": "^2.0.0",
54-
"micromark-extension-gfm": "^2.0.0",
52+
"mdast-util-from-markdown": "^2.0.0",
53+
"mdast-util-gfm": "^3.0.0",
54+
"micromark-extension-gfm": "^3.0.0",
5555
"prettier": "^3.0.0",
5656
"remark-cli": "^11.0.0",
5757
"remark-preset-wooorm": "^9.0.0",

test/core.js

+16-20
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ test('toHast', () => {
1111
'should expose the public api'
1212
)
1313

14-
assert.throws(
15-
() => {
16-
// @ts-expect-error runtime.
17-
toHast({type: 'bar', children: [true]})
18-
},
19-
/Expected node, got `true`/,
20-
'should throw on non-nodes'
21-
)
14+
assert.throws(() => {
15+
// @ts-expect-error runtime.
16+
toHast({type: 'bar', children: [true]})
17+
}, 'should throw on non-nodes')
2218

2319
assert.deepEqual(
2420
toHast({
@@ -65,8 +61,8 @@ test('toHast', () => {
6561
properties: {},
6662
children: [{type: 'text', value: 'foxtrot'}],
6763
position: {
68-
start: {line: 2, column: 3, offset: null},
69-
end: {line: 2, column: 12, offset: null}
64+
start: {line: 2, column: 3, offset: undefined},
65+
end: {line: 2, column: 12, offset: undefined}
7066
}
7167
},
7268
'should patch `position`s when given'
@@ -92,14 +88,14 @@ test('toHast', () => {
9288
properties: {},
9389
children: [{type: 'text', value: 'golf\n'}],
9490
position: {
95-
start: {line: 2, column: 3, offset: null},
96-
end: {line: 2, column: 12, offset: null}
91+
start: {line: 2, column: 3, offset: undefined},
92+
end: {line: 2, column: 12, offset: undefined}
9793
}
9894
}
9995
],
10096
position: {
101-
start: {line: 2, column: 3, offset: null},
102-
end: {line: 2, column: 12, offset: null}
97+
start: {line: 2, column: 3, offset: undefined},
98+
end: {line: 2, column: 12, offset: undefined}
10399
}
104100
},
105101
'should patch `position`s on `pre` and `code`'
@@ -120,8 +116,8 @@ test('toHast', () => {
120116
properties: {},
121117
children: [{type: 'text', value: 'foxtrot'}],
122118
position: {
123-
start: {line: 2, column: 3, offset: null},
124-
end: {line: 2, column: 12, offset: null}
119+
start: {line: 2, column: 3, offset: undefined},
120+
end: {line: 2, column: 12, offset: undefined}
125121
}
126122
},
127123
'should patch `position`s when given'
@@ -147,14 +143,14 @@ test('toHast', () => {
147143
properties: {},
148144
children: [{type: 'text', value: 'golf\n'}],
149145
position: {
150-
start: {line: 2, column: 3, offset: null},
151-
end: {line: 2, column: 12, offset: null}
146+
start: {line: 2, column: 3, offset: undefined},
147+
end: {line: 2, column: 12, offset: undefined}
152148
}
153149
}
154150
],
155151
position: {
156-
start: {line: 2, column: 3, offset: null},
157-
end: {line: 2, column: 12, offset: null}
152+
start: {line: 2, column: 3, offset: undefined},
153+
end: {line: 2, column: 12, offset: undefined}
158154
}
159155
},
160156
'should patch `position`s on `pre` and `code`'

test/footnote-mixed.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test('footnote', () => {
1111
type: 'paragraph',
1212
children: [
1313
{type: 'text', value: 'alpha'},
14+
// @ts-expect-error: to do: remove.
1415
{type: 'footnote', children: [{type: 'text', value: 'bravo'}]}
1516
]
1617
},
@@ -33,6 +34,7 @@ test('footnote', () => {
3334
assert(mdast, 'expected node')
3435

3536
assert.deepEqual(
37+
// @ts-expect-error: to do: remove when `to-html` is released.
3638
toHtml(mdast),
3739
`<p>alpha<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
3840
<p>charlie<sup><a href="#user-content-fn-x" id="user-content-fnref-x" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>

test/footnote.js

+13
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import {toHast} from '../index.js'
99
test('footnote', () => {
1010
let tree = toHast({
1111
type: 'root',
12+
// @ts-expect-error: to do: remove `footnote`s.
1213
children: [{type: 'footnote', children: [{type: 'text', value: 'alpha'}]}]
1314
})
1415
assert(tree, 'expected node')
1516
assert.equal(
17+
// @ts-expect-error: to do: remove when `to-html` is released.
1618
toHtml(tree),
1719
`<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup>
1820
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
@@ -39,11 +41,13 @@ test('footnote', () => {
3941
type: 'paragraph',
4042
children: [{type: 'footnoteReference', identifier: '1'}]
4143
},
44+
// @ts-expect-error: to do: remove `footnote`s.
4245
{type: 'footnote', children: [{type: 'text', value: 'charlie'}]}
4346
]
4447
})
4548
assert(tree, 'expected node')
4649
assert.equal(
50+
// @ts-expect-error: to do: remove when `to-html` is released.
4751
toHtml(tree),
4852
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
4953
<sup><a href="#user-content-fn-2" id="user-content-fnref-2" data-footnote-ref aria-describedby="footnote-label">2</a></sup>
@@ -83,6 +87,7 @@ test('footnote', () => {
8387
})
8488
assert(tree, 'expected node')
8589
assert.equal(
90+
// @ts-expect-error: to do: remove when `to-html` is released.
8691
toHtml(tree),
8792
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
8893
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
@@ -112,6 +117,7 @@ test('footnote', () => {
112117
)
113118
assert(tree, 'expected node')
114119
assert.equal(
120+
// @ts-expect-error: to do: remove when `to-html` is released.
115121
toHtml(tree),
116122
`<table>
117123
<thead>
@@ -153,6 +159,7 @@ test('footnote', () => {
153159
)
154160
assert(tree, 'expected node')
155161
assert.equal(
162+
// @ts-expect-error: to do: remove when `to-html` is released.
156163
toHtml(tree),
157164
`<table>
158165
<thead>
@@ -183,6 +190,7 @@ test('footnote', () => {
183190
)
184191
assert(tree, 'expected node')
185192
assert.equal(
193+
// @ts-expect-error: to do: remove when `to-html` is released.
186194
toHtml(tree),
187195
`<p>Call<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup><sup><a href="#user-content-fn-1" id="user-content-fnref-1-2" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
188196
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
@@ -204,6 +212,7 @@ test('footnote', () => {
204212
)
205213
assert(tree, 'expected node')
206214
assert.equal(
215+
// @ts-expect-error: to do: remove when `to-html` is released.
207216
toHtml(tree),
208217
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
209218
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Voetnoten</h2>
@@ -225,6 +234,7 @@ test('footnote', () => {
225234
)
226235
assert(tree, 'expected node')
227236
assert.equal(
237+
// @ts-expect-error: to do: remove when `to-html` is released.
228238
toHtml(tree),
229239
`<p><sup><a href="#fn-1" id="fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
230240
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
@@ -246,6 +256,7 @@ test('footnote', () => {
246256
)
247257
assert(tree, 'expected node')
248258
assert.equal(
259+
// @ts-expect-error: to do: remove when `to-html` is released.
249260
toHtml(tree),
250261
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
251262
<section data-footnotes class="footnotes"><h1 class="sr-only" id="footnote-label">Footnotes</h1>
@@ -267,6 +278,7 @@ test('footnote', () => {
267278
)
268279
assert(tree, 'expected node')
269280
assert.equal(
281+
// @ts-expect-error: to do: remove when `to-html` is released.
270282
toHtml(tree),
271283
`<p><sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
272284
<section data-footnotes class="footnotes"><h2 id="footnote-label">Footnotes</h2>
@@ -290,6 +302,7 @@ test('footnote', () => {
290302
)
291303
assert(tree, 'expected node')
292304
assert.equal(
305+
// @ts-expect-error: to do: remove when `to-html` is released.
293306
toHtml(tree),
294307
`<p>a<sup><a href="#user-content-fn-__proto__" id="user-content-fnref-__proto__" data-footnote-ref aria-describedby="footnote-label">1</a></sup> b<sup><a href="#user-content-fn-__proto__" id="user-content-fnref-__proto__-2" data-footnote-ref aria-describedby="footnote-label">1</a></sup> c<sup><a href="#user-content-fn-constructor" id="user-content-fnref-constructor" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
295308
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>

0 commit comments

Comments
 (0)