.prettierrc.mjs 1.2 KB

12345678910111213141516171819202122232425
  1. export default {
  2. printWidth: 100, // 每行最大字符数
  3. tabWidth: 2, // 制表符对应的空格数
  4. semi: false, // 禁止自动添加分号
  5. vueIndentScriptAndStyle: true, // 确保Vue文件中script和style标签的缩进正确
  6. plugins: ['prettier-plugin-tailwindcss'],
  7. // 引号与括号配置
  8. singleQuote: true, // 使用单引号包裹字符串
  9. quoteProps: 'as-needed', // 仅在必要时为对象属性添加引号
  10. bracketSpacing: true, // 对象字面量括号内添加空格
  11. trailingComma: 'es5', // 在ES5允许的位置添加末尾逗号
  12. // JSX与箭头函数配置
  13. jsxBracketSameLine: false, // JSX闭合标签不与前一行同列
  14. jsxSingleQuote: false, // JSX属性使用双引号
  15. arrowParens: 'always', // 箭头函数参数必须用括号包裹
  16. // 其他配置
  17. insertPragma: false, // 不自动插入Prettier pragma指令
  18. requirePragma: false, // 不要求文件包含Prettier pragma指令
  19. proseWrap: 'never', // 不自动换行处理多行文本
  20. htmlWhitespaceSensitivity: 'ignore', // 忽略HTML空白字符敏感规则
  21. endOfLine: 'lf', // 文件结尾使用LF换行符
  22. rangeStart: 0, // 格式化范围起始位置(默认从0开始)
  23. }