JavaScript

JavaScript

By DeepSource

Found redundant literal in a logical expression JS-W1043

Anti-pattern
Minor

Using literals like true, 0, and false on either side of a logical operator is unnecessary. For example, true && something will always evaluate to something.

If you're using || to set defaults (like num || 10), use the ?? operator instead (num ?? 10).

Bad Practice

const makesNoSense = someFunc() && true
const value = getValue() || 'default'

Recommended

const thisIsFine = someFunc()
const value = getValue() ?? 'default'