Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(organizeImports): add space where needed #2602

Merged
merged 1 commit into from
Apr 25, 2024
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b

Contributed by @Conaclos

- Import sorting now adds spaces where needed ([#1665](https://github.com/biomejs/biome/issues/1665))
Contributed by @Conaclos

### CLI

#### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,14 @@ impl ImportNode {
// If the node we're attaching this separator to has no trailing trivia, just create a simple comma token
let last_trailing_trivia = match node.syntax().last_trailing_trivia() {
Some(trivia) if !trivia.is_empty() => trivia,
_ => return make::token(T![,]),
_ => {
let sep = make::token(T![,]);
return if node.syntax().has_leading_newline() {
sep
} else {
sep.with_trailing_trivia([(TriviaPieceKind::Whitespace, " ")])
};
}
};

// Otherwise we need to clone the trailing trivia from the node to the separator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import {type ContactOption, /* 1 */ loadStripe, /* 2 */ type StripeElementsOptions} from '@stripe/stripe-js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: space.ts
---
# Input
```ts
import {type ContactOption, /* 1 */ loadStripe, /* 2 */ type StripeElementsOptions} from '@stripe/stripe-js';
```

# Actions
```diff
@@ -1 +1 @@
-import {type ContactOption, /* 1 */ loadStripe, /* 2 */ type StripeElementsOptions} from '@stripe/stripe-js';
\ No newline at end of file
+import {type ContactOption, /* 1 */ type StripeElementsOptions, loadStripe /* 2 */ } from '@stripe/stripe-js';
\ No newline at end of file

```