前端开发用的比较多的语法格式化无非 ESLint 和 Prettier,但是 Prettier 在 vue 中适配只能说一般吧,就比如 vue 中的>括号一直有 bug,记录下修复

Prettier 修复尖括号换行

添加这个属性就行

{
  "htmlWhitespaceSensitivity": "ignore"
}

例子

module.exports = {
  bracketSpacing: true,
  singleQuote: true,
  jsxSingleQuote: true,
  tabWidth: 2,
  semi: true,
  // 标签闭合位置 默认false
  bracketSameLine: true,
  jsxBracketSameLine: true,
  //指定换行长度
  printWidth: 120,
  // avoid 能省略括号的时候就省略 例如x => x
  arrowParens: 'avoid',
  vueIndentScriptAndStyle: true,
  trailingComma: 'all',
  proseWrap: 'never',
  htmlWhitespaceSensitivity: 'ignore',
  endOfLine: 'auto',
}