Prettier 选项参考
每一个 Prettier 格式化选项,附默认值、可选值和可复制的配置片段。
Common
bracketSameLineBracket Same Linewhere the closing angle bracket of a multi-line tag landsbracketSpacingBracket Spacingthe spaces inside object braces, and everywhere they followobjectWrapObject WrapPrettier's one deliberate escape hatch, and how to switch it offproseWrapProse Wraphow Markdown paragraphs are wrapped, and why the default leaves them alonesingleAttributePerLineSingle Attribute Per Lineone attribute per line, for markup diffs that read like code diffssingleQuoteSingle Quotea preference Prettier overrides whenever escaping would suffer
Global
embeddedLanguageFormattingEmbedded Language Formattingformatting the CSS, HTML and GraphQL hiding inside your template literalsendOfLineEnd Of Lineline endings, and the Windows diff problem this option was created to endprintWidthPrint Widththe width Prettier aims for, not a hard limittabWidthTab Widthhow wide one indentation level is, in columnsuseTabsUse Tabstabs for indentation, and why accessibility is the strongest argument
HTML
JavaScript
arrowParensArrow Parensparentheses around a lone arrow parameter, and the edit cost of leaving them offexperimentalOperatorPositionExperimental Operator Positionwhether a wrapped operator trails the line above or leads the line belowexperimentalTernariesExperimental Ternariesan opt-in answer to Prettier's longest-running formatting argumentjsxSingleQuoteJsx Single Quotequote style for JSX attributes, kept separate from your JavaScript stringsquotePropsQuote Propswhen object keys get quoted, and the consistency option most people wantsemiSemisemicolons, and the ASI hazards behind the defaulttrailingCommaTrailing Commathe option that exists to make diffs smaller
Special
checkIgnorePragmaCheck Ignore Pragmalets a file opt itself out of formatting entirelycursorOffsetCursor Offsetthe option that stops format-on-save losing your placeinsertPragmaInsert Pragmastamps a @format marker on every file Prettier formatsrangeEndRange Endthe exclusive end of a partial formatrangeStartRange Startthe start of a partial format, and how Format Selection actually worksrequirePragmaRequire Pragmathe option that lets a huge codebase adopt Prettier one file at a time
生成自 Prettier 3.9.6。