Update rationale (#5136)

* Clarify semicolon example

* Add rationale for print width

Fixes #5081.

* Link options and rationale

* Add rationale for comments

Refs. #5121.

* Mention that spaces can be used for alignment for --use-tabs

Refs. #4199.

* Add missing word

* Remove bad `istanbul ignore next` example
This commit is contained in:
Simon Lydell authored and GitHub committed 2018-09-29 09:41:21 +02:00
1 parent 265d9337f6
commit a459743eb2
2 files changed
+76 -6

No files matched your search

+8 -2
View File
@@ -14,6 +14,8 @@ Specify the line length that the printer will wrap on.
> In code styleguides, maximum line length rules are often set to 100 or 120. However, when humans write code, they don't strive to reach the maximum number of columns on every line. Developers often use whitespace to break up long lines for readability. In practice, the average line length often ends up well below the maximum.
>
> Prettier, on the other hand, strives to fit the most code into every line. With the print width set to 120, prettier may produce overly compact, or otherwise undesirable code.
>
> See the [print width rationale](rationale.md#print-width) for more information.
| Default | CLI Override | API Override |
| ------- | --------------------- | ------------------- |
@@ -31,12 +33,14 @@ Specify the number of spaces per indentation-level.
## Tabs
Indent lines with tabs instead of spaces
Indent lines with tabs instead of spaces.
| Default | CLI Override | API Override |
| ------- | ------------ | ----------------- |
| `false` | `--use-tabs` | `useTabs: <bool>` |
(Tabs will be used for _indentation_ but Prettier uses spaces to _align_ things, such as in ternaries.)
## Semicolons
Print semicolons at the ends of statements.
@@ -44,7 +48,7 @@ Print semicolons at the ends of statements.
Valid options:
- `true` - Add a semicolon at the end of every statement.
- `false` - Only add semicolons at the beginning of lines that may introduce ASI failures.
- `false` - Only add semicolons at the beginning of lines that [may introduce ASI failures](rationale.md#semicolons).
| Default | CLI Override | API Override |
| ------- | ------------ | -------------- |
@@ -59,6 +63,8 @@ Notes:
- Quotes in JSX will always be double and ignore this setting.
- If the number of quotes outweighs the other quote, the quote which is less used will be used to format the string - Example: `"I'm double quoted"` results in `"I'm double quoted"` and `"This \"example\" is single quoted"` results in `'This "example" is single quoted'`.
See the [strings rationale](#rationale.md#strings) for more information.
| Default | CLI Override | API Override |
| ------- | ---------------- | --------------------- |
| `false` | `--single-quote` | `singleQuote: <bool>` |