Skip to content

Commit

Permalink
Update unist-builder (esm)
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 21, 2021
1 parent f936de4 commit 4713bd5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/plugin/recma-document.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import u from 'unist-builder'
import {u} from 'unist-builder'
import {stringifyPosition} from 'unist-util-stringify-position'
import {positionFromEstree} from 'unist-util-position-from-estree'
import {create} from '../util/estree-util-create.js'
Expand Down
7 changes: 4 additions & 3 deletions lib/plugin/recma-jsx-build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {buildJsx} from 'estree-util-build-jsx'
import u from 'unist-builder'
import {u} from 'unist-builder'
import {specifiersToObjectPattern} from '../util/estree-util-specifiers-to-object-pattern.js'

/**
Expand Down Expand Up @@ -36,7 +36,8 @@ export function recmaJsxBuild(options = {}) {
typeof tree.body[0].source.value === 'string' &&
/\/jsx-runtime$/.test(tree.body[0].source.value)
) {
tree.body[0] = u('VariableDeclaration', {
tree.body[0] = {
type: 'VariableDeclaration',
kind: 'const',
declarations: [
u('VariableDeclarator', {
Expand All @@ -49,7 +50,7 @@ export function recmaJsxBuild(options = {}) {
})
})
]
})
}
}
}
}
2 changes: 1 addition & 1 deletion lib/plugin/recma-jsx-rewrite.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {name as isIdentifierName} from 'estree-util-is-identifier-name'
import {walk} from 'estree-walker'
import {analyze} from 'periscopic'
import u from 'unist-builder'
import {u} from 'unist-builder'
import {specifiersToObjectPattern} from '../util/estree-util-specifiers-to-object-pattern.js'

/**
Expand Down
27 changes: 13 additions & 14 deletions lib/util/estree-util-specifiers-to-object-pattern.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import u from 'unist-builder'
import {u} from 'unist-builder'
import {create} from './estree-util-create.js'

/**
Expand All @@ -11,7 +11,8 @@ import {create} from './estree-util-create.js'
* @returns {import('estree').ObjectPattern}
*/
export function specifiersToObjectPattern(specifiers) {
return u('ObjectPattern', {
return {
type: 'ObjectPattern',
properties: specifiers.map((specifier) => {
var key =
'imported' in specifier
Expand All @@ -26,17 +27,15 @@ export function specifiersToObjectPattern(specifiers) {
key = specifier.local
}

return create(
specifier,
u('Property', {
kind: 'init',
shorthand: key.name === value.name,
method: false,
computed: false,
key,
value
})
)
return create(specifier, {
type: 'Property',
kind: 'init',
shorthand: key.name === value.name,
method: false,
computed: false,
key,
value
})
})
})
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"remark-rehype": "^8.1.0",
"stringify-entities": "^4.0.0",
"unified": "^9.0.0",
"unist-builder": "^2.0.0",
"unist-builder": "^3.0.0",
"unist-util-position-from-estree": "^1.0.0",
"unist-util-stringify-position": "^3.0.0",
"unist-util-visit": "^2.0.0",
Expand Down

0 comments on commit 4713bd5

Please sign in to comment.