报错
在eslint严格模式下,多次遇到报错:
Unexpected block statement surrounding arrow body; move the returned value immediately after the =>
解决方法
如下所示,
在只有一个返回值时,是这样写的:
let foo = () => {
return 0;
};
let bar = () => {
return {
bar: {
foo: 1,
bar: 2,
}
};
};
eslint规定写成:
let foo1 = () => 0;
let foo3 = () => ({
bar: {
foo: 1,
bar: 2,
}
});
官方:
https://eslint/docs/rules/arrow-body-style
报错
在eslint严格模式下,多次遇到报错:
Unexpected block statement surrounding arrow body; move the returned value immediately after the =>
解决方法
如下所示,
在只有一个返回值时,是这样写的:
let foo = () => {
return 0;
};
let bar = () => {
return {
bar: {
foo: 1,
bar: 2,
}
};
};
eslint规定写成:
let foo1 = () => 0;
let foo3 = () => ({
bar: {
foo: 1,
bar: 2,
}
});
官方:
https://eslint/docs/rules/arrow-body-style