Hello, I am declaring my next computed function and Slint marks me an error in syntax that I cannot understand, my computed method is the following and I immediately attach the error that this throws at me. Computed property:
columns() {
return this.columnNamesFromCsv.map((columnName) => {
return {
name: columnName,
label: columnName,
align: 'center',
sortable: true,
field: (row) => row[columnName]
};
});
}
Mistake:
error Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`
Thank you in advance for your responses and opinions.
The error is the following:
ESLint recommends omitting "return" in the declaration of an arrow function when the function has only one statement. That is, instead of
we should use
But the problem is that if you want to return an object, you can't transform something like
in this:
Because we have an ambiguity: the braces are understood as the beginning of the block and not as the declaration of an object, causing an error.
But there is a solution, and it is the one that gives you the error message:
Approximate translation:
That is, something like:
In your case it would be: