dev-guard-as-an-expression
This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.
Reported when a __DEV__ guard is written as && or ?: where an if would do the same thing.
__DEV__ && publish() does what if (__DEV__) publish() does, and the framework asks for the
if.
Not because the build cares. Measured with esbuild and __DEV__: false: the && form is
dropped where an unminified if (false) { … } keeps its whole block and its strings, and with
minifying on — which every package here does — both vanish the same way.
The reason is that a flag with two spellings has to be read twice by everything that reads it: a person grepping, somebody learning the codebase, and this checker, which reported dev-only code for being written the other way until it was taught both.
Only a STATEMENT is reported. const name = __DEV__ ? displayName(x) : "" uses the value and
an if is no replacement for it, so it is left alone — and if (__DEV__ && ready) is the
shape being asked for, not an instance of the fault.
Next
- All rules — the other checks this one runs beside.
- Checking your app — how to run it, and what it proves.