wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase
MIT License
1.46k stars 56 forks source link

Wrap new component code with fragment only if needed #30

Closed chiptus closed 6 years ago

chiptus commented 6 years ago

Thank you for this extension, for a long time I wanted one like this (I started creating one, but didn't have the time to make it more production ready). Now for the bug/feature-request:

Not always I will need a fragment (<>) wrapping my new component. It should wrap only when there's more than one element in the root

borislit commented 6 years ago

@chiptus Glad you liked it! Thank you! As for the idea - I agree completely! The problem here is that Babel doesnt know how to parse multiline JSX, and throws an error. Thats why I wrap it by default. The naive solution would be to have a try-catch statement, with a fallback in the catch statement. But that pretty bad.

borislit commented 6 years ago

@chiptus i've created a naive implementation for now https://github.com/wix/vscode-glean/commit/24ff2b074f5d2512cbdbea9fe6fe2616108caad2 Check it out in v4.0.7

chiptus commented 6 years ago

I will check it out, thanks!

On Wed, Oct 31, 2018, 12:50 Boris Litvinsky <notifications@github.com wrote:

@chiptus https://github.com/chiptus i've created a naive implementation for now 24ff2b0 https://github.com/wix/vscode-glean/commit/24ff2b074f5d2512cbdbea9fe6fe2616108caad2 Check it out in v4.0.7

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wix/vscode-glean/issues/30#issuecomment-434642587, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUVF3Kei-og1ewRMF4cxUHXwIPg-XQjks5uqYB_gaJpZM4YCAaz .