Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
djahandarie opened this issue Feb 15, 2024 · 1 comment · Fixed by #452
Closed

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

djahandarie opened this issue Feb 15, 2024 · 1 comment · Fixed by #452
Assignees
Milestone

Comments

@djahandarie
Copy link

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

@vdiez
Copy link
Contributor

vdiez commented Feb 16, 2024

Hi @djahandarie,

thanks for reporting this FP. We'll fix this for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants