Repository navigation
fix: don't add a space between a jsx expression container's braces and an object or array literal - #882
Merged
Conversation
…d an object or array literal
thristhart
added a commit
to thristhart/dprint-plugin-typescript
that referenced
this pull request
Nov 6, 2026
dprint#882 stopped adding a space between a JSX expression container's braces and an object or array literal (`style={{ color }}`). That's a good default, but some codebases enforce `style={ { color } }` with eslint's `react/jsx-curly-spacing` (`when: always`, which doesn't allow `{{` by default) and have no way to keep it. This adds `jsxExpressionContainer.spaceSurroundingObjectOrArrayLiteral` (default `false`, which keeps the current output) for the space around an object or array literal. It's independent of `jsxExpressionContainer.spaceSurroundingExpression`, which is now used for every other expression. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thristhart
added a commit
to thristhart/dprint-plugin-typescript
that referenced
this pull request
Nov 6, 2026
this option brings back the behavior fixed by dprint#882 (as mentioned in dprint#602)
dsherret
added a commit
to thristhart/dprint-plugin-typescript
that referenced
this pull request
Nov 6, 2026
…eral and spaceSurroundingArrayLiteral Both default to the value of `jsxExpressionContainer.spaceSurroundingExpression`, which restores the output from before dprint#882. Set them to `false` to keep the brackets beside the braces (ex. `{{ value: true }}`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #602
With
jsxExpressionContainer.spaceSurroundingExpression: true, an object or array literal got spaces between its braces and the container's braces:There's now no space next to an object or array literal, like eslint's
react/jsx-curly-spacingwithobjectLiterals: "never":style={{...}}), empty literals and literal children.{({ a: 1 })}is stable.{ /* c */ { a: 1 } }), as do other expressions (ex.{ { a: 1 } as T }or{ [1].map(f) }) and spread attributes.This only changes output when the option is enabled.
Tests
issue0602.txthas the issue's examples, empty literals, children, removed and kept parens, comments, and multi-line literals.JsxExpressionContainer_SpaceSurroundingExpression_True.txtnow expectsstyle={{instead ofstyle={ {.