function-codemorphs

1.2.0 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i function-codemorphs

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

405 kB

Total Files

13

Last publish

Collaborators

  • jedwards1211