1.0.1 • Published 3 months ago

@softide/prettier-config v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

📦 @softide/prettier-config

这是一个共享的Prettier配置包,用于在项目中统一代码格式化规则。

📥 安装

你可以使用npm、yarn或pnpm等包管理器安装此包:

# npm
npm install --save-dev @softide/prettier-config

# yarn
yarn add -D @softide/prettier-config

# pnpm
pnpm add -D @softide/prettier-config

📖 使用方法

在你的项目中可以通过以下任一方式使用此配置:

  • 对于 .prettierrc.js.prettierrc.cjs 文件(推荐):
module.exports = "@softide/prettier-config";

// 或

module.exports = {
	...require("@softide/prettier-config"),
    // 你可以在这里自定义配置
};
  • 对于 .prettierrc.prettierrc.json.prettierrc.yaml 文件:
"@softide/prettier-config"
  • 对于 package.json 文件:
{
  "prettier": "@softide/prettier-config"
}

以上任何一种配置方式都是有效的,你可以选择最适合你项目的方式。更多相关信息请阅读 Prettier 共享配置

⚙️ 默认配置

以下为该配置包提供的配置项:

配置项说明
arrowParens"always"箭头函数参数始终使用括号
bracketSameLinefalse多行元素的闭合括号另起一行
bracketSpacingtrue对象字面量的括号之间添加空格
embeddedLanguageFormatting"auto"自动格式化嵌入的代码块
endOfLine"lf"使用 LF 作为换行符
htmlWhitespaceSensitivity"css"根据CSS display属性处理HTML空白
jsxSingleQuotefalseJSX中使用双引号
jsxBracketSameLinefalseJSX多行元素的闭合括号另起一行
printWidth150每行最大字符数
proseWrap"preserve"保持Markdown文本原有的换行
quoteProps"as-needed"仅在必要时为对象属性添加引号
semitrue语句末尾添加分号
singleAttributePerLinefalse不强制HTML/Vue/JSX的属性单行显示
singleQuotefalse使用双引号
tabWidth4缩进宽度为4个空格
trailingComma"es5"添加ES5兼容的尾随逗号
useTabstrue使用Tab进行缩进
vueIndentScriptAndStylefalse不缩进Vue文件中的script和style标签

更多相关信息请阅读 Prettier 配置文档

1.0.1

3 months ago

1.0.0

3 months ago