1.2.0 • Published 3 years ago

function-codemorphs v1.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

function-codemorphs

CircleCI Coverage Status semantic-release Commitizen friendly npm version

codemods for in-IDE refactoring of functions

These aren't really intended to be used with the jscodeshift CLI, but rather for building IDE extensions.

convertArrowFunctionBodyToBlockStatement

Converts an arrow function with an expression body to a block statement.

Before

const foo = () => 'foo!'

After

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

Special Options

selectionStart (number, required)

The start of the selection in the source code. This is used for determining which function to convert.

selectionEnd (number, required)

The end of the selection in the source code. This is used for determining which function to convert.

convertArrowFunctionBodyToExpression

Converts the block statement body of an arrow function to an expression, as long as the body only consists of a return statement.

Before

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

After

const foo = () => 'foo!'

Special Options

selectionStart (number, required)

The start of the selection in the source code. This is used for determining which function to convert.

selectionEnd (number, required)

The end of the selection in the source code. This is used for determining which function to convert.