`no-unused-collection` incorrectly fires in this situation
djahandarie opened this issue · comments
We ran into this case of no-unused-collection
incorrectly firing on a collection which is actually used:
https://github.com/themoeway/yomitan/blob/7a8612b035e0847ea0f0e2fc6643693c89bc80f4/ext/js/pages/permissions-main.js#L107-L116
Reproducer
(I didn't test this but I assume this is the minimal case)
const a = {foo: false};
const b = {foo: false};
const xs = [a, b];
for (let i = 0; i < 2; ++i) {
xs[i].foo = true;
}
// I assume `xs[0].foo = true` would also trigger this issue even without the loop
Basically, xs
is only being used as a list of pointers to items that will get modified.
Expected behavior
no-unused-collection
should not fire here as the collection is being used.
eslint-plugin-sonarjs version: 0.23.0
eslint version: 8.56
Node.js version: 20
Rule key: no-unused-collection
Hi @djahandarie,
thanks for reporting this FP. We'll fix this for the next release.