6.1.0 β€’ Published 1 year ago

@putout/plugin-apply-shorthand-properties v6.1.0

Weekly downloads
2,385
License
MIT
Repository
github
Last release
1 year ago

@putout/plugin-apply-shorthand-properties NPM version

🐊Putout plugin adds ability to apply shorthand properties.

Install

npm i @putout/plugin-apply-shorthand-properties -D

Config

{
    "rules": {
        "apply-shorthand-properties": ["on", {
            "ignore": [],
            "rename": false
        }]
    },
    "plugins": [
        "apply-shorthand-properties"
    ]
}

With default options

❌ Example of incorrect code

import {'b' as b} from 'b';

const {a: a} = b;

βœ… Example of correct code

import {b} from 'b';

const {a} = b;

When rename enabled

❌ Example of incorrect code

const AUTH_SESSION = 'xx';

export const setSession = (session) => ({
    type: AUTH_SESSION,
    payload: session,
});

βœ… Example of correct code

const type = 'xx';

export const setSession = (payload) => ({
    type,
    payload,
});

Comparison

LinterRuleFix
🐊 Putoutapply-shorthand-propertiesβœ…
⏣ ESLintno-useless-rename❌

License

MIT