@putout/plugin-convert-assignment-to-comparison
Version:
πPutout plugin adds ability convert assignment to comparison
45 lines (30 loc) β’ 1.01 kB
Markdown
# @putout/plugin-convert-assignment-to-comparison [![NPM version][NPMIMGURL]][NPMURL]
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-assignment-to-comparison.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-assignment-to-comparison"npm"
> You should almost never have an `if...else` with an assignment like `a = b` as a condition.
>
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)
π[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to convert assignment to comparison.
Merged to [`@putout/plugin-assignment`](https://www.npmjs.com/package/@putout/plugin-assignment).
## Install
```
npm i @putout/plugin-convert-assignment-to-comparison -D
```
## Rule
```json
{
"rules": {
"convert-assignment-to-comparison": "on"
}
}
```
## β Example of incorrect code
```js
if (a = b) {}
```
## β
Example of correct code
```js
if (a === b) {}
```
## License
MIT