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

Fix FP S2428 (prefer-object-literal): Ignore circular reference assignments #391

Closed
zloirock opened this issue Feb 2, 2023 · 1 comment · Fixed by #427
Closed

Fix FP S2428 (prefer-object-literal): Ignore circular reference assignments #391

zloirock opened this issue Feb 2, 2023 · 1 comment · Fixed by #427
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zloirock
Copy link

zloirock commented Feb 2, 2023

const O = {}; // => error  Declare one or more properties of this object inside of the object literal syntax instead of using separate statements  sonarjs/prefer-object-literal
O.self = O;

The problem is that we can't define self references in the object literal. Sure, it can be worked around - but the error in this case is not what is expected from this rule.

@vilchik-elena vilchik-elena added the bug Something isn't working label Feb 7, 2023
@victor-diez-sonarsource victor-diez-sonarsource added this to the 0.19.0 milestone Apr 21, 2023
@victor-diez-sonarsource
Copy link
Contributor

Thanks for reporting this @zloirock,

we'll add an exception for cases like this one in the next release.

@ilia-kebets-sonarsource ilia-kebets-sonarsource modified the milestones: 0.22.0, 0.23.0 Nov 1, 2023
@yassin-kammoun-sonarsource yassin-kammoun-sonarsource changed the title prefer-object-literal false positive Fix FP prefer-object-literal: Ignore self-reference assignments Nov 2, 2023
@yassin-kammoun-sonarsource yassin-kammoun-sonarsource changed the title Fix FP prefer-object-literal: Ignore self-reference assignments Fix FP prefer-object-literal: Ignore circular reference assignments Nov 2, 2023
@ilia-kebets-sonarsource ilia-kebets-sonarsource changed the title Fix FP prefer-object-literal: Ignore circular reference assignments Fix FP S2428 (prefer-object-literal): Ignore circular reference assignments Nov 2, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working
Projects
None yet
5 participants