.prettierrc.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. module.exports = {
  2. // 一行最多 120 字符
  3. printWidth: 120,
  4. // 使用 4 个空格缩进
  5. tabWidth: 4,
  6. // 不使用缩进符,而使用空格
  7. useTabs: false,
  8. // 行尾需要有分号
  9. semi: true,
  10. // 使用单引号
  11. singleQuote: true,
  12. // 末尾不需要逗号
  13. trailingComma: 'none',
  14. // 大括号内的首尾需要空格
  15. bracketSpacing: true,
  16. // jsx 标签的反尖括号需要换行
  17. bracketSameLine: true,
  18. // 箭头函数,只有一个参数的时候,也需要括号
  19. arrowParens: 'always',
  20. // 每个文件格式化的范围是文件的全部内容
  21. rangeStart: 0,
  22. rangeEnd: Infinity,
  23. // 不需要写文件开头的 @prettier
  24. requirePragma: false,
  25. // 不需要自动在文件开头插入 @prettier
  26. insertPragma: false,
  27. // 使用默认的折行标准
  28. proseWrap: 'preserve',
  29. // 根据显示样式决定 html 要不要折行 ignore
  30. htmlWhitespaceSensitivity: 'strict',
  31. // 换行符使用 lf
  32. endOfLine: 'lf',
  33. parser: 'typescript',
  34. overrides: [
  35. {
  36. files: ['*.json'],
  37. options: {
  38. parser: 'json',
  39. tabWidth: 2
  40. }
  41. },
  42. {
  43. files: '*.{css,sass,scss,less}',
  44. options: {
  45. parser: 'css',
  46. tabWidth: 4
  47. }
  48. },
  49. {
  50. files: '*.{ts,tsx}',
  51. options: {
  52. parser: 'typescript'
  53. }
  54. }
  55. ]
  56. };