Skip to content

vscodeshift/function-codemorphs

Repository files navigation

@vscodeshift/function-codemorphs

CircleCI Coverage Status semantic-release Commitizen friendly Visual Studio Marketplace Version

Commands for refactoring functions

Convert arrow function body to block statement

Before

const foo = () => 'foo!'

Position cursor anywhere in the arrow function and then run the Convert arrow function body to block statement command.

After

const foo = () => {
  return 'foo!'
}

Convert arrow function body to expression

The inverse of the above. The function body must consist only of a return statement or this will error out.

Before

const foo = () => {
  return 'foo!'
}

Position cursor anywhere in the arrow function and then run the Convert arrow function body to expression command.

After

const foo = () => 'foo!'