Skip to content

Commit 0f7b945

Browse files
committed
docs(prettier-plugin-toml): document the default-free parser options
1 parent 33e2f02 commit 0f7b945

1 file changed

Lines changed: 34 additions & 26 deletions

File tree

‎packages/toml/README.md‎

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ so both produce the same output — with no configuration at all, Prettier
8080
defaults to `80` while tombi has no line width limit.
8181

8282
The plugin's own options have no defaults: when they are not set, the
83-
discovered configuration (or Tombi's default) decides. `toml-version` follows
84-
the same rule because it decides how the source is parsed.
83+
discovered configuration (or Tombi's default) decides, except
84+
`stringQuoteStyle` and `inlineTableBraceSpaceWidth`, which derive from
85+
Prettier's `singleQuote`/`bracketSpacing`. `toml-version` follows the same rule
86+
because it decides how the source is parsed.
8587

8688
### Notes
8789

@@ -101,46 +103,52 @@ counterparts where they exist:
101103
- `singleQuote` → `string-quote-style`
102104
- `bracketSpacing` → `inline-table-brace-space-width`
103105

104-
`endOfLine` is handled by [prettier][] itself. All of tombi's other format rules
105-
are exposed as `toml` options and can be used to override the inherited values:
106+
`endOfLine` is handled by [prettier][] itself. All of tombi's other format
107+
rules are exposed as `toml` options. They have no defaults: setting one
108+
overrides the discovered configuration, while leaving it unset lets
109+
`tombi.toml` (or Tombi's own default) decide — except `stringQuoteStyle` and
110+
`inlineTableBraceSpaceWidth`, which derive from the core options above.
106111

107112
```ts
108113
interface PrettierOptions {
109-
// The TOML version to use when parsing and formatting.
110-
tomlVersion: 'v1.0.0' | 'v1.1.0-preview' | 'v1.1.0' // default `v1.0.0`
114+
// The TOML version to use when parsing and formatting; follows the
115+
// discovered configuration when unset.
116+
tomlVersion?: 'v1.0.0' | 'v1.1.0-preview' | 'v1.1.0'
111117
// The number of spaces inside the brackets of a single line array.
112-
arrayBracketSpaceWidth: number // default `0`
118+
arrayBracketSpaceWidth?: number
113119
// The number of spaces after the comma in a single line array.
114-
arrayCommaSpaceWidth: number // default `1`
120+
arrayCommaSpaceWidth?: number
115121
// The style used to format comments.
116-
commentStyle: 'normalize' | 'preserve' // default `normalize`
122+
commentStyle?: 'normalize' | 'preserve'
117123
// The delimiter between date and time.
118-
dateTimeDelimiter: 'preserve' | 'space' | 'T' // default `T`
124+
dateTimeDelimiter?: 'preserve' | 'space' | 'T'
119125
// The blank lines limit between groups.
120-
groupBlankLinesLimit: number // default `1`
126+
groupBlankLinesLimit?: number
121127
// Whether to indent sub-tables.
122-
indentSubTables: boolean // default `false`
128+
indentSubTables?: boolean
123129
// Whether to indent table key-value pairs.
124-
indentTableKeyValuePairs: boolean // default `false`
125-
// The number of spaces inside the braces of a single line inline table,
126-
// defaults to `bracketSpacing` (`1` or `0`).
127-
inlineTableBraceSpaceWidth: number // default `bracketSpacing`
130+
indentTableKeyValuePairs?: boolean
131+
// The number of spaces inside the braces of a single line inline table;
132+
// derives from `bracketSpacing` (`1` or `0`) when unset.
133+
inlineTableBraceSpaceWidth?: number
128134
// The number of spaces after the comma in a single line inline table.
129-
inlineTableCommaSpaceWidth: number // default `1`
135+
inlineTableCommaSpaceWidth?: number
130136
// Whether to align the equals sign in key-value pairs.
131-
keyValueEqualsSignAlignment: boolean // default `false`
132-
// The preferred quote character for keys, defaults to `stringQuoteStyle`.
133-
keyQuoteStyle: 'double' | 'preserve' | 'single' // default `undefined`
134-
// The preferred quote character for strings, defaults to `singleQuote`.
135-
stringQuoteStyle: 'double' | 'preserve' | 'single' // default `singleQuote`
137+
keyValueEqualsSignAlignment?: boolean
138+
// The preferred quote character for keys; follows `stringQuoteStyle` when
139+
// unset.
140+
keyQuoteStyle?: 'double' | 'preserve' | 'single'
141+
// The preferred quote character for strings; derives from `singleQuote`
142+
// when unset.
143+
stringQuoteStyle?: 'double' | 'preserve' | 'single'
136144
// Whether to align the trailing comments in key-value pairs.
137-
trailingCommentAlignment: boolean // default `false`
145+
trailingCommentAlignment?: boolean
138146
// The number of spaces around the equals sign in a key-value pair.
139-
keyValueEqualsSignSpaceWidth: number // default `1`
147+
keyValueEqualsSignSpaceWidth?: number
140148
// The number of blank lines between tables.
141-
tableBlankLines: number // default `1`
149+
tableBlankLines?: number
142150
// The number of spaces before a trailing comment.
143-
trailingCommentSpaceWidth: number // default `2`
151+
trailingCommentSpaceWidth?: number
144152
}
145153
```
146154

0 commit comments

Comments
 (0)