🐊Putout plugin adds ability to convert anonymous to arrow function
npm install @putout/plugin-convert-to-arrow-function[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-to-arrow-function.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-to-arrow-function "npm"
> An arrow function expression is a compact alternative to anonymous function.
>
> (c) MDN
🐊Putout plugin convert anonymous to arrow function.
```
npm i @putout/plugin-convert-to-arrow-function
`json`
{
"rules": {
"convert-to-arrow-function": "on"
}
}
`js
module.exports = function(a, b) {};
function x() {
return function(a) {
return b;
};
}
call(function() {
return 'world';
});
`
`js
module.exports = (a, b) => {};
function x() {
return (a) => {
return b;
};
}
call(() => {
return 'world';
});
`
Linter | Rule | Fix
--------|-------|------------|
🐊 Putout | convert-to-arrow-function | ✅
⏣ ESLint | prefer-arrow-callback` | ✅
MIT