wix-incubator / vscode-glean

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

Render conditionally doesn't insert { } required for JSXExpressionContainer #105

Closed jedwards1211 closed 4 years ago

jedwards1211 commented 4 years ago

I'd recommend using JSCodeshift or at least Recast to transform the AST

Before

/**
 * @prettier
 * @flow
 */

import * as React from 'react'

export type Props = {

}

export default function Test(props: Props): React.Node {
  return (
    <div>
      <Foo />
    </div>
  )
}

After

/**
 * @prettier
 * @flow
 */

import * as React from 'react'

export type Props = {

}

export default function Test(props: Props): React.Node {
  return (
    <div>
(
true
?       <Foo />

: null
)    </div>
  )
}
anhthii commented 4 years ago

same here

jedwards1211 commented 4 years ago

is there anyone this doesn't happen for? Maybe it's specific to .js files?

borislit commented 4 years ago

Hey @anhthii @jedwards1211 I was able to reproduce an issue. Im currently working on a version that will include several fixes. Including this one

borislit commented 4 years ago

:tada: This issue has been resolved in version 4.20.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

borislit commented 4 years ago

Just release a fix. Pls validate!

anhthii commented 4 years ago

@borislit It works perfectly. Thankyou!