From bedae9feecd4b231a5b258c15e780abb03bebd67 Mon Sep 17 00:00:00 2001 From: sorrycc Date: Thu, 5 Jan 2023 21:45:12 +0800 Subject: [PATCH] test: update expected files since babel upgraded --- test/fixtures/array-expression/expected.js | 14 +--- .../as-arguments-identifier/expected.js | 12 +-- test/fixtures/as-arguments/expected.js | 9 +-- test/fixtures/binary-expression/expected.js | 9 +-- test/fixtures/conditions/expected.js | 21 ++--- .../custom-name-source-file/expected.js | 15 +--- test/fixtures/custom-name/expected.js | 15 +--- .../custom-style-name-file/expected.js | 14 +--- test/fixtures/custom-style-name/expected.js | 14 +--- .../custom-style-path-ignore/expected.js | 21 ++--- test/fixtures/custom-style-path/expected.js | 18 ++--- test/fixtures/execute-direct/expected.js | 9 +-- test/fixtures/execute-member/expected.js | 9 +-- test/fixtures/export-import/expected.js | 15 +--- .../fixtures/expression-statement/expected.js | 10 +-- test/fixtures/file-name/expected.js | 12 +-- test/fixtures/import-alias/expected.js | 9 +-- test/fixtures/import-css/expected.js | 22 ++--- test/fixtures/keep-named-import/expected.js | 12 +-- test/fixtures/material-ui/expected.js | 9 +-- test/fixtures/member-expression/expected.js | 13 +-- test/fixtures/modules-false/expected.js | 7 +- .../multiple-libraries-hilojs/expected.js | 18 ++--- test/fixtures/multiple-libraries/expected.js | 15 +--- test/fixtures/multiple-words/expected.js | 12 +-- test/fixtures/new-expression/expected.js | 9 +-- test/fixtures/object-shorthand/expected.js | 14 +--- test/fixtures/property/expected.js | 15 +--- test/fixtures/react-element/expected.js | 11 +-- test/fixtures/react-toolbox/expected.js | 9 +-- test/fixtures/return/expected.js | 19 ++--- test/fixtures/sequence-expression/expected.js | 12 +-- test/fixtures/specifier-alias/expected.js | 13 +-- test/fixtures/style-library-name/expected.js | 14 +--- test/fixtures/super-class/expected.js | 3 +- test/fixtures/switch/expected.js | 14 +--- test/fixtures/use-multiple-times/expected.js | 14 +--- .../expected.js | 11 +-- test/fixtures/variable-declarator/expected.js | 14 +--- test/fixtures/variable-scope/expected.js | 80 +++++-------------- test/index.test.js | 2 + 41 files changed, 151 insertions(+), 437 deletions(-) diff --git a/test/fixtures/array-expression/expected.js b/test/fixtures/array-expression/expected.js index 47f97b66..843c570f 100644 --- a/test/fixtures/array-expression/expected.js +++ b/test/fixtures/array-expression/expected.js @@ -1,12 +1,6 @@ -"use strict"; - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var a = [_button.default]; +import _Button from "antd/lib/button"; +var a = [_Button]; var b = { - 'test': [_button.default] + 'test': [_Button] }; -[_button.default].map(function () {}); - +[_Button].map(function () {}); \ No newline at end of file diff --git a/test/fixtures/as-arguments-identifier/expected.js b/test/fixtures/as-arguments-identifier/expected.js index 8599660a..e16bfafe 100644 --- a/test/fixtures/as-arguments-identifier/expected.js +++ b/test/fixtures/as-arguments-identifier/expected.js @@ -1,9 +1,3 @@ -"use strict"; - -var _modal = _interopRequireDefault(require("antd/lib/modal")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _Modal = bind()(_modal.default); - -var _newModal = new AnyClass(_modal.default); \ No newline at end of file +import _Modal2 from "antd/lib/modal"; +const _Modal = bind()(_Modal2); +const _newModal = new AnyClass(_Modal2); \ No newline at end of file diff --git a/test/fixtures/as-arguments/expected.js b/test/fixtures/as-arguments/expected.js index 0890e4e9..5204f7e5 100644 --- a/test/fixtures/as-arguments/expected.js +++ b/test/fixtures/as-arguments/expected.js @@ -1,7 +1,2 @@ -"use strict"; - -var _modal = _interopRequireDefault(require("antd/lib/modal")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _Modal = bind({})(_modal.default); \ No newline at end of file +import _Modal2 from "antd/lib/modal"; +const _Modal = bind({})(_Modal2); \ No newline at end of file diff --git a/test/fixtures/binary-expression/expected.js b/test/fixtures/binary-expression/expected.js index e1dc5685..80bf1594 100644 --- a/test/fixtures/binary-expression/expected.js +++ b/test/fixtures/binary-expression/expected.js @@ -1,10 +1,5 @@ -"use strict"; - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var extraProps = undefined === _button.default ? { +import _Button from "antd/lib/button"; +const extraProps = undefined === _Button ? { type: 'primary' } : {}; console.log(extraProps); \ No newline at end of file diff --git a/test/fixtures/conditions/expected.js b/test/fixtures/conditions/expected.js index 1c2f8e0a..734a6033 100644 --- a/test/fixtures/conditions/expected.js +++ b/test/fixtures/conditions/expected.js @@ -1,14 +1,7 @@ -"use strict"; - -var _select = _interopRequireDefault(require("antd/lib/select")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (a === _select.default) {} - -if (_select.default) {} - -_select.default ? 'a' : 'b'; -a ? _select.default : 2; -_select.default || 'a'; -a || _select.default; \ No newline at end of file +import _Select from "antd/lib/select"; +if (a === _Select) {} +if (_Select) {} +_Select ? 'a' : 'b'; +a ? _Select : 2; +_Select || 'a'; +a || _Select; \ No newline at end of file diff --git a/test/fixtures/custom-name-source-file/expected.js b/test/fixtures/custom-name-source-file/expected.js index cc989381..ea4e270f 100644 --- a/test/fixtures/custom-name-source-file/expected.js +++ b/test/fixtures/custom-name-source-file/expected.js @@ -1,11 +1,4 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", { - component: _button.default -})); +import _Button from "antd/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", { + component: _Button +})); \ No newline at end of file diff --git a/test/fixtures/custom-name/expected.js b/test/fixtures/custom-name/expected.js index cc989381..ea4e270f 100644 --- a/test/fixtures/custom-name/expected.js +++ b/test/fixtures/custom-name/expected.js @@ -1,11 +1,4 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", { - component: _button.default -})); +import _Button from "antd/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", { + component: _Button +})); \ No newline at end of file diff --git a/test/fixtures/custom-style-name-file/expected.js b/test/fixtures/custom-style-name-file/expected.js index 27eb5d37..eb3af9b8 100644 --- a/test/fixtures/custom-style-name-file/expected.js +++ b/test/fixtures/custom-style-name-file/expected.js @@ -1,11 +1,3 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -require("../../../../element-ui/lib/theme-light/button"); - -var _button2 = _interopRequireDefault(require("element-ui/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button2.default, null, "xxxx"))); +import "../../../../element-ui/lib/theme-light/button"; +import _Button from "element-ui/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx"))); \ No newline at end of file diff --git a/test/fixtures/custom-style-name/expected.js b/test/fixtures/custom-style-name/expected.js index 79e8b357..9442b3f1 100644 --- a/test/fixtures/custom-style-name/expected.js +++ b/test/fixtures/custom-style-name/expected.js @@ -1,11 +1,3 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -require("element-ui/lib/theme-light/button"); - -var _button2 = _interopRequireDefault(require("element-ui/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button2.default, null, "xxxx"))); +import "element-ui/lib/theme-light/button"; +import _Button from "element-ui/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx"))); \ No newline at end of file diff --git a/test/fixtures/custom-style-path-ignore/expected.js b/test/fixtures/custom-style-path-ignore/expected.js index 71759e6e..79f7492e 100644 --- a/test/fixtures/custom-style-path-ignore/expected.js +++ b/test/fixtures/custom-style-path-ignore/expected.js @@ -1,15 +1,6 @@ -"use strict"; - -var _animation = _interopRequireDefault(require("antd/lib/animation")); - -require("antd/lib/button/style/2x"); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -var _react = _interopRequireDefault(require("react")); - -var _reactDom = _interopRequireDefault(require("react-dom")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement(_animation.default, null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx")), document.getElementById("react-container")); +import _Animation from "antd/lib/animation"; +import "antd/lib/button/style/2x"; +import _Button from "antd/lib/button"; +import React from "react"; +import ReactDom from "react-dom"; +ReactDOM.render( /*#__PURE__*/React.createElement(_Animation, null, /*#__PURE__*/React.createElement(_Button, null, "xxxx")), document.getElementById("react-container")); \ No newline at end of file diff --git a/test/fixtures/custom-style-path/expected.js b/test/fixtures/custom-style-path/expected.js index 22ec90db..c52c6fa9 100644 --- a/test/fixtures/custom-style-path/expected.js +++ b/test/fixtures/custom-style-path/expected.js @@ -1,13 +1,5 @@ -"use strict"; - -require("antd/lib/button/style/2x"); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -var _react = _interopRequireDefault(require("react")); - -var _reactDom = _interopRequireDefault(require("react-dom")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx")), document.getElementById('react-container')); +import "antd/lib/button/style/2x"; +import _Button from "antd/lib/button"; +import React from 'react'; +import ReactDom from 'react-dom'; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx")), document.getElementById('react-container')); \ No newline at end of file diff --git a/test/fixtures/execute-direct/expected.js b/test/fixtures/execute-direct/expected.js index 43a247a2..893b54bc 100644 --- a/test/fixtures/execute-direct/expected.js +++ b/test/fixtures/execute-direct/expected.js @@ -1,7 +1,2 @@ -"use strict"; - -var _message2 = _interopRequireDefault(require("antd/lib/message")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _message2.default)('xxx'); \ No newline at end of file +import _message from "antd/lib/message"; +_message('xxx'); \ No newline at end of file diff --git a/test/fixtures/execute-member/expected.js b/test/fixtures/execute-member/expected.js index fea39f0c..095bbdf2 100644 --- a/test/fixtures/execute-member/expected.js +++ b/test/fixtures/execute-member/expected.js @@ -1,7 +1,2 @@ -"use strict"; - -var _message2 = _interopRequireDefault(require("antd/lib/message")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_message2.default.success('xxx'); \ No newline at end of file +import _message from "antd/lib/message"; +_message.success('xxx'); \ No newline at end of file diff --git a/test/fixtures/export-import/expected.js b/test/fixtures/export-import/expected.js index 71ac85da..96c29226 100644 --- a/test/fixtures/export-import/expected.js +++ b/test/fixtures/export-import/expected.js @@ -1,13 +1,2 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; - -var _datePicker = _interopRequireDefault(require("antd/lib/date-picker")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _default = _datePicker.default; -exports.default = _default; \ No newline at end of file +import _DatePicker from "antd/lib/date-picker"; +export default _DatePicker; \ No newline at end of file diff --git a/test/fixtures/expression-statement/expected.js b/test/fixtures/expression-statement/expected.js index 240c4c9b..7bb38d10 100644 --- a/test/fixtures/expression-statement/expected.js +++ b/test/fixtures/expression-statement/expected.js @@ -1,7 +1,3 @@ -"use strict"; - -var _antdMobile = require("antd-mobile"); - -window.Toast = _antdMobile.Toast; - -_antdMobile.Toast.success('test'); \ No newline at end of file +import { Toast } from 'antd-mobile'; +window.Toast = Toast; +Toast.success('test'); \ No newline at end of file diff --git a/test/fixtures/file-name/expected.js b/test/fixtures/file-name/expected.js index 9cc7e31b..cd3232f8 100644 --- a/test/fixtures/file-name/expected.js +++ b/test/fixtures/file-name/expected.js @@ -1,9 +1,3 @@ -"use strict"; - -var _index = _interopRequireDefault(require("antd-mobile-fake-2.0/lib/select/index.native")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (_index.default) {} - -console.log(_index.default); \ No newline at end of file +import _Select from "antd-mobile-fake-2.0/lib/select/index.native"; +if (_Select) {} +console.log(_Select); \ No newline at end of file diff --git a/test/fixtures/import-alias/expected.js b/test/fixtures/import-alias/expected.js index cd1d51fc..48344ea4 100644 --- a/test/fixtures/import-alias/expected.js +++ b/test/fixtures/import-alias/expected.js @@ -1,9 +1,4 @@ -"use strict"; - -var _select = _interopRequireDefault(require("antd/lib/select")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (_select.default) { +import _Select from "antd/lib/select"; +if (_Select) { console.log('foo'); } \ No newline at end of file diff --git a/test/fixtures/import-css/expected.js b/test/fixtures/import-css/expected.js index be2322f4..92bb9c9b 100644 --- a/test/fixtures/import-css/expected.js +++ b/test/fixtures/import-css/expected.js @@ -1,16 +1,6 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -require("antd/lib/button/style"); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -require("antd/lib/message/style"); - -var _message2 = _interopRequireDefault(require("antd/lib/message")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _message2.default)('xxx'); -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx"))); +import "antd/lib/button/style"; +import _Button from "antd/lib/button"; +import "antd/lib/message/style"; +import _message from "antd/lib/message"; +_message('xxx'); +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx"))); \ No newline at end of file diff --git a/test/fixtures/keep-named-import/expected.js b/test/fixtures/keep-named-import/expected.js index 8b346aa5..9ea72e13 100644 --- a/test/fixtures/keep-named-import/expected.js +++ b/test/fixtures/keep-named-import/expected.js @@ -1,8 +1,4 @@ -"use strict"; - -var _end2 = require("stream/lib/end"); - -var _start2 = require("stream/lib/start"); - -(0, _start2.start)(); -(0, _end2.end)(); +import { end as _end } from "stream/lib/end"; +import { start as _start } from "stream/lib/start"; +_start(); +_end(); \ No newline at end of file diff --git a/test/fixtures/material-ui/expected.js b/test/fixtures/material-ui/expected.js index 78d46a95..592c551e 100644 --- a/test/fixtures/material-ui/expected.js +++ b/test/fixtures/material-ui/expected.js @@ -1,7 +1,2 @@ -"use strict"; - -var _Toolbar2 = _interopRequireDefault(require("material-ui/Toolbar")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _Toolbar2.default)('xxx'); \ No newline at end of file +import _Toolbar from "material-ui/Toolbar"; +_Toolbar('xxx'); \ No newline at end of file diff --git a/test/fixtures/member-expression/expected.js b/test/fixtures/member-expression/expected.js index f8062bfa..8a59a650 100644 --- a/test/fixtures/member-expression/expected.js +++ b/test/fixtures/member-expression/expected.js @@ -1,11 +1,4 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, { +import _Button from "antd/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, { type: "primary" -}, "Button"))); +}, "Button"))); \ No newline at end of file diff --git a/test/fixtures/modules-false/expected.js b/test/fixtures/modules-false/expected.js index 12de3f11..dabbbb2d 100644 --- a/test/fixtures/modules-false/expected.js +++ b/test/fixtures/modules-false/expected.js @@ -1,13 +1,8 @@ "use strict"; require("antd/lib/button/style"); - var _button = _interopRequireDefault(require("antd/lib/button")); - var _react = _interopRequireDefault(require("react")); - var _reactDom = _interopRequireDefault(require("react-dom")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx")), document.getElementById('react-container')); +ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx")), document.getElementById('react-container')); \ No newline at end of file diff --git a/test/fixtures/multiple-libraries-hilojs/expected.js b/test/fixtures/multiple-libraries-hilojs/expected.js index 398b26fb..71418b5c 100644 --- a/test/fixtures/multiple-libraries-hilojs/expected.js +++ b/test/fixtures/multiple-libraries-hilojs/expected.js @@ -1,13 +1,5 @@ -"use strict"; - -var _abc = _interopRequireDefault(require("hilojs/abc")); - -var _class = _interopRequireDefault(require("hilojs/core/class")); - -var _select = _interopRequireDefault(require("antd/lib/select")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (_select.default) {} - -if (_class.default && _abc.default) {} \ No newline at end of file +import _Abc from "hilojs/abc"; +import _Class from "hilojs/core/class"; +import _Select from "antd/lib/select"; +if (_Select) {} +if (_Class && _Abc) {} \ No newline at end of file diff --git a/test/fixtures/multiple-libraries/expected.js b/test/fixtures/multiple-libraries/expected.js index 7fbf56e6..6688944d 100644 --- a/test/fixtures/multiple-libraries/expected.js +++ b/test/fixtures/multiple-libraries/expected.js @@ -1,11 +1,4 @@ -"use strict"; - -var _select = _interopRequireDefault(require("antd-mobile/lib/select")); - -var _select2 = _interopRequireDefault(require("antd/lib/select")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -if (_select2.default) {} - -if (_select.default) {} \ No newline at end of file +import _Select2 from "antd-mobile/lib/select"; +import _Select from "antd/lib/select"; +if (_Select) {} +if (_Select2) {} \ No newline at end of file diff --git a/test/fixtures/multiple-words/expected.js b/test/fixtures/multiple-words/expected.js index ef079065..5708e764 100644 --- a/test/fixtures/multiple-words/expected.js +++ b/test/fixtures/multiple-words/expected.js @@ -1,10 +1,2 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _inputNumber = _interopRequireDefault(require("antd/lib/input-number")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/*#__PURE__*/ -_react.default.createElement(_inputNumber.default, null); +import _InputNumber from "antd/lib/input-number"; +/*#__PURE__*/React.createElement(_InputNumber, null); \ No newline at end of file diff --git a/test/fixtures/new-expression/expected.js b/test/fixtures/new-expression/expected.js index d5426096..ac0ae2dc 100644 --- a/test/fixtures/new-expression/expected.js +++ b/test/fixtures/new-expression/expected.js @@ -1,7 +1,2 @@ -"use strict"; - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -new _button.default(); \ No newline at end of file +import _Button from "antd/lib/button"; +new _Button(); \ No newline at end of file diff --git a/test/fixtures/object-shorthand/expected.js b/test/fixtures/object-shorthand/expected.js index 047c3813..aab2994d 100644 --- a/test/fixtures/object-shorthand/expected.js +++ b/test/fixtures/object-shorthand/expected.js @@ -1,14 +1,8 @@ -"use strict"; - -var _message2 = _interopRequireDefault(require("antd/lib/message")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _message2.default)('xxx'); - +import _message from "antd/lib/message"; +_message('xxx'); function App() { - var message = 'xxx'; + const message = 'xxx'; console.log({ - message: message + message }); } \ No newline at end of file diff --git a/test/fixtures/property/expected.js b/test/fixtures/property/expected.js index cc989381..ea4e270f 100644 --- a/test/fixtures/property/expected.js +++ b/test/fixtures/property/expected.js @@ -1,11 +1,4 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", { - component: _button.default -})); +import _Button from "antd/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", { + component: _Button +})); \ No newline at end of file diff --git a/test/fixtures/react-element/expected.js b/test/fixtures/react-element/expected.js index e73fcdd7..9f2da180 100644 --- a/test/fixtures/react-element/expected.js +++ b/test/fixtures/react-element/expected.js @@ -1,9 +1,2 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx"))); +import _Button from "antd/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx"))); \ No newline at end of file diff --git a/test/fixtures/react-toolbox/expected.js b/test/fixtures/react-toolbox/expected.js index 4cc43665..5986e275 100644 --- a/test/fixtures/react-toolbox/expected.js +++ b/test/fixtures/react-toolbox/expected.js @@ -1,7 +1,2 @@ -"use strict"; - -var _app_bar = _interopRequireDefault(require("react-toolbox/lib/app_bar")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _app_bar.default)('xxx'); \ No newline at end of file +import _AppBar from "react-toolbox/lib/app_bar"; +_AppBar('xxx'); \ No newline at end of file diff --git a/test/fixtures/return/expected.js b/test/fixtures/return/expected.js index f39399f8..c9eace99 100644 --- a/test/fixtures/return/expected.js +++ b/test/fixtures/return/expected.js @@ -1,29 +1,20 @@ -"use strict"; - -var _toast2 = _interopRequireDefault(require("antd/lib/toast")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - +import _toast from "antd/lib/toast"; function a() { - return _toast2.default; + return _toast; } - function b(toast) { return toast; } - function c() { var toast = 'toast'; return toast; } - function d() { var toast = 'toast'; return function () { return toast; }; } - -var e = function e() { - return _toast2.default; -}; +const e = () => { + return _toast; +}; \ No newline at end of file diff --git a/test/fixtures/sequence-expression/expected.js b/test/fixtures/sequence-expression/expected.js index ff610a3e..c1358c3d 100644 --- a/test/fixtures/sequence-expression/expected.js +++ b/test/fixtures/sequence-expression/expected.js @@ -1,9 +1,3 @@ -"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); \ No newline at end of file +import _Button from "antd/lib/button"; +true, _Button; +true ? (true, _Button) : (false, _Button); \ No newline at end of file diff --git a/test/fixtures/specifier-alias/expected.js b/test/fixtures/specifier-alias/expected.js index 5d368235..adf01f00 100644 --- a/test/fixtures/specifier-alias/expected.js +++ b/test/fixtures/specifier-alias/expected.js @@ -1,10 +1,3 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var foo = _button.default.foo; -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, null, "xxxx"))); +import _Button from "antd/lib/button"; +const foo = _Button.foo; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx"))); \ No newline at end of file diff --git a/test/fixtures/style-library-name/expected.js b/test/fixtures/style-library-name/expected.js index 14fc92d6..8f9e69b9 100644 --- a/test/fixtures/style-library-name/expected.js +++ b/test/fixtures/style-library-name/expected.js @@ -1,11 +1,3 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -require("element-ui/lib/theme-chalk/button"); - -var _button2 = _interopRequireDefault(require("element-ui/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -ReactDOM.render( /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button2.default, null, "xxxx"))); +import "element-ui/lib/theme-chalk/button"; +import _Button from "element-ui/lib/button"; +ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, null, "xxxx"))); \ No newline at end of file diff --git a/test/fixtures/super-class/expected.js b/test/fixtures/super-class/expected.js index e1e5cdbb..6d262876 100644 --- a/test/fixtures/super-class/expected.js +++ b/test/fixtures/super-class/expected.js @@ -1,3 +1,2 @@ import _Button from "antd/lib/button"; - -class MyButton extends _Button {} +class MyButton extends _Button {} \ No newline at end of file diff --git a/test/fixtures/switch/expected.js b/test/fixtures/switch/expected.js index ab662319..9a1930ee 100644 --- a/test/fixtures/switch/expected.js +++ b/test/fixtures/switch/expected.js @@ -1,13 +1,7 @@ -"use strict"; - -var _select = _interopRequireDefault(require("antd/lib/select")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -switch (_select.default) { - case _select.default: +import _Select from "antd/lib/select"; +switch (_Select) { + case _Select: console.log('foo'); - default: console.log('bar'); -} +} \ No newline at end of file diff --git a/test/fixtures/use-multiple-times/expected.js b/test/fixtures/use-multiple-times/expected.js index 35fcd0c3..be6cc4f5 100644 --- a/test/fixtures/use-multiple-times/expected.js +++ b/test/fixtures/use-multiple-times/expected.js @@ -1,10 +1,4 @@ -"use strict"; - -var _button = _interopRequireDefault(require("antd-mobile/lib/button")); - -var _a = _interopRequireDefault(require("a")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _a.default)(_button.default); -(0, _a.default)(_button.default); \ No newline at end of file +import _Button from "antd-mobile/lib/button"; +import a from 'a'; +a(_Button); +a(_Button); \ No newline at end of file diff --git a/test/fixtures/variable-declarator-renamed-import/expected.js b/test/fixtures/variable-declarator-renamed-import/expected.js index e384657f..f46e122a 100644 --- a/test/fixtures/variable-declarator-renamed-import/expected.js +++ b/test/fixtures/variable-declarator-renamed-import/expected.js @@ -1,8 +1,3 @@ -"use strict"; - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var Button = 'Another Button'; -var a = _button.default; +import _Button from "antd/lib/button"; +const Button = 'Another Button'; +const a = _Button; \ No newline at end of file diff --git a/test/fixtures/variable-declarator/expected.js b/test/fixtures/variable-declarator/expected.js index 14a1e7f2..5cc914cf 100644 --- a/test/fixtures/variable-declarator/expected.js +++ b/test/fixtures/variable-declarator/expected.js @@ -1,10 +1,4 @@ -"use strict"; - -var _modal = _interopRequireDefault(require("antd/lib/modal")); - -var _button = _interopRequireDefault(require("antd/lib/button")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var a = _button.default; -var b = (a, _modal.default); +import _Modal from "antd/lib/modal"; +import _Button from "antd/lib/button"; +const a = _Button; +const b = (a, _Modal); \ No newline at end of file diff --git a/test/fixtures/variable-scope/expected.js b/test/fixtures/variable-scope/expected.js index 1654d70e..d2f1665c 100644 --- a/test/fixtures/variable-scope/expected.js +++ b/test/fixtures/variable-scope/expected.js @@ -1,74 +1,36 @@ -"use strict"; - -var _react = _interopRequireDefault(require("react")); - -var _message3 = _interopRequireDefault(require("antd/lib/message")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -(0, _message3.default)('xxx'); - -_message3.default.error('error'); - -var testIf = function testIf(message) { +import _message from "antd/lib/message"; +_message('xxx'); +_message.error('error'); +const testIf = message => { if (message) return message; }; - -var testIf2 = function testIf2() { - if (_message3.default) return _message3.default; +const testIf2 = () => { + if (_message) return _message; }; - -var testExpression = function testExpression(message) { - return message + 'test'; -}; - -var testExpression2 = function testExpression2() { - return _message3.default + 'test'; -}; - -var testNestFunction = function testNestFunction(message) { - return function (a) { - return message; - }; -}; - -var testNestFunction2 = function testNestFunction2() { - return function (a) { - return _message3.default; - }; -}; - -var testFunction = function testFunction(message) { +const testExpression = message => message + 'test'; +const testExpression2 = () => _message + 'test'; +const testNestFunction = message => a => message; +const testNestFunction2 = () => a => message; +const testFunction = message => { message.error('error'); return message.test; }; - -var testFunction1 = function testFunction1() { - return _message3.default.error('error'); -}; - -var testFunction2 = function testFunction2(message) { - return message.error('error'); -}; - -var testFunction3 = function testFunction3(message) { +const testFunction1 = () => _message.error('error'); +const testFunction2 = message => message.error('error'); +const testFunction3 = message => { if (message) { message = message.test.message; - - for (var i = 0; i < 10; i++) { - var _message2 = i; - - if (_message2 > 4) { - return _message2; + for (let i = 0; i < 10; i++) { + const message = i; + if (message > 4) { + return message; } } } - message = null; return message; }; - function App() { - var message = 'xxx'; - return /*#__PURE__*/_react.default.createElement("div", null, message); -} + const message = 'xxx'; + return /*#__PURE__*/React.createElement("div", null, message); +} \ No newline at end of file diff --git a/test/index.test.js b/test/index.test.js index 9be76f02..2518bbbe 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -16,6 +16,8 @@ describe('index', () => { fixtures = onlyFixtures; } + // fixtures = fixtures.slice(0, 1); + fixtures.map(caseName => { const fixtureDir = join(fixturesDir, caseName); const actualFile = join(fixtureDir, 'actual.js');