Skip to content

Commit a62e408

Browse files
committed
Update unist-util-visit
1 parent 80097f6 commit a62e408

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"tape": "^5.0.0",
8080
"type-coverage": "^2.0.0",
8181
"typescript": "^4.0.0",
82-
"unist-util-visit": "^3.0.0",
82+
"unist-util-visit": "^4.0.0",
8383
"vfile": "^5.0.0",
8484
"xo": "^0.42.0"
8585
},

test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @typedef {import('estree-jsx').Program} Program
33
* @typedef {import('estree-jsx').Comment} Comment
44
* @typedef {import('estree-jsx').Node} Node
5+
* @typedef {import('./index.js').Node} HastNode
56
*/
67

78
import test from 'tape'
@@ -28,6 +29,7 @@ import {toEstree} from './index.js'
2829
// @ts-expect-error Types are wrong.
2930
const generate = fauxEsmGenerate.default
3031

32+
/** @type {['mdxFlowExpression', 'mdxJsxFlowElement', 'mdxJsxTextElement', 'mdxTextExpression', 'mdxjsEsm']} */
3133
const passThrough = [
3234
'mdxFlowExpression',
3335
'mdxJsxFlowElement',
@@ -866,18 +868,17 @@ test('integration (micromark-extension-mdxjs, mdast-util-mdx)', (t) => {
866868

867869
const hast = toHast(mdast, {passThrough})
868870

869-
if (clean) visit(hast, passThrough, acornClean)
871+
if (clean && hast) visit(hast, passThrough, acornClean)
870872

871873
// @ts-expect-error: update.
872874
return recastSerialize(toEstree(hast))
873875

874876
/**
875-
* @param {unknown} node
877+
* @param {HastNode} node
876878
*/
877879
function acornClean(node) {
878880
let index = -1
879881

880-
// @ts-expect-error embedded mdx
881882
if (node.data && node.data.estree) delete node.data.estree
882883

883884
// @ts-expect-error embedded mdx

0 commit comments

Comments
 (0)