Search code examples
eslinttypescript-eslint

Eslint rule for enforcing spaces around a ternary statement's colon?


Is there an eslint rule to check that ternary colons have a space around them? There is a multiline-ternary rule, but I can't find one about the spacing.

Example of bad formatting:

showAreas ? areas: undefined
//               ^ missing a space

Example of good formatting:

showAreas ? areas : undefined

Solution

  • You can use this rule for enforcing spaces Space Infix Ops