Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codemodsquad/function-codemorphs
codemods for in-IDE refactoring of functions
https://github.com/codemodsquad/function-codemorphs
jscodeshift refactoring
Last synced: about 1 month ago
JSON representation
codemods for in-IDE refactoring of functions
- Host: GitHub
- URL: https://github.com/codemodsquad/function-codemorphs
- Owner: codemodsquad
- License: mit
- Created: 2020-02-01T05:43:56.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T06:12:00.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T09:40:42.115Z (8 months ago)
- Topics: jscodeshift, refactoring
- Language: TypeScript
- Size: 3.36 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# function-codemorphs
[![CircleCI](https://circleci.com/gh/codemodsquad/function-codemorphs.svg?style=svg)](https://circleci.com/gh/codemodsquad/function-codemorphs)
[![Coverage Status](https://codecov.io/gh/codemodsquad/function-codemorphs/branch/master/graph/badge.svg)](https://codecov.io/gh/codemodsquad/function-codemorphs)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![npm version](https://badge.fury.io/js/function-codemorphs.svg)](https://badge.fury.io/js/function-codemorphs)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
```js
const foo = () => 'foo!'
```## After
```js
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
```js
const foo = () => {
return 'foo!'
}
```## After
```js
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.