Prettier:フォーマットオプションのデフォルト設定を確認する方法

スポンサーリンク

フォーマットオプションのデフォルト設定を確認する方法

フォーマットオプションのデフォルト設定は下記ページで確認できます。

Options · Prettier
Prettier ships with a handful of format options.

バージョン2.5.1時点では下記オプションがあります(カッコ内がデフォルトの値)。

  • Print Width(80)
  • Tab Width(2)
  • Tabs(false)
  • Semicolons(true)
  • Quotes(false)
  • Quote Props("as-needed")
  • JSX Quotes(false)
  • Trailing Commas("es5")
  • Bracket Spacing(true)
  • Bracket Line(false)
  • [Deprecated] JSX Brackets(false)
  • Arrow Function Parentheses("always")
  • Range(0 - Inifinity)
  • Parser(None)
  • File Path(None)
  • Require Pragma(false)
  • Insert Pragma(false)
  • Prose Wrap("preserve")
  • HTML Whitespace Sensitivity("css")
  • Vue files script and style tags indentation(false)
  • End of Line("lf")
  • Embedded Language Formatting("auto")

 

また、--helpオプションで表示されるFormat optionsで確認することができます。

$ npx prettier --help
 (省略)
Format options:

  --arrow-parens <always|avoid>
                           Include parentheses around a sole arrow function parameter.
                           Defaults to always.
  --bracket-same-line      Put > of opening tags on the last line instead of on a new line.
                           Defaults to false.
  --no-bracket-spacing     Do not print spaces between brackets.
  --embedded-language-formatting <auto|off>
                           Control how Prettier formats quoted code embedded in the file.
                           Defaults to auto.
  --end-of-line <lf|crlf|cr|auto>
                           Which end of line characters to apply.
                           Defaults to lf.
  --html-whitespace-sensitivity <css|strict|ignore>
                           How to handle whitespaces in HTML.
                           Defaults to css.
  --jsx-single-quote       Use single quotes in JSX.
                           Defaults to false.
  --parser <flow|babel|babel-flow|babel-ts|typescript|espree|meriyah|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|glimmer|html|angular|lwc>
                           Which parser to use.
  --print-width       The line length where Prettier will try wrap.
                           Defaults to 80.
  --prose-wrap <always|never|preserve>
                           How to wrap prose.
                           Defaults to preserve.
  --quote-props <as-needed|consistent|preserve>
                           Change when properties in objects are quoted.
                           Defaults to as-needed.
  --no-semi                Do not print semicolons, except at the beginning of lines which may need them.
  --single-quote           Use single quotes instead of double quotes.
                           Defaults to false.
  --tab-width         Number of spaces per indentation level.
                           Defaults to 2.
  --trailing-comma <es5|none|all>
                           Print trailing commas wherever possible when multi-line.
                           Defaults to es5.
  --use-tabs               Indent with tabs instead of spaces.
                           Defaults to false.
  --vue-indent-script-and-style
                           Indent script and style tags in Vue files.
                           Defaults to false.
 (省略)