-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't ignore whitespace in expressions (#930)
* add tests * do print expressions with comments only * don't remove whitespace in expressions * fix whitespace in tests * test to ignore empty expressions with whitespace * ignore empty expressions with whitespace * remove test relating to an unaffected code path * chore: changeset
- Loading branch information
1 parent
9ff6342
commit 4de359b
Showing
7 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/compiler': patch | ||
--- | ||
|
||
Preserve whitespace in expressions |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { convertToTSX } from '@astrojs/compiler'; | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
|
||
test('preverve whitespace around jsx comments', async () => { | ||
const input = `{/* @ts-expect-error */} | ||
<Component prop="value"></Component> | ||
{ | ||
// @ts-expect-error | ||
} | ||
<Component prop="value"></Component> | ||
{ | ||
/* @ts-expect-error */ | ||
<Component prop="value"></Component> | ||
} | ||
{ | ||
// @ts-expect-error | ||
<Component prop="value"></Component> | ||
}`; | ||
const output = `<Fragment> | ||
{/* @ts-expect-error */} | ||
<Component prop="value"></Component> | ||
{ | ||
// @ts-expect-error | ||
} | ||
<Component prop="value"></Component> | ||
{ | ||
/* @ts-expect-error */ | ||
<Fragment><Component prop="value"></Component></Fragment> | ||
} | ||
{ | ||
// @ts-expect-error | ||
<Fragment><Component prop="value"></Component></Fragment> | ||
} | ||
</Fragment> | ||
export default function __AstroComponent_(_props: Record<string, any>): any {}\n`; | ||
const { code } = await convertToTSX(input, { sourcemap: 'external' }); | ||
assert.snapshot(code, output, `expected code to match snapshot`); | ||
}); | ||
|
||
test.run(); |