Skip to content

Commit

Permalink
fix(organizeImports): add space where needed (#2602)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Apr 25, 2024
1 parent 0c0eb99 commit 2db7d05
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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

```

0 comments on commit 2db7d05

Please sign in to comment.