Repository navigation
feat(fmt): apply object spacing to import/export lines - #30371
Merged
Merged
Conversation
This lets spacing in named import/export lines follow the config for objects. Spaces would always be added before, which looked odd in projects that otherwise used no spaces for objects. The documentation already mentions that the given property applies to "object-like nodes", so no change is needed there. Comparing with other formatters, Stylistic groups spacing of import and export lines with that of other curly object spacing too, hence this simplifies migration.
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.
Hi Deno folks!
I stumbled over an issue during formatting a project that I'm moving to Deno, where curly braces would be handled inconsistently by
deno fmt, and thought this would make for a nice first contribution.This lets spacing in named import/export lines follow the config for objects. Spaces would always be added before, which looked odd in projects that otherwise used no spaces for object syntax.
There is no change for users who leave
spaceSurroundingPropertiesat the default value (on).Config:
{ "fmt": {"spaceSurroundingProperties": false} }Old formatting:
New formatting with this PR applied:
With this change, the behavior roughly matches that of stylistic's curly rule, which seems reasonable to me. For me this simplified migration to deno a lot, because import braces were 90% of formatting changes caused by
deno fmtw/o option to change them before.As alternative to this change I considered adding a new property, but exposing all of dprint's internals does not seem right to me. Stylistic does not have an option to configure import/exports and objects separately either.
The documentation already mentions that the given property applies to "object-like nodes", so no change should be needed there.