no-return-assign - 何时禁用
no-return-assign - when to disable
我正在尝试在此对象数组中传递 ID:
const children = [{name: Jack, age: 8}, {name: Joe, age: 6}];
children.forEach((child) => (child.id = v4()));
我一直收到 eslint 错误 no-return-assign
这真的很烦我(双关语)
我试过了:
children.forEach(child => child.id = v4());
children.forEach((child) => (child.id = v4()));
children.forEach(child => (child.id = v4()));
children.forEach((child) => {
return child.id = v4()
});
None 工作。
我应该禁用 eslint 吗?有解决方法吗?
好吧,不要 return 回调函数中的任何内容。随便写
children.forEach(child => {
child.id = v4();
});
甚至更简单
for (const child of children) {
child.id = v4();
}
我正在尝试在此对象数组中传递 ID:
const children = [{name: Jack, age: 8}, {name: Joe, age: 6}];
children.forEach((child) => (child.id = v4()));
我一直收到 eslint 错误 no-return-assign
这真的很烦我(双关语)
我试过了:
children.forEach(child => child.id = v4());
children.forEach((child) => (child.id = v4()));
children.forEach(child => (child.id = v4()));
children.forEach((child) => {
return child.id = v4()
});
None 工作。
我应该禁用 eslint 吗?有解决方法吗?
好吧,不要 return 回调函数中的任何内容。随便写
children.forEach(child => {
child.id = v4();
});
甚至更简单
for (const child of children) {
child.id = v4();
}