Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hikire/babel-plugin-arrow-functions-implicit-return

Arrow functions blocks behave like do expressions
https://github.com/hikire/babel-plugin-arrow-functions-implicit-return

arrow-functions arrow-functions-implicit babel implicit-return

Last synced: about 1 month ago
JSON representation

Arrow functions blocks behave like do expressions

Awesome Lists containing this project

README

        

# Arrow functions implicit return

This plugin allows you to use arrow functions like [do expressions](https://github.com/getify/You-Dont-Know-JS/blob/master/types%20%26%20grammar/ch5.md#statement-completion-values).

## Examples

```js
const shows = ["Death Note", "Steins;Gate", "Maho shojo XD"];
const nextShow = prevShow => {
const prevIndex = shows.findIndex(show => show === prevShow);
shows[(prevIndex + 1) % shows.length];
};
```

### With JSX

```js
const getUserNav = () => {

{user => {
if (user) {
Hello {user.name}!;
} else {
Login;
}
}}
;
};
```

## Installation

```sh
npm install --save-dev babel-plugin-arrow-functions-implicit-return
```

## Usage

### Via `.babelrc` (Recommended)

#### .babelrc

```js
{
"plugins": ["arrow-functions-implicit-return"]
}
```

### Via CLI

```sh
babel --plugins arrow-functions-implicit-return script.js
```

### Via Node API

```js
require("babel-core").transform("code", {
plugins: ["arrow-functions-implicit-return"]
});
```