4.0.0 β€’ Published 12 months ago

@putout/plugin-convert-to-arrow-function v4.0.0

Weekly downloads
2,823
License
MIT
Repository
github
Last release
12 months ago

@putout/plugin-convert-to-arrow-function NPM version

An arrow function expression is a compact alternative to anonymous function.

(c) MDN

🐊Putout plugin convert anonymous to arrow function.

Install

npm i @putout/plugin-convert-to-arrow-function

Rule

{
    "rules": {
        "convert-to-arrow-function": "on"
    }
}

❌ Example of incorrect code

module.exports = function(a, b) {};

function x() {
    return function(a) {
        return b;
    };
}

call(function() {
    return 'world';
});

βœ… Example of correct code

module.exports = (a, b) => {};

function x() {
    return (a) => {
        return b;
    };
}

call(() => {
    return 'world';
});

Comparison

LinterRuleFix
🐊 Putoutconvert-to-arrow-functionβœ…
⏣ ESLintprefer-arrow-callbackβœ…

License

MIT