sindresorhus/eslint-plugin-unicorn
Rule proposal: `prefer-change-array-by-copy`
Fermée
#1 514 ouverte le 8 sept. 2021
help wantednew rule
Métriques du dépôt
- Stars
- (5 022 étoiles)
- Métriques de merge PR
- (Merge moyen 1j 16h) (399 PRs mergées en 30 j)
Description
"Change Array by copy" proposal
Fail
array.reverse();
array.sort();
const array = [...foo];
array.splice(0, 1);
const array = [...foo];
array[1] = 'changed';
Pass
array = array.toReversed();
array = array.toSorted();
const array = foo.toSpliced(0, 1);
const array = foo.with(1, 'changed');