Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

no-unused-collection incorrectly fires in this situation #449

@djahandarie

Description

@djahandarie

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions