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

4.0.0 • Public • Published

@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

Linter Rule Fix
🐊 Putout convert-to-arrow-function
ESLint prefer-arrow-callback

License

MIT

Package Sidebar

Install

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

Weekly Downloads

17,775

Version

4.0.0

License

MIT

Unpacked Size

4.89 kB

Total Files

4

Last publish

Collaborators

  • coderaiser