Skip to content

Latest commit

 

History

History
 
 

plugin-minify

@putout/plugin-minify NPM version

🐊Putout plugin adds support of minifiers used in @putout/minify and minify.

Install

npm i @putout/plugin-putout -D

Rules

{
    "rules": {
        "minify/convert-if-to-logical": "on",
        "minify/remove-return-undefined": "on",
        "minify/mangle-names": "on",
        "minify/types": "on"
    }
}

convert-if-to-logical

Check out in 🐊Putout Editor.

❌ Example of incorrect code

if (a)
    console.log('hello');

if (b) {
    console.log('hello');
    console.log('world');
}

✅ Example of correct code

a && console.log('hello');

b && (console.log('hello'), console.log('world'));

remove-return-undefined

❌ Example of incorrect code

const fn = () => {
    if (a)
        return undefined;
    
    return undefined;
};

✅ Example of correct code

const fn = () => {
    if (a)
        return;
};

mangle-names

Check out in 🐊Putout Editor.

❌ Example of incorrect code

function generate() {
    const hello = 'hi';
    return hello;
}

✅ Example of correct code

function generate() {
    const a = 'hi';
    return a;
}

types

Check out in 🐊Putout Editor.

❌ Example of incorrect code

const a = undefined;
const b = true;
const c = false;

✅ Example of correct code

const a = void 0;
const b = !0;
const c = !1;

License

MIT