Skip to content

Commit ed58cd9

Browse files
committed
Update @types/mdast
1 parent c332c07 commit ed58cd9

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

lib/index.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
/**
2-
* @typedef {import('mdast').Root} Root
3-
* @typedef {import('mdast').Content} Content
2+
* @typedef {import('mdast').Nodes} Nodes
43
* @typedef {import('mdast').Paragraph} Paragraph
54
*/
65

7-
/**
8-
* @typedef {Content | Root} Node
9-
*/
10-
116
import {visit} from 'unist-util-visit'
127

138
/**
149
* Remove empty paragraphs in `tree`.
1510
*
16-
* @template {Node} Tree
11+
* @template {Nodes} Tree
1712
* Node type.
1813
* @param {Tree} tree
1914
* Tree to change.
@@ -27,7 +22,7 @@ export function squeezeParagraphs(tree) {
2722
}
2823

2924
visit(tree, function (node, index, parent) {
30-
if (index !== null && parent && emptyParagraph(node)) {
25+
if (index !== undefined && parent && emptyParagraph(node)) {
3126
parent.children.splice(index, 1)
3227
return index
3328
}
@@ -40,7 +35,7 @@ export function squeezeParagraphs(tree) {
4035
/**
4136
* Check if a node is an empty paragraph.
4237
*
43-
* @param {Node} node
38+
* @param {Nodes} node
4439
* Node to check.
4540
* @returns {boolean}
4641
* Whether `node` was an empty paragraph.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
"index.js"
4141
],
4242
"dependencies": {
43-
"@types/mdast": "^3.0.0",
44-
"unist-util-visit": "^4.0.0"
43+
"@types/mdast": "^4.0.0",
44+
"unist-util-visit": "^5.0.0"
4545
},
4646
"devDependencies": {
47-
"@types/tape": "^5.0.0",
47+
"@types/node": "^20.0.0",
4848
"c8": "^8.0.0",
4949
"prettier": "^2.0.0",
5050
"remark-cli": "^11.0.0",
@@ -53,7 +53,7 @@
5353
"tsd": "^0.28.0",
5454
"type-coverage": "^2.0.0",
5555
"typescript": "^5.0.0",
56-
"unist-builder": "^3.0.0",
56+
"unist-builder": "^4.0.0",
5757
"xo": "^0.54.0"
5858
},
5959
"scripts": {

test.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* @typedef {import('mdast').Paragraph} Paragraph
44
*/
55

6-
import test from 'tape'
6+
import assert from 'node:assert/strict'
7+
import test from 'node:test'
78
import {u} from 'unist-builder'
89
import {squeezeParagraphs} from './index.js'
910

10-
test((t) => {
11-
t.deepEqual(
11+
test('squeezeParagraphs', () => {
12+
assert.deepEqual(
1213
squeezeParagraphs(
1314
/** @type {Root} */ (
1415
u('root', [
@@ -41,11 +42,9 @@ test((t) => {
4142
])
4243
)
4344

44-
t.deepEqual(
45+
assert.deepEqual(
4546
squeezeParagraphs(/** @type {Paragraph} */ (u('paragraph', []))),
4647
null,
4748
'should return `null` for empty paragraphs'
4849
)
49-
50-
t.end()
5150
})

0 commit comments

Comments
 (0)