I often add an extra line or two of no-op code in order to improve readability. But in these examples, the code clearly wasn't written to communicate anything, but rather by mistake.
So e.g. you have lines like:
const isCar = (wheels === 4) && (steeringWheels === 1) && (canDrive === true);
if (isCar) { ... }
and not lines like: if ((wheels === 4) && (steeringWheels === 1) && canDrive === true) { ... }
And similarly: const isCar = (wheels === 4) && (steeringWheels === 1) && (canDrive === true);
return isCar;
Rather than: return (wheels === 4) && (steeringWheels === 1) && (canDrive === true);
I'd actually like linters for JS and Python to enforce named conditionals and named returns, but afaik no one has done this yet.Other linters might complain about `==`, though ;)
Often a code comment can be avoided (and clarity improved) by giving a name to an intermediate value rather than letting it be a nameless expression.
I like it! But I don't think of this a no-op code and would not imagine a lint rule objecting to it. That said, a code minifier (or compiler) would be well positioned to optimize that code, so you shouldn't even have to worry about even the thought of perf implications.