@marshal93/prettier-config
v1.0.2
Published
prettier-config
Readme
@marshal93/prettier-config
与 @marshal93/eslint-config 配置保持一致的 prettier 配置。
INSTALL
npm i -D prettier @marshal93/prettier-configUsage
.prettierrc.js
在你的项目根目录下新建 .prettierrc.js,内容如下:
module.exports = {
...require('@marshal93/prettier-config')
};或者直接在 package.json 中配置:
{
"prettier": "@marshal93/prettier-config"
}npm script
在 package.json 里的 "scripts" 里添加 format 命令:
{
"scripts": {
"format": "prettier src/ --write"
}
}使用 lerna 做包管理的应用,还可以加上:
{
"scripts": {
"format:packages": "prettier packages/**/src/ --write"
}
}在项目根目录下执行 yarn format 或 npm run format 格式化代码。
配置说明
| 配置项 | 值 | 说明 | |--------|-----|------| | printWidth | 100 | 每行最大长度 | | tabWidth | 2 | 缩进宽度 | | useTabs | false | 使用空格缩进 | | semi | true | 语句末尾分号 | | singleQuote | true | 使用单引号 | | quoteProps | as-needed | 对象属性引号规则 | | trailingComma | all | 尾随逗号 | | bracketSpacing | true | 对象花括号内空格 | | bracketSameLine | false | JSX 标签括号不放在同一行 | | arrowParens | avoid | 箭头函数单参数不加括号 |
