babel-plugin-arrow-functions-implicit-return

0.1.1 • Public • Published

Arrow functions implicit return

This plugin allows you to use arrow functions like do expressions.

Examples

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

With JSX

const getUserNav = () => {
    <UserConsumer>
        {
            (user) => {
                if(user){
                    <span>Hello {user.name}!<span>;
                } else {
                    <a onClick={showLogin}>Login</a>;
                }
            }
        }
    </UserConsumer>
};

Installation

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

Usage

Via .babelrc (Recommended)

.babelrc

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

Via CLI

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

Via Node API

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

Package Sidebar

Install

npm i babel-plugin-arrow-functions-implicit-return

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

6.88 kB

Total Files

8

Last publish

Collaborators

  • zurajanainazayda