Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@putout/plugin-convert-typeof-to-is-type

coderaiser6.1kMIT2.0.1

🐊Putout plugin adds ability to convert typeof to is type

putout, putout-plugin, plugin, convert, typeof, is-type

readme

@putout/plugin-convert-typeof-to-is-type NPM version

The typeof operator returns a string indicating the type of the unevaluated operand.

(c) MDN

🐊Putout plugin adds ability to convert typeof to is type. Merged to @putout/plugin-types.

Install

npm i @putout/plugin-convert-typeof-to-is-type -D

Rule

{
    "rules": {
        "convert-typeof-to-is-type": "on"
    }
}

❌ Example of incorrect code

if (typeof a === 'boolean')
    return x;

✅ Example of correct code

const isBool = (a) => typeof a === 'boolean';

if (isBool(a))
    return x;

License

MIT