File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * @typedef {import('mdast').Content|import('mdast').Root } MdastNode
2
+ * @typedef {import('mdast').Content|import('mdast').Root } Node
3
3
*/
4
4
5
5
import { visit } from 'unist-util-visit'
6
6
7
7
/**
8
8
* Make an mdast tree compact by merging adjacent text nodes and block quotes.
9
9
*
10
- * @template {MdastNode } Tree
10
+ * @template {Node } Tree
11
11
* @param {Tree } tree
12
12
* @returns {Tree }
13
13
*/
14
14
export function compact ( tree ) {
15
- visit ( tree , ( child , index , parent ) => {
15
+ // @ts -expect-error: hush, TS.
16
+ visit ( tree , visitor )
17
+
18
+ return tree
19
+
20
+ /**
21
+ * @param {import('mdast').Content } child
22
+ * @param {number } index
23
+ * @param {Extract<Node, import('mdast').Parent> } parent
24
+ */
25
+ function visitor ( child , index , parent ) {
16
26
if (
17
27
parent &&
18
28
index &&
@@ -40,7 +50,5 @@ export function compact(tree) {
40
50
return index
41
51
}
42
52
}
43
- } )
44
-
45
- return tree
53
+ }
46
54
}
Original file line number Diff line number Diff line change 54
54
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
55
55
"test-api" : " node test.js" ,
56
56
"test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" ,
57
- "test" : " npm run format && npm run test-coverage"
57
+ "test" : " npm run build && npm run format && npm run test-coverage"
58
58
},
59
59
"prettier" : {
60
60
"tabWidth" : 2 ,
You can’t perform that action at this time.
0 commit comments