Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[transform-react-jsx] Add useSpread option to transform JSX (#10572)
* [transform-react-jsx] Add useSpread option to transform JSX * Add validation for default option * Add error when using useSpread and useBuiltIns at the same time * Move useSpread to convertAttribute helper function * Add useSpread option to presect-react * Remove casting useSpread to boolean in preset-react option. Co-Authored-By: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
8ffca04
commit 3d2f365
Showing
9 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...bel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var div = <Component {...props} foo="bar" /> |
4 changes: 4 additions & 0 deletions
4
...plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": [["transform-react-jsx", { "useSpread": 0 }]], | ||
"throws": "transform-react-jsx currently only accepts a boolean option for useSpread (defaults to false)" | ||
} |
1 change: 1 addition & 0 deletions
1
.../babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var div = <Component {...props} foo="bar" /> |
6 changes: 6 additions & 0 deletions
6
...el-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": [ | ||
["transform-react-jsx", { "useSpread": true, "useBuiltIns": true }] | ||
], | ||
"throws": "transform-react-jsx currently only accepts useBuiltIns or useSpread but not both" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var div = <Component {...props} foo="bar" /> |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var div = React.createElement(Component, { ...props, | ||
foo: "bar" | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": [["transform-react-jsx", { "useSpread": true }]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters