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

@putout/plugin-remove-useless-type-conversion NPM version

It is possible to use a couple of NOT operators (!!) in series to explicitly force the conversion of any value to the corresponding boolean primitive. The conversion is based on the "truthyness" or "falsyness" of the value.

The same conversion can be done through the Boolean function.

(c) MDN

????Putout plugin adds ability to remove useless type conversion. Merged to @putout/plugin-types.

Install

npm i @putout/plugin-remove-useless-type-conversion

Rule

{
    "rules": {
        "remove-useless-type-conversion/named": "on",
        "remove-useless-type-conversion/with-double-negations": "on"
    }
}

named

❌ Example of incorrect code

const a = !![1].includes(1);
const b = Boolean([1].includes(1));

✅ Example of correct code

const a = [1].includes(1);

with-double-negations

❌ Example of incorrect code

if (!!a) {
    console.log('hi');
}

✅ Example of correct code

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

Comparison

Linter Rule Fix
???? Putout remove-useless-type-conversion
ESLint no-implicit-coercion

License

MIT

Current Tags

  • 3.0.1                                ...           latest (3 years ago)

5 Versions

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

Copyright 2013 - present © cnpmjs.org | Home |