Skip to content

Commit

Permalink
Update vfile
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 23, 2021
1 parent 29ea36c commit 4812dec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/index.js
Expand Up @@ -125,7 +125,6 @@ export function raw(tree, file, options) {
}
}

// @ts-expect-error: update `vfile`.
const result = fromParse5(documentMode(tree) ? document() : fragment(), file)

if (stitches) {
Expand Down Expand Up @@ -506,5 +505,5 @@ function createParse5Location(node) {
* @return {value is Options}
*/
function isOptions(value) {
return Boolean(value && !('contents' in value))
return Boolean(value && !('message' in value && 'messages' in value))
}
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -43,7 +43,7 @@
"parse5": "^6.0.0",
"unist-util-position": "^4.0.0",
"unist-util-visit": "^3.0.0",
"vfile": "^4.0.0",
"vfile": "^5.0.0",
"web-namespaces": "^2.0.0",
"zwitch": "^2.0.0"
},
Expand All @@ -61,7 +61,7 @@
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unified": "^9.0.0",
"unified": "^10.0.0",
"unist-builder": "^3.0.0",
"xo": "^0.39.0"
},
Expand Down
11 changes: 6 additions & 5 deletions test.js
@@ -1,7 +1,7 @@
import test from 'tape'
import {u} from 'unist-builder'
import {h} from 'hastscript'
import unified from 'unified'
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
Expand Down Expand Up @@ -288,10 +288,11 @@ test('integration', (t) => {
unified()
.use(remarkParse)
.use(remarkRehype, {allowDangerousHtml: true})
.use(() => {
// @ts-expect-error hast is more specific than unist.
return (tree, file) => raw(tree, file)
})
.use(
() => (tree, file) =>
// @ts-expect-error hast is more specific than unist.
raw(tree, file)
)
.use(() => {
return transformer
function transformer(/** @type {import('unist').Node} */ tree) {
Expand Down

0 comments on commit 4812dec

Please sign in to comment.