Prettier 配置生成器与演练场

正在加载 Prettier latest…

Prettier 选项参考

下列每个选项都可在上方的生成器中使用。所示默认值来自 Prettier 3.9.6。

bracketSameLineBracket Same Line

where the closing angle bracket of a multi-line tag lands

默认值
false
CLI 参数
--bracket-same-line

bracketSpacingBracket Spacing

the spaces inside object braces, and everywhere they follow

默认值
true
CLI 参数
--no-bracket-spacing

objectWrapObject Wrap

Prettier's one deliberate escape hatch, and how to switch it off

默认值
"preserve"
CLI 参数
--object-wrap
可选值
preservecollapse

proseWrapProse Wrap

how Markdown paragraphs are wrapped, and why the default leaves them alone

默认值
"preserve"
CLI 参数
--prose-wrap
可选值
alwaysneverpreserve

singleAttributePerLineSingle Attribute Per Line

one attribute per line, for markup diffs that read like code diffs

默认值
false
CLI 参数
--single-attribute-per-line

singleQuoteSingle Quote

a preference Prettier overrides whenever escaping would suffer

默认值
false
CLI 参数
--single-quote

embeddedLanguageFormattingEmbedded Language Formatting

formatting the CSS, HTML and GraphQL hiding inside your template literals

默认值
"auto"
CLI 参数
--embedded-language-formatting
可选值
autooff

endOfLineEnd Of Line

line endings, and the Windows diff problem this option was created to end

默认值
"lf"
CLI 参数
--end-of-line
可选值
lfcrlfcrauto

printWidthPrint Width

the width Prettier aims for, not a hard limit

默认值
80
CLI 参数
--print-width

tabWidthTab Width

how wide one indentation level is, in columns

默认值
2
CLI 参数
--tab-width

useTabsUse Tabs

tabs for indentation, and why accessibility is the strongest argument

默认值
false
CLI 参数
--use-tabs

htmlWhitespaceSensitivityHtml Whitespace Sensitivity

the option that stops Prettier changing how your page renders

默认值
"css"
CLI 参数
--html-whitespace-sensitivity
可选值
cssstrictignore

vueIndentScriptAndStyleVue Indent Script And Style

whether a Vue SFC indents inside its script and style blocks

默认值
false
CLI 参数
--vue-indent-script-and-style

arrowParensArrow Parens

parentheses around a lone arrow parameter, and the edit cost of leaving them off

默认值
"always"
CLI 参数
--arrow-parens
可选值
alwaysavoid

experimentalOperatorPositionExperimental Operator Position

whether a wrapped operator trails the line above or leads the line below

默认值
"end"
CLI 参数
--experimental-operator-position
可选值
startend

experimentalTernariesExperimental Ternaries

an opt-in answer to Prettier's longest-running formatting argument

默认值
false
CLI 参数
--experimental-ternaries

jsxSingleQuoteJsx Single Quote

quote style for JSX attributes, kept separate from your JavaScript strings

默认值
false
CLI 参数
--jsx-single-quote

quotePropsQuote Props

when object keys get quoted, and the consistency option most people want

默认值
"as-needed"
CLI 参数
--quote-props
可选值
as-neededconsistentpreserve

semiSemi

semicolons, and the ASI hazards behind the default

默认值
true
CLI 参数
--no-semi

trailingCommaTrailing Comma

the option that exists to make diffs smaller

默认值
"all"
CLI 参数
--trailing-comma
可选值
alles5none

checkIgnorePragmaCheck Ignore Pragma

lets a file opt itself out of formatting entirely

默认值
false
CLI 参数
--check-ignore-pragma

cursorOffsetCursor Offset

the option that stops format-on-save losing your place

默认值
-1
CLI 参数
--cursor-offset

insertPragmaInsert Pragma

stamps a @format marker on every file Prettier formats

默认值
false
CLI 参数
--insert-pragma

rangeEndRange End

the exclusive end of a partial format

默认值
CLI 参数
--range-end

rangeStartRange Start

the start of a partial format, and how Format Selection actually works

默认值
0
CLI 参数
--range-start

requirePragmaRequire Pragma

the option that lets a huge codebase adopt Prettier one file at a time

默认值
false
CLI 参数
--require-pragma