Skip to main content

js/noCommaOperator

disallow comma operators

ESLint Equivalent: no-sequences

Examples

Invalid

(0, 1, 2)

 file.ts:1 lint/js/noCommaOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid the comma operator. It can lead to easy mistakes and ambiguous
    code.

    (0, 1, 2)
    ^^^^^^^^^

  If you want multiple expressions, then break it up.


test(), rome()

 file.ts:1 lint/js/noCommaOperator ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  Avoid the comma operator. It can lead to easy mistakes and ambiguous
    code.

    test(), rome()
    ^^^^^^^^^^^^^^

  If you want multiple expressions, then break it up.

Valid

foo(0, 1, 2)
[1, 2,]
[1,,,3]
let a, b, c;