Skip to content

Commit 4a8bccc

Browse files
committed
docs: add delimiterSpacing toggle and global option docs
1 parent c238a4c commit 4a8bccc

6 files changed

Lines changed: 62 additions & 1 deletion

File tree

src/content/docs/formatter/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ The following defaults are applied:
6767
"arrowParentheses":"always",
6868
"bracketSameLine": false,
6969
"bracketSpacing": true,
70+
"delimiterSpacing": false,
7071
"jsxQuoteStyle": "double",
7172
"quoteProperties": "asNeeded",
7273
"semicolons": "always",

src/content/docs/reference/configuration.mdx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,14 @@ Choose whether spaces should be added between brackets and inner values.
635635

636636
> Default: `true`
637637
638+
### `formatter.delimiterSpacing`
639+
640+
Whether to insert spaces inside delimiters. Affects parentheses `()`, square brackets `[]`, TypeScript angle brackets `<>`, and JSX curly braces `{}`.
641+
642+
This option is available for JavaScript, JSON, and CSS. It is not available for GraphQL.
643+
644+
> Default: `false`
645+
638646
### `formatter.expand`
639647

640648
Whether to expand arrays and objects on multiple lines.
@@ -845,6 +853,14 @@ Choose whether spaces should be added between brackets and inner values.
845853

846854
> Default: `true`
847855
856+
### `javascript.formatter.delimiterSpacing`
857+
858+
Whether to insert spaces inside delimiters. Affects parentheses `()`, square brackets `[]`, TypeScript angle brackets `<>`, and JSX curly braces `{}`.
859+
860+
This option is available for JavaScript, JSON, and CSS. It is not available for GraphQL.
861+
862+
> Default: `false`
863+
848864
### `javascript.formatter.attributePosition`
849865

850866
The attribute position style in jsx elements.
@@ -1086,6 +1102,12 @@ Choose whether spaces should be added between brackets and inner values.
10861102

10871103
> Default: `true`
10881104
1105+
### `json.formatter.delimiterSpacing`
1106+
1107+
Whether to insert spaces inside square brackets `[]`.
1108+
1109+
> Default: `false`
1110+
10891111
### `json.formatter.expand`
10901112

10911113
Whether to expand arrays and objects on multiple lines.
@@ -1228,6 +1250,12 @@ The type of quote used when representing string literals. It can be `"single"` o
12281250

12291251
> Default: `"double"`
12301252
1253+
### `css.formatter.delimiterSpacing`
1254+
1255+
Whether to insert spaces inside delimiters. Affects parentheses `()` and square brackets `[]`.
1256+
1257+
> Default: `false`
1258+
12311259
### `css.formatter.trailingNewline`
12321260

12331261
Whether to add a trailing newline at the end of the file.
@@ -1243,7 +1271,6 @@ Setting this option to `false` is **highly discouraged** because it could cause
12431271
Disable trailing newline at your own risk.
12441272
:::
12451273

1246-
12471274
### `css.linter.enabled`
12481275

12491276
Enables Biome's linter for CSS files.

src/playground/PlaygroundLoader.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ function initState(
432432
bracketSpacing:
433433
searchParams.get("bracketSpacing") === "true" ||
434434
defaultPlaygroundState.settings.bracketSpacing,
435+
delimiterSpacing:
436+
searchParams.get("delimiterSpacing") === "true" ||
437+
defaultPlaygroundState.settings.delimiterSpacing,
435438
bracketSameLine:
436439
searchParams.get("bracketSameLine") === "true" ||
437440
defaultPlaygroundState.settings.bracketSameLine,

src/playground/tabs/SettingsTab.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default function SettingsTab({
5858
semicolons,
5959
arrowParentheses,
6060
bracketSpacing,
61+
delimiterSpacing,
6162
bracketSameLine,
6263
expand,
6364
indentScriptAndStyle,
@@ -121,6 +122,10 @@ export default function SettingsTab({
121122
setPlaygroundState,
122123
"bracketSpacing",
123124
);
125+
const setDelimiterSpacing = createPlaygroundSettingsSetter(
126+
setPlaygroundState,
127+
"delimiterSpacing",
128+
);
124129
const setBracketSameLine = createPlaygroundSettingsSetter(
125130
setPlaygroundState,
126131
"bracketSameLine",
@@ -350,6 +355,8 @@ export default function SettingsTab({
350355
setAttributePosition={setAttributePosition}
351356
bracketSpacing={bracketSpacing}
352357
setBracketSpacing={setBracketSpacing}
358+
delimiterSpacing={delimiterSpacing}
359+
setDelimiterSpacing={setDelimiterSpacing}
353360
bracketSameLine={bracketSameLine}
354361
setBracketSameLine={setBracketSameLine}
355362
expand={expand}
@@ -772,6 +779,8 @@ function FormatterSettings({
772779
setAttributePosition,
773780
bracketSpacing,
774781
setBracketSpacing,
782+
delimiterSpacing,
783+
setDelimiterSpacing,
775784
bracketSameLine,
776785
setBracketSameLine,
777786
expand,
@@ -803,6 +812,8 @@ function FormatterSettings({
803812
setAttributePosition: (value: AttributePosition) => void;
804813
bracketSpacing: boolean;
805814
setBracketSpacing: (value: boolean) => void;
815+
delimiterSpacing: boolean;
816+
setDelimiterSpacing: (value: boolean) => void;
806817
bracketSameLine: boolean;
807818
setBracketSameLine: (value: boolean) => void;
808819
expand: Expand;
@@ -822,6 +833,7 @@ function FormatterSettings({
822833
const arrowParenthesesId = useId();
823834
const attributePositionId = useId();
824835
const bracketSpacingId = useId();
836+
const delimiterSpacingId = useId();
825837
const bracketSameLineId = useId();
826838
const expandId = useId();
827839
const indentScriptAndStyleId = useId();
@@ -966,6 +978,16 @@ function FormatterSettings({
966978
onChange={(e) => setBracketSpacing(e.target.checked)}
967979
/>
968980
</div>
981+
<div className="field-row">
982+
<label htmlFor={delimiterSpacingId}>Delimiter Spacing</label>
983+
<input
984+
id={delimiterSpacingId}
985+
name="delimiterSpacing"
986+
type="checkbox"
987+
checked={delimiterSpacing}
988+
onChange={(e) => setDelimiterSpacing(e.target.checked)}
989+
/>
990+
</div>
969991
<div className="field-row">
970992
<label htmlFor={bracketSameLineId}>Bracket Same Line</label>
971993
<input

src/playground/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export interface PlaygroundSettings {
178178
arrowParentheses: ArrowParentheses;
179179
attributePosition: AttributePosition;
180180
bracketSpacing: boolean;
181+
delimiterSpacing: boolean;
181182
bracketSameLine: boolean;
182183
expand: Expand;
183184
lintRules: LintRule;
@@ -234,6 +235,7 @@ export const defaultPlaygroundState: PlaygroundState = {
234235
arrowParentheses: ArrowParentheses.Always,
235236
attributePosition: AttributePosition.Auto,
236237
bracketSpacing: true,
238+
delimiterSpacing: false,
237239
bracketSameLine: false,
238240
expand: Expand.Auto,
239241
lintRules: LINT_RULES.recommended,

src/playground/workers/biomeWorker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ self.addEventListener("message", async (e) => {
126126
semicolons,
127127
arrowParentheses,
128128
bracketSpacing,
129+
delimiterSpacing,
129130
bracketSameLine,
130131
expand,
131132
indentScriptAndStyle,
@@ -186,6 +187,7 @@ self.addEventListener("message", async (e) => {
186187
? "always"
187188
: "asNeeded",
188189
bracketSpacing,
190+
delimiterSpacing,
189191
bracketSameLine,
190192
attributePosition:
191193
attributePosition === AttributePosition.Auto
@@ -200,6 +202,7 @@ self.addEventListener("message", async (e) => {
200202
css: {
201203
formatter: {
202204
quoteStyle: quoteStyle === QuoteStyle.Double ? "double" : "single",
205+
delimiterSpacing,
203206
},
204207
parser: {
205208
allowWrongLineComments: true,
@@ -208,6 +211,9 @@ self.addEventListener("message", async (e) => {
208211
},
209212
},
210213
json: {
214+
formatter: {
215+
delimiterSpacing,
216+
},
211217
parser: {
212218
allowComments,
213219
},

0 commit comments

Comments
 (0)