Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Refactoring: Add Braces to JSX Attribute #61

Closed
nicoespeon opened this issue Dec 25, 2019 · 1 comment
Closed

New Refactoring: Add Braces to JSX Attribute #61

nicoespeon opened this issue Dec 25, 2019 · 1 comment
Labels
✨ Feature New refactoring or feature 👋 Good first issue Good for newcomers

Comments

@nicoespeon
Copy link
Owner

Is this request related to a problem? Please describe.

Sometimes, I need to transform a primitive JSX attribute into an expression. To do so, I need to wrap the attribute with braces. I'd be nice if Abracadabra could do it for me.

Describe the solution you'd like

With following code:

function render() {
  return <Header title="Hello" />; 
}

If my cursor is on the title="Hello" attribute, I'd like to propose a quick fix to add braces around:

function render() {
  return <Header title={"Hello"} />; 
}

Additional context

The difference between these 2 snippets in terms of AST is a JSXExpressionContainer.

First AST is:

image

Second AST is:

image

So we need to put the value of the attribute into a JSXExpressionContainer if it's not already.

@nicoespeon nicoespeon added ✨ Feature New refactoring or feature 👋 Good first issue Good for newcomers labels Dec 25, 2019
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 16, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 16, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 16, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 16, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 20, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 20, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 20, 2020
timvancleef pushed a commit to timvancleef/abracadabra that referenced this issue Jan 20, 2020
@nicoespeon
Copy link
Owner Author

Implemented in #70 that got merged. This refactoring will be shipped in the next release, thanks to @timvancleef 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature New refactoring or feature 👋 Good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant