पाठ 9 / 25

Prettier Advanced विकल्प

Fine-grained control के लिए Prettier के पूर्ण configuration में महारत हासिल करें।

Prettier के विकल्प

Basics से परे: endOfLine (LF vs CRLF), arrowParens (when to add parens), bracketSpacing, और jsxBracketSameLine subtle formatting choices को control करते हैं।

पूर्ण Prettier config

सभी commonly-used विकल्पों के साथ एक comprehensive Prettier config।

{
  "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

Line endings को platforms में consistent रखने के लिए endOfLine को 'lf' पर सेट करें (Windows/Linux/Mac)। Line-ending के अंतर से Git conflicts को रोकता है।

त्वरित जाँच

त्वरित जाँच: 'endOfLine' option क्या करता है?

  • Cross-platform consistency के लिए line ending style (LF vs CRLF) को control करता है।
  • Line length को सेट करता है।
  • Quote style को determine करता है।
Answer

Cross-platform consistency के लिए line ending style (LF vs CRLF) को control करता है। — 'endOfLine' Git में line-ending conflicts को रोकता है। 'lf' अधिकांश परियोजनाओं के लिए standard है; 'crlf' Windows-only टीमों के लिए।