biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
15.6k stars 486 forks source link

📎 Implement formatting option to include space inside parens, braces, brackets, etc. #4607

Open sirreal opened 1 week ago

sirreal commented 1 week ago

Description

Add formatting option to include spacing inside parentheses, square brackets, curly braces, and angle brackets.

For example, this input:

function id<TypeArg>(x: TypeArg): TypeArg {
    return x;
}
const arr = [1, 2, 3];
if (id(true)) {
    // …
}

Would be formatted as follows with a "space inside" option enabled:

function id< TypeArg > ( x: TypeArg ): TypeArg {
    return x;
}
const arr = [ 1, 2, 3 ];
if ( id( true ) ) {
    // …
}

See https://github.com/biomejs/biome/discussions/2360#discussioncomment-10690814.