fix: remove extra margin between multiline object#100
Conversation
🦋 Changeset detectedLatest commit: 3b0f385 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
I'm pretty sure this was added intentionally as this is the way code is formatted inside esrap/src/languages/ts/index.js Lines 850 to 860 in 7a37005 and I haven't checked many more places, but this does appear to be intentional. But I do agree that this looks weird in some places like you showed. Maybe we could avoid adding this extra line break if [i-1] and [i] are |
That is just better! |
manuel3108
left a comment
There was a problem hiding this comment.
LGTM, hoping for another approval though :D
Rich-Harris
left a comment
There was a problem hiding this comment.
not sure this is quite right — the test in this PR also passes on main, but IIUC the intent is to format things like this (in other words margin should only apply to statements, I guess?):
const obj = {
before: 1,
object: {
a: 'lorem ipsum dolor sit amet',
b: 'lorem ipsum dolor sit amet',
c: 'lorem ipsum dolor sit amet',
d: 'lorem ipsum dolor sit amet',
e: 'lorem ipsum dolor sit amet'
},
array: [
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet'
],
after: 2
};Right now, there's an unwanted new line between object and array:
const obj = {
before: 1,
object: {
a: 'lorem ipsum dolor sit amet',
b: 'lorem ipsum dolor sit amet',
c: 'lorem ipsum dolor sit amet',
d: 'lorem ipsum dolor sit amet',
e: 'lorem ipsum dolor sit amet'
},
array: [
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet',
'lorem ipsum dolor sit amet'
],
after: 2
};|
Thx, updated with your test |
I'm not sure if it was on purpose or not.
With today's margin, vite config looks like https://github.com/sveltejs/cli/blob/main/packages/sv/lib/cli/tests/snapshots/create-with-all-addons/vite.config.ts
What do you think ?