SonarLint v3.3.3
vscode 1.64.2
Possibly false positive in such a case:
[1, 2, 1, 1].reduce(
( acc, n ) => ( acc[n] += 1, acc ), [0, 0, 0] ) // [ 0, 3, 1 ]
// ^
// Unexpected use of comma operator. ( javascript:S878 )
According to JavaScript static code analysis: Comma operator should not be used
Exceptions
Use of comma operator is tolerated:
- If the expression sequence is explicitly wrapped in parentheses.
With additional parentheses the linter issues another warning
[1, 2, 1, 1].reduce(
( acc, n ) => ( ( acc[n] += 1, acc ) ), [0, 0, 0] ) // [ 0, 3, 1 ]
// ^
// Remove these useless parentheses. [+1 location] ( javascript:S1110 )