.prettierrc.js 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. module.exports = {
  2. // 定制格式化要求
  3. overrides: [
  4. {
  5. files: '.prettierrc',
  6. options: {
  7. parser: 'json'
  8. }
  9. }
  10. ],
  11. printWidth: 100, // 一行最多 100 字符
  12. tabWidth: 2, // 使用 4 个空格缩进
  13. semi: true, // 行尾需要有分号
  14. singleQuote: true, // 使用单引号而不是双引号
  15. useTabs: true, // 用制表符而不是空格缩进行
  16. quoteProps: 'as-needed', // 仅在需要时在对象属性两边添加引号
  17. jsxSingleQuote: false, // 在 JSX 中使用单引号而不是双引号
  18. trailingComma: 'none', // 末尾不需要逗号
  19. bracketSpacing: true, // 大括号内的首尾需要空格
  20. bracketSameLine: false, // 将多行 HTML(HTML、JSX、Vue、Angular)元素反尖括号需要换行
  21. arrowParens: 'always', // 箭头函数,只有一个参数的时候,也需要括号 avoid
  22. rangeStart: 0, // 每个文件格fsingleQuote式化的范围是开头-结束
  23. rangeEnd: Infinity, // 每个文件格式化的范围是文件的全部内容
  24. requirePragma: false, // 不需要写文件开头的 @prettier
  25. insertPragma: false, // 不需要自动在文件开头插入 @prettier
  26. proseWrap: 'preserve', // 使用默认的折行标准 always
  27. htmlWhitespaceSensitivity: 'css', // 根据显示样式决定 html 要不要折行
  28. vueIndentScriptAndStyle: false, //(默认值)对于 .vue 文件,不缩进 <script> 和 <style> 里的内容
  29. endOfLine: 'lf', // 换行符使用 lf 在Linux和macOS以及git存储库内部通用\n
  30. embeddedLanguageFormatting: 'auto' //(默认值)允许自动格式化内嵌的代码块
  31. };