Comments (13)
Huge thanks for you for this plugin!
i’m glad it’s useful for you!
I found just one drawback. Plugin pose all
JSX
tags just in one line. How can I avoid it?
i don’t know, but maybe we can find out together.
do you know how babel/ESTree represents whitespace?
from babel-plugin-transform-react-createelement-to-jsx.
Unfortunately, nope.
from babel-plugin-transform-react-createelement-to-jsx.
so you say
<ol>
<li>a</li>
<li>b</li>
</ol>
gets converted to
<ol><li>a</li><li>b</li></ol>
or what?
from babel-plugin-transform-react-createelement-to-jsx.
I mean
React.createElement("ul", React.createElement("li"))
converts to
<ul><li></li></ul>
not
<ul>
<li></li>
</ul>
from babel-plugin-transform-react-createelement-to-jsx.
well, that’s correct, no?
React.createElement("ul",
React.createElement("li")
)
should convert to
<ul>
<li></li>
</ul>
or similar.
from babel-plugin-transform-react-createelement-to-jsx.
It's not just JSX. I noticed that it did this for simple arrays also. I tried with a simple example:
Before:
let my_list = [
"one",
"two",
"three",
"four"
];
after:
let my_list = ["one", "two", "three", "four"];
from babel-plugin-transform-react-createelement-to-jsx.
huh? that’s really weird, as i only replace nodes that pass all the checks (i.e. are React.createElement
calls, etc.)
is what you observe inside of such an expression or will a file containing only what you showed me be transformed like that?
from babel-plugin-transform-react-createelement-to-jsx.
Only what I showed you. It's a file containing only an array
from babel-plugin-transform-react-createelement-to-jsx.
Adding the following to the test file will reproduce this:
it('should ignore regular javascript arrays', () => {
let source = `
let list = [
"one",
"two",
"three",
]
`
expect(source).to.convertTo(source)
})
results in:
1) createElement-to-JSX should ignore regular javascript arrays:
Code “
let list = [
"one",
"two",
"three",
]
” converts wrongly
+ expected - actual
-let list = ["one", "two", "three"];
+ let list = [
+ "one",
+ "two",
+ "three",
+ ]
+
at Assertion.<anonymous> (test/chai-convert-to.js:62:41)
at Assertion.ctx.(anonymous function) [as convertTo] (node_modules/chai/lib/chai/utils/addMethod.js:41:25)
at Context.<anonymous> (test/index.js:72:21)
I'll try to debug further, to see if I can't get to the bottom of it.
from babel-plugin-transform-react-createelement-to-jsx.
Further investigation shows that this is a problem with babel itself. I can reproduce it by running babel without any plugin options. Using the babel --retain-lines
flag can mostly mitigate it, but not perfectly:
before
let foo = [
'one',
'two',
'three'
];
after
let foo = [
'one',
'two',
'three'];
from babel-plugin-transform-react-createelement-to-jsx.
OK, so it’s not actually a bug and i can close it, right?
from babel-plugin-transform-react-createelement-to-jsx.
I should think so
from babel-plugin-transform-react-createelement-to-jsx.
OK, thanks for investigating!
from babel-plugin-transform-react-createelement-to-jsx.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-transform-react-createelement-to-jsx.