Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/content/docs/formatter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The following defaults are applied:
"arrowParentheses":"always",
"bracketSameLine": false,
"bracketSpacing": true,
"delimiterSpacing": false,
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"semicolons": "always",
Expand Down
29 changes: 28 additions & 1 deletion src/content/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ Choose whether spaces should be added between brackets and inner values.

> Default: `true`

### `formatter.delimiterSpacing`

Whether to insert spaces inside delimiters. Affects parentheses `()`, square brackets `[]`, TypeScript angle brackets `<>`, and JSX curly braces `{}`.

This option is available for JavaScript, JSON, and CSS. It is not available for GraphQL.

> Default: `false`

### `formatter.expand`

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

> Default: `true`

### `javascript.formatter.delimiterSpacing`

Whether to insert spaces inside delimiters. Affects parentheses `()`, square brackets `[]`, TypeScript angle brackets `<>`, and JSX curly braces `{}`.

This option is available for JavaScript, JSON, and CSS. It is not available for GraphQL.

> Default: `false`

### `javascript.formatter.attributePosition`

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

> Default: `true`

### `json.formatter.delimiterSpacing`

Whether to insert spaces inside square brackets `[]`.

> Default: `false`

### `json.formatter.expand`

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

> Default: `"double"`

### `css.formatter.delimiterSpacing`

Whether to insert spaces inside delimiters. Affects parentheses `()` and square brackets `[]`.

> Default: `false`

### `css.formatter.trailingNewline`

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


### `css.linter.enabled`

Enables Biome's linter for CSS files.
Expand Down
3 changes: 3 additions & 0 deletions src/playground/PlaygroundLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ function initState(
bracketSpacing:
searchParams.get("bracketSpacing") === "true" ||
defaultPlaygroundState.settings.bracketSpacing,
delimiterSpacing:
searchParams.get("delimiterSpacing") === "true" ||
defaultPlaygroundState.settings.delimiterSpacing,
bracketSameLine:
searchParams.get("bracketSameLine") === "true" ||
defaultPlaygroundState.settings.bracketSameLine,
Expand Down
22 changes: 22 additions & 0 deletions src/playground/tabs/SettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function SettingsTab({
semicolons,
arrowParentheses,
bracketSpacing,
delimiterSpacing,
bracketSameLine,
expand,
indentScriptAndStyle,
Expand Down Expand Up @@ -121,6 +122,10 @@ export default function SettingsTab({
setPlaygroundState,
"bracketSpacing",
);
const setDelimiterSpacing = createPlaygroundSettingsSetter(
setPlaygroundState,
"delimiterSpacing",
);
const setBracketSameLine = createPlaygroundSettingsSetter(
setPlaygroundState,
"bracketSameLine",
Expand Down Expand Up @@ -350,6 +355,8 @@ export default function SettingsTab({
setAttributePosition={setAttributePosition}
bracketSpacing={bracketSpacing}
setBracketSpacing={setBracketSpacing}
delimiterSpacing={delimiterSpacing}
setDelimiterSpacing={setDelimiterSpacing}
bracketSameLine={bracketSameLine}
setBracketSameLine={setBracketSameLine}
expand={expand}
Expand Down Expand Up @@ -772,6 +779,8 @@ function FormatterSettings({
setAttributePosition,
bracketSpacing,
setBracketSpacing,
delimiterSpacing,
setDelimiterSpacing,
bracketSameLine,
setBracketSameLine,
expand,
Expand Down Expand Up @@ -803,6 +812,8 @@ function FormatterSettings({
setAttributePosition: (value: AttributePosition) => void;
bracketSpacing: boolean;
setBracketSpacing: (value: boolean) => void;
delimiterSpacing: boolean;
setDelimiterSpacing: (value: boolean) => void;
bracketSameLine: boolean;
setBracketSameLine: (value: boolean) => void;
expand: Expand;
Expand All @@ -822,6 +833,7 @@ function FormatterSettings({
const arrowParenthesesId = useId();
const attributePositionId = useId();
const bracketSpacingId = useId();
const delimiterSpacingId = useId();
const bracketSameLineId = useId();
const expandId = useId();
const indentScriptAndStyleId = useId();
Expand Down Expand Up @@ -966,6 +978,16 @@ function FormatterSettings({
onChange={(e) => setBracketSpacing(e.target.checked)}
/>
</div>
<div className="field-row">
<label htmlFor={delimiterSpacingId}>Delimiter Spacing</label>
<input
id={delimiterSpacingId}
name="delimiterSpacing"
type="checkbox"
checked={delimiterSpacing}
onChange={(e) => setDelimiterSpacing(e.target.checked)}
/>
</div>
<div className="field-row">
<label htmlFor={bracketSameLineId}>Bracket Same Line</label>
<input
Expand Down
2 changes: 2 additions & 0 deletions src/playground/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export interface PlaygroundSettings {
arrowParentheses: ArrowParentheses;
attributePosition: AttributePosition;
bracketSpacing: boolean;
delimiterSpacing: boolean;
bracketSameLine: boolean;
expand: Expand;
lintRules: LintRule;
Expand Down Expand Up @@ -234,6 +235,7 @@ export const defaultPlaygroundState: PlaygroundState = {
arrowParentheses: ArrowParentheses.Always,
attributePosition: AttributePosition.Auto,
bracketSpacing: true,
delimiterSpacing: false,
bracketSameLine: false,
expand: Expand.Auto,
lintRules: LINT_RULES.recommended,
Expand Down
6 changes: 6 additions & 0 deletions src/playground/workers/biomeWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ self.addEventListener("message", async (e) => {
semicolons,
arrowParentheses,
bracketSpacing,
delimiterSpacing,
bracketSameLine,
expand,
indentScriptAndStyle,
Expand Down Expand Up @@ -186,6 +187,7 @@ self.addEventListener("message", async (e) => {
? "always"
: "asNeeded",
bracketSpacing,
delimiterSpacing,
bracketSameLine,
attributePosition:
attributePosition === AttributePosition.Auto
Expand All @@ -200,6 +202,7 @@ self.addEventListener("message", async (e) => {
css: {
formatter: {
quoteStyle: quoteStyle === QuoteStyle.Double ? "double" : "single",
delimiterSpacing,
},
parser: {
allowWrongLineComments: true,
Expand All @@ -208,6 +211,9 @@ self.addEventListener("message", async (e) => {
},
},
json: {
formatter: {
delimiterSpacing,
},
parser: {
allowComments,
},
Expand Down