Lesson 9 / 25
Prettier Advanced Options
Master Prettier's full configuration for fine-grained control.
Prettier's options
Beyond basics: endOfLine (LF vs CRLF), arrowParens (when to add parens), bracketSpacing, and jsxBracketSameLine control subtle formatting choices.
Full Prettier config
A comprehensive Prettier config with all commonly-used options.
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf"
}
Output:
Comprehensive Prettier config ready
Line ending strategy
Set endOfLine to 'lf' to keep line endings consistent across platforms (Windows/Linux/Mac). Prevents Git conflicts from line-ending differences.
Quick check
Quick check: What does the 'endOfLine' option do?
- Controls line ending style (LF vs CRLF) for cross-platform consistency.
- Sets the line length.
- Determines quote style.
Answer
Controls line ending style (LF vs CRLF) for cross-platform consistency. — 'endOfLine' prevents line-ending conflicts in Git. 'lf' is standard for most projects; 'crlf' for Windows-only teams.