Rule author here. Would love to see some examples! I think the closest I’ve (knowingly) done to this is to add an empty else clause that contains a comment.
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.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.
Other linters might complain about `==`, though ;)