@putout/plugin-simplify-ternary

putout plugin adds ability to simplify ternary operator

Usage no npm install needed!

<script type="module">
  import putoutPluginSimplifyTernary from 'https://cdn.skypack.dev/@putout/plugin-simplify-ternary';
</script>

README

@putout/plugin-simplify-ternary NPM version Dependency Status

putout plugin adds ability to simplify ternary.

Install

npm i @putout/plugin-simplify-ternary -D

Rule

{
    "rules": {
        "simplify-ternary": "on"
    }
}

❌ Incorrect code example

module.exports = fs.copyFileSync ? fs.copyFileSync : copyFileSync;

x = y ? y : z;
x = y ? z : y;

✅ Correct code Example

module.exports = fs.copyFileSync || copyFileSync;

x = y || z;
x = y && z;

License

MIT