-1

I did not find a documentation in the whole eslint website, and I do not know if there is a plugin to forbid arguments editions.

Here is an example of code which should be:

Incorrect:

const incorrectUpdate = (data) => {
  data.field = data.field === 'Hello' ? 'Stack' : 'Overflow';
  return data;
};

Correct:

const validUpdate = (data) => {
  return { ...data, field: data.field === 'Hello' ? 'Stack' : 'Overflow' };
};

Please can you send me the eslint config?

Can you left Array.reduce to continue accumulator edition ?

karkael
  • 431
  • 2
  • 9
  • 1
    Assuming I've understood "arguments editions" correctly, and you mean mutating the parameter values, [`no-param-reassign`](https://eslint.org/docs/latest/rules/no-param-reassign) can do that. – jonrsharpe Mar 15 '23 at 15:57

1 Answers1

0

Activate no-param-reassign.

For Array.reduce, use every time the same variable name: "acc".

Here is the config, in .eslintrc:

"no-param-reassign": [
  "warn",
  {
    "props": true,
    "ignorePropertyModificationsFor": ["acc"]
  }
],
karkael
  • 431
  • 2
  • 9