Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sveltejs/prettier-plugin-svelte
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0957c4bdf0a44ae460db6125c3bbbb4455fd6f36
Choose a base ref
...
head repository: sveltejs/prettier-plugin-svelte
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 14da6fb7fe0141771d88662b73efa53d39946b1f
Choose a head ref
  • 3 commits
  • 10 files changed
  • 1 contributor

Commits on Oct 10, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    branchvincent Branch Vincent
    Copy the full SHA
    ebd7e9a View commit details

Commits on Nov 18, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7cfd71b View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    14da6fb View commit details
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# prettier-plugin-svelte changelog

## 2.8.0 (unreleased)
## 2.8.1 (Unreleased)

* (fix) format `{#await .. catch ..}..{/await}` correctly ([#323](https://github.com/sveltejs/prettier-plugin-svelte/issues/323))
* (fix) respect strict mode and shorthand options when formatting bindings ([#321](https://github.com/sveltejs/prettier-plugin-svelte/issues/321))

## 2.8.0

* (feat) support `singleAttributePerLine` Prettier option ([#305](https://github.com/sveltejs/prettier-plugin-svelte/issues/305))
* (feat) add `svelteSortOrder: none` Prettier option which skips reordering scripts/styles/html ([#305](https://github.com/sveltejs/prettier-plugin-svelte/issues/314))
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier-plugin-svelte",
"version": "2.7.1",
"version": "2.8.0",
"description": "Svelte plugin for prettier",
"main": "plugin.js",
"files": [
18 changes: 16 additions & 2 deletions src/print/index.ts
Original file line number Diff line number Diff line change
@@ -540,6 +540,17 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
]),
path.call(print, 'then'),
);
} else if (!hasPendingBlock && hasCatchBlock) {
block.push(
groupConcat([
'{#await ',
printSvelteBlockJS(path, print, 'expression'),
' catch',
expandNode(node.error),
'}',
]),
path.call(print, 'catch'),
);
} else {
block.push(
groupConcat(['{#await ', printSvelteBlockJS(path, print, 'expression'), '}']),
@@ -557,7 +568,7 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
}
}

if (hasCatchBlock) {
if ((hasPendingBlock || hasThenBlock) && hasCatchBlock) {
block.push(
groupConcat(['{:catch', expandNode(node.error), '}']),
path.call(print, 'catch'),
@@ -597,7 +608,10 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
return concat([
'bind:',
node.name,
node.expression.type === 'Identifier' && node.expression.name === node.name
node.expression.type === 'Identifier' &&
node.expression.name === node.name &&
options.svelteAllowShorthand &&
!options.svelteStrictMode
? ''
: concat(['=', ...printJsExpression()]),
]);
8 changes: 8 additions & 0 deletions test/formatting/samples/strict-mode-false/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<input value />
<input value="string" />
<input {value} />
<input value={value} />
<input value="{value}" />
<input bind:value />
<input bind:value={value} />
<input bind:value="{value}" />
8 changes: 8 additions & 0 deletions test/formatting/samples/strict-mode-false/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<input value />
<input value="string" />
<input {value} />
<input {value} />
<input {value} />
<input bind:value />
<input bind:value />
<input bind:value />
3 changes: 3 additions & 0 deletions test/formatting/samples/strict-mode-true/input.html
Original file line number Diff line number Diff line change
@@ -3,3 +3,6 @@
<input {value} />
<input value={value} />
<input value="{value}" />
<input bind:value />
<input bind:value={value} />
<input bind:value="{value}" />
3 changes: 3 additions & 0 deletions test/formatting/samples/strict-mode-true/output.html
Original file line number Diff line number Diff line change
@@ -3,3 +3,6 @@
<input value="{value}" />
<input value="{value}" />
<input value="{value}" />
<input bind:value="{value}" />
<input bind:value="{value}" />
<input bind:value="{value}" />
2 changes: 2 additions & 0 deletions test/printer/samples/allow-shorthand-false.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<input type="text" value={value} />

<input type="text" data={data} />

<input type="text" bind:value={value} />
1 change: 1 addition & 0 deletions test/printer/samples/await-catch-without-pending.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{#await thePromise catch theCatch}the value is {theCatch}{/await}