2.0.0 β€’ Published 11 months ago

@putout/plugin-convert-assignment-to-comparison v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@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