sequences
Reports using the comma operator in expressions.
✅ This rule is included in the ts javascript presets.
The comma operator evaluates each of its operands and returns the value of the last operand. It can hide side effects and make code harder to read. Prefer writing separate expressions or statements instead.
Examples
Section titled “Examples”const const result: number
result = (const doSideEffect: () => void
doSideEffect(), const computeValue: () => number
computeValue());const doSideEffect: () => void
doSideEffect();const const result: number
result = const computeValue: () => number
computeValue();Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”Some developers prefer the succinct style of sequences and find it more readable. If you explicitly prefer sequences then you can disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noCommaOperator - ESLint:
no-sequences
Made with ❤️🔥 around the world by
the Flint team and contributors.