Skip to content

Latest commit

 

History

History

plugin-convert-assignment-to-comparison

@putout/plugin-convert-assignment-to-comparison NPM version

You should almost never have an if...else with an assignment like a = b as a condition.

(c) MDN

🐊Putout plugin adds ability to convert assignment to comparison.

Install

npm i @putout/plugin-convert-assignment-to-comparison -D

Rule

{
    "rules": {
        "convert-assignment-to-comparison": "on"
    }
}

❌ Example of incorrect code

if (a = b) {}

✅ Example of correct code

if (a === b) {}

License

MIT