typescript.lang.correctness.useless-ternary.useless-ternary
semgrep
Author
unknown
Download Count*
License
It looks like no matter how $CONDITION is evaluated, this expression returns $ANS. This is probably a copy-paste error.
Run Locally
Run in CI
Defintion
rules:
- id: useless-ternary
pattern: |
$CONDITION ? $ANS : $ANS
message: It looks like no matter how $CONDITION is evaluated, this expression
returns $ANS. This is probably a copy-paste error.
languages:
- typescript
- javascript
metadata:
category: correctness
technology:
- react
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
severity: ERROR
Examples
useless-ternary.tsx
// ruleid:useless-ternary
card.id.includes(":") ? `/r/${card.id}` : `/r/${card.id}`
// ok
card.id.includes(":") ? `/s/${card.id}` : `/r/${card.id}`
Short Link: https://sg.run/9rN0