vscode格式化配置 | .prettierrc配置文件


 鏈接:

vscode常用插件及用戶配置

.prettierrc推薦配置

module.exports = {
    trailingComma: 'none',
    tabWidth: 2,
    semi: true,
    singleQuote: true,
    printWidth: 120,
    arrowParens: 'avoid'
};

 

.prettierrc常用配置

{
    // tab縮進大小,默認為2
    "tabWidth": 4,
    // 使用tab縮進,默認false
    "useTabs": false,
    // 使用分號, 默認true
    "semi": false,
    // 使用單引號, 默認false(在jsx中配置無效, 默認都是雙引號)
    "singleQuote": false,
    // 行尾逗號,默認none,可選 none|es5|all
    // es5 包括es5中的數組、對象
    // all 包括函數對象等所有可選
    "TrailingCooma": "all",
    // 對象中的空格 默認true
    // true: { foo: bar }
    // false: {foo: bar}
    "bracketSpacing": true,
    // JSX標簽閉合位置 默認false
    // false: <div
    //          className=""
    //          style={{}}
    //       >
    // true: <div
    //          className=""
    //          style={{}} >
    "jsxBracketSameLine": false,
    // 箭頭函數參數括號 默認avoid 可選 avoid| always
    // avoid 能省略括號的時候就省略 例如x => x
    // always 總是有括號
    "arrowParens": "avoid"
}

官網.prettierrc 文檔

https://prettier.io/docs/en/configuration.html

api說明

https://prettier.io/docs/en/options.html

api option 中文版

https://juejin.im/post/5a7d70496fb9a063317c47f1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM