Reputation: 8916
Why my Code Get: [eslint] Unexpected function expression. (prefer-arrow-callback)
?
Code:
kitty.save(function (err) {
if (err) {
console.log('a');
}
});
What is wrong?
Upvotes: 3
Views: 150
Reputation: 19569
You have eslint configured to take arrow functions when they're inline like that. Try this:
kitty.save((err) => {
if (err) {
console.log('a')
}
});
Alternatively, you can disable this eslint rule, whether inline or in your eslintrc file. E.g.
// eslint-disable prefer-arrow-callback
kitty.save(function (err) {
if (err) {
console.log('a');
}
});
You can read a bit more about arrow functions here. And about eslint rules here.
Upvotes: 1