diff --git a/src/Plugin.js b/src/Plugin.js index 77282ab..b0a3bd2 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -304,4 +304,9 @@ export default class Plugin { const expressionsProps = node.expressions.map((_, index) => index); this.buildExpressionHandler(node.expressions, expressionsProps, path, state); } + + AssignmentPattern(path, state) { + const { node } = path; + this.buildExpressionHandler(node, ['right'], path, state); + } } diff --git a/src/index.js b/src/index.js index a3c8d5b..f0f9938 100644 --- a/src/index.js +++ b/src/index.js @@ -102,6 +102,7 @@ export default function ({ types }) { 'SwitchStatement', 'SwitchCase', 'SequenceExpression', + 'AssignmentPattern', ]; const ret = { diff --git a/test/fixtures/assignment-pattern/actual.js b/test/fixtures/assignment-pattern/actual.js new file mode 100644 index 0000000..6f2b082 --- /dev/null +++ b/test/fixtures/assignment-pattern/actual.js @@ -0,0 +1,3 @@ +import { Button } from 'antd'; + +const { a = Button } = {}; diff --git a/test/fixtures/assignment-pattern/expected.js b/test/fixtures/assignment-pattern/expected.js new file mode 100644 index 0000000..d10ce85 --- /dev/null +++ b/test/fixtures/assignment-pattern/expected.js @@ -0,0 +1,4 @@ +import _Button from "antd/lib/button"; +const { + a = _Button +} = {};