Why my Code Get: [eslint] Unexpected function expression. (prefer-arrow-callback) ?
Code:
kitty.save(function (err) {
if (err) {
console.log('a');
}
});
What is wrong?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With