@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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 4.0.0
    3,136
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 4.0.0
    3,136
  • 3.0.0
    15,121
  • 2.0.0
    229
  • 1.1.0
    4
  • 1.0.0
    0

Package Sidebar

Install

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

Weekly Downloads

18,490

Version

4.0.0

License

MIT

Unpacked Size

4.89 kB

Total Files

4

Last publish

Collaborators

  • coderaiser