Skip to content

Commit 9ec50ce

Browse files
committed
Refactor to use estree-util-visit
1 parent b7beccc commit 9ec50ce

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
"index.js"
3434
],
3535
"devDependencies": {
36-
"@types/acorn": "^4.0.5",
36+
"@types/acorn": "^4.0.0",
3737
"@types/tape": "^4.0.0",
3838
"acorn": "^8.0.0",
3939
"c8": "^7.0.0",
40-
"estree-walker": "^3.0.0",
40+
"estree-util-visit": "^1.0.0",
4141
"prettier": "^2.0.0",
4242
"recast": "^0.20.0",
4343
"remark-cli": "^9.0.0",

test.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from 'tape'
22
import {parse as acornParse} from 'acorn'
33
import recast from 'recast'
4-
import {walk} from 'estree-walker'
4+
import {visit} from 'estree-util-visit'
55
import {attachComments} from './index.js'
66

77
/**
@@ -178,17 +178,21 @@ function parse(doc) {
178178
}
179179

180180
/**
181-
* @param {EstreeNode|EstreeComment|EstreeNode[]|EstreeComment[]} value
181+
* @param {EstreeNode|EstreeNode[]} value
182182
* @returns {void}
183183
*/
184184
function removePositions(value) {
185185
// @ts-ignore
186-
walk(value, {
187-
enter(node) {
186+
visit(
187+
value,
188+
/**
189+
* @param {EstreeNode} node
190+
*/
191+
function (node) {
188192
// @ts-ignore they most certainly exist.
189193
delete node.start
190194
// @ts-ignore they most certainly exist.
191195
delete node.end
192196
}
193-
})
197+
)
194198
}

0 commit comments

Comments
 (0)