sloops77 / eslint-plugin-better-mutation

Eslint rules to enforce function-scope mutation only
MIT License
20 stars 6 forks source link

Permit modification of variables created using array prototype functions that result in new arrays #69

Open sloops77 opened 3 months ago

sloops77 commented 3 months ago

In most cases its weird to modify an array created using map, however it may be desired in certain circumstances

eg the following could be considered to be ok.

'const a = x.map(v => v); a[0] = 2;',
The following array methods are theoretically ok:
      'Array.prototype.concat',
      'Array.prototype.filter',
      'Array.prototype.flat',
      'Array.prototype.flatMap',
      'Array.prototype.map',
      'Array.prototype.slice',
      'Array.prototype.toReverse',
      'Array.prototype.toSorted',
      'Array.prototype.toSpliced',
      'Array.prototype.with',