SonarSource / eslint-plugin-sonarjs

SonarJS rules for ESLint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

zloirock opened this issue · comments

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.

commented

Thanks for reporting this @zloirock,

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