Skip to content

Commit

Permalink
feat: 新增SequenceExpression支持 (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
licic1995 committed Jan 5, 2023
1 parent c4d6910 commit 54a94bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,11 @@ export default class Plugin {
const { node } = path;
this.buildExpressionHandler(node, ['superClass'], path, state);
}

SequenceExpression(path, state) {
const { node } = path;

const expressionsProps = node.expressions.map((_, index) => index);
this.buildExpressionHandler(node.expressions, expressionsProps, path, state);
}
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default function ({ types }) {
'ClassDeclaration',
'SwitchStatement',
'SwitchCase',
'SequenceExpression',
];

const ret = {
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/sequence-expression/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Button } from 'antd';

(true, Button);

true ? (true, Button) : (false, Button);
9 changes: 9 additions & 0 deletions test/fixtures/sequence-expression/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

var _button = _interopRequireDefault(require("antd/lib/button"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

true, _button.default;

true ? (true, _button.default) : (false, _button.default);

0 comments on commit 54a94bc

Please sign in to comment.