鏈接:
.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 中文版