1. 创建格式化器文件
cd vue-demo
touch .prettierrc.js
# .prettierrc.js内容
module.exports = {
useTabs: false,
tabWidth: 4,
printWidth: 80,
singleQuote: true,
trailingComma: 'none',
semi: false,
vueIndentScriptAndStyle: true,
bracketSpacing: true,
proseWrap: 'preserve',
jsxSingleQuote: false,
parser: 'babylon',
tslintIntegration: false
};
2. vscode配置
- Vscode安装插件
Prettier - Code formatter
- 配置vscode使用.prettierrc.js
- 设置—搜索
save
—勾选Editor:Format On Save - 项目文件右键选择
使用...格式化文档
—配置默认格式化器—Prettier - Code formatter
(default)
# .eslintrc.js rules里添加配置
"rules": {
"indent":0,
"space-before-function-paren":0
}
3. 参考文档
https://www.cnblogs.com/yaopengfei/p/15568730.html
- editorconfig、eslint、prettier的区别
https://blog.csdn.net/nnuan/article/details/116012721