@putout/plugin-remove-useless-conditions
🐊Putout plugin adds ability to remove useless conditions
Last updated 3 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/plugin-remove-useless-conditions 
SYNC missed versions from official npm registry.

@putout/plugin-remove-useless-conditions NPM version

The if statement executes a statement if a specified condition is truthy. If the condition is falsy, another statement can be executed.

(c) MDN

????Putout plugin adds ability to remove useless conditions. Merged to @putout/plugin-conditions.

Install

npm i @putout/plugin-remove-useless-conditions

Rule

{
    "rules": {
        "remove-useless-conditions/evaluate": "on",
        "remove-useless-conditions/simplify": "on"
    }
}

Evaluate

❌ Example of incorrect code

const a = [];
const c = a;

if (a) {
    console.log(a);
}

✅ Example of correct code

const a = [];
const c = a;

console.log(a);

Simplify

❌ Example of incorrect code

if (zone?.tooltipCallback) {
    zone.tooltipCallback(e);
}

if (a)
    alert('hello');
else
    alert('hello');

✅ Example of correct code

zone?.tooltipCallback(e);

alert('hello');

License

MIT

Current Tags

  • 3.0.1                                ...           latest (3 years ago)

4 Versions

  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |