Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/hikire/babel-plugin-arrow-functions-implicit-return
- Owner: hikire
- License: mit
- Created: 2018-05-29T15:58:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-09T20:19:14.000Z (over 6 years ago)
- Last Synced: 2024-12-07T21:44:14.225Z (about 2 months ago)
- Topics: arrow-functions, arrow-functions-implicit, babel, implicit-return
- Language: JavaScript
- Size: 57.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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"]
});
```