4.0.0 β’ Published 3 years ago
@putout/plugin-convert-to-arrow-function v4.0.0
@putout/plugin-convert-to-arrow-function 
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-functionRule
{
"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