Skip to content

Instantly share code, notes, and snippets.

@WLyKan
Forked from AutMaple/prettierrc.js
Created July 18, 2025 05:22
Show Gist options
  • Save WLyKan/f5ad8cb36ee3163be992c02b9e6b3d7d to your computer and use it in GitHub Desktop.
Save WLyKan/f5ad8cb36ee3163be992c02b9e6b3d7d to your computer and use it in GitHub Desktop.
[prettier] prettier 配置文件 #prettier
module.exports = {
// 指定每行代码的最大长度(默认值:80)
printWidth: 80,
// 指定每个缩进级别的空格数(默认值:2)
tabWidth: 2,
// 使用制表符而不是空格进行缩进(默认值:false)
useTabs: false,
// 在语句末尾添加分号(默认值:true)
semi: true,
// 使用单引号而不是双引号(默认值:false)
singleQuote: false,
// 在对象或数组的末尾是否使用逗号(默认值:none)
trailingComma: 'none',
// 大括号内的首尾需要空格(默认值:true)
bracketSpacing: true,
// 将 JSX 标签的闭合符号放在最后一行的末尾,而不是另起一行(默认值:false)
jsxBracketSameLine: false,
// 箭头函数的参数是否带圆括号(默认值:avoid)
arrowParens: 'avoid',
// 指定 HTML 文件的全局空白区域敏感度(默认值:css)
htmlWhitespaceSensitivity: 'css',
// 指定要使用的解析器(默认值:none)
parser: null,
// 指定要使用的解析器插件列表(默认值:[])
plugins: [],
// 指定换行符样式(默认值:'auto')
endOfLine: 'auto',
// 在文件顶部插入一个特殊的 @format 标记,指定文件使用 Prettier 进行格式化(默认值:false)
insertPragma: false,
// 在文件开头插入一个 BOM(字节顺序标记)(默认值:false)
byteOrderMark: false,
// 不要在文件开头插入或删除文件的任何注释(默认值:false)
disableLanguages: [],
// 指定需要忽略的文件路径模式(默认值:[])
ignorePath: '.prettierignore',
// 指定要使用的解析器(默认值:'babylon')
parser: 'babel',
// 指定要使用的解析器工作目录的路径(默认值:'prettier')
};
@WLyKan
Copy link
Author

WLyKan commented Jul 18, 2025

{
  "printWidth": 100,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "jsxSingleQuote": true,
  "trailingComma": "all",
  "bracketSpacing": true,
  "jsxBracketSameLine": false,
  "arrowParens": "always",
  "endOfLine": "lf",
  "proseWrap": "preserve",
  "overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }],
  "plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment