简体   繁体   中英

Prettier VS Code - how a JS object is formatted

I got this object:

const map = {
        '&amp;': '&', '&#038;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&#039;': "'", '&#8217;': '’',
        '&#8216;': '‘', '&#8211;': '–', '&#8212;': '—', '&#8230;': '…', '&#8221;': '”'
    };

And prettier automatically formats it to:

const map = {
    '&amp;': '&',
    '&#038;': '&',
    '&lt;': '<',
    '&gt;': '>',
    '&quot;': '"',
    '&#039;': "'",
    '&#8217;': '’',
    '&#8216;': '‘',
    '&#8211;': '–',
    '&#8212;': '—',
    '&#8230;': '…',
    '&#8221;': '”'
};

How can I configure it to stay as the original?

The first code is a minified code. You should try to install the minify plugin for VSCode ad add a keyboard shortcut to minify your code as the first one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM