[Vuejs]-No-return-assign / no-unused-expressions

3👍

The reason you’re getting these kinds of warnings is because it’s confusing to put imperative code inside an expression. Your code is equivalent to something like this, which is much more readable:

this.data.forEach(el => {
    if (el.value === newValue) {
        el[column] = newValue[column];
        return newValue[column];
    else {
        return el;
    }
});

It’s worth noting that the return value of a callback in forEach is ignored, so your code actually probably does something different to what you intended. If the assignment statement is all you wanted, you can do this:

this.data
    .filter(el => el.value === newValue)
    .forEach(el => {
        el[column] = newValue[column];
    });

Leave a comment