nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: sveltejs/language-tools
Pull request #908 (2021-03-23 09:23:10)

(fix) ignore `typeof $store`
Don't translate this into a store access
#903


Patch:
diff --git a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
index 2c678579..eb50c087 100644
--- a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
+++ b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
@@ -142,9 +142,17 @@ export function processInstanceScriptContent(
     };
 
     const handleStore = (ident: ts.Identifier, parent: ts.Node) => {
+        // ignore "typeof $store"
+        if (parent && parent.kind === ts.SyntaxKind.TypeQuery) {
+            return;
+        }
+        // ignore break
+        if (parent && parent.kind === ts.SyntaxKind.BreakStatement) {
+            return;
+        }
+
         const storename = ident.getText().slice(1); // drop the $
         // handle assign to
-        // eslint-disable-next-line max-len
         if (
             parent &&
             ts.isBinaryExpression(parent) &&
@@ -160,10 +168,7 @@ export function processInstanceScriptContent(
             str.appendLeft(parent.end + astOffset, ')');
             return;
         }
-        // ignore break
-        if (parent && parent.kind === ts.SyntaxKind.BreakStatement) {
-            return;
-        }
+
         // handle Assignment operators ($store +=, -=, *=, /=, %=, **=, etc.)
         // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Assignment
         const operators = {


Test patch:
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/typeof-$store/expected.tsx b/packages/svelte2tsx/test/svelte2tsx/samples/typeof-$store/expected.tsx
new file mode 100644
index 00000000..6e406174
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/typeof-$store/expected.tsx
@@ -0,0 +1,14 @@
+///<reference types="svelte" />
+<></>;
+import {writable} from "svelte/store";
+function render() {
+
+	
+	const foo = writable(1)/*Ωignore_startΩ*/;let $foo = __sveltets_store_get(foo);/*Ωignore_endΩ*/;
+	type Foo = typeof $foo;
+;
+() => (<></>);
+return { props: {}, slots: {}, getters: {}, events: {} }}
+
+export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
+}
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/typeof-$store/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/typeof-$store/input.svelte
new file mode 100644
index 00000000..5bf160f8
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/typeof-$store/input.svelte
@@ -0,0 +1,5 @@
+<script lang="ts">
+	import {writable} from "svelte/store";
+	const foo = writable(1);
+	type Foo = typeof $foo;
+</script>
\ No newline at end of file
Repository: sveltejs/language-tools
Pull request #935 (2021-04-02 21:37:28)

(fix) don't remove inserted code around comment
Use overwrite instead of remove
#928


Patch:
diff --git a/packages/svelte2tsx/src/htmlxtojsx/nodes/comment.ts b/packages/svelte2tsx/src/htmlxtojsx/nodes/comment.ts
index 6b38a7ea..0c6ab234 100644
--- a/packages/svelte2tsx/src/htmlxtojsx/nodes/comment.ts
+++ b/packages/svelte2tsx/src/htmlxtojsx/nodes/comment.ts
@@ -5,5 +5,5 @@ import { BaseNode } from '../../interfaces';
  * Removes comment
  */
 export function handleComment(str: MagicString, node: BaseNode): void {
-    str.remove(node.start, node.end);
+    str.overwrite(node.start, node.end, '', { contentOnly: true });
 }


Test patch:
diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/comments-around-if/expected.jsx b/packages/svelte2tsx/test/htmlx2jsx/samples/comments-around-if/expected.jsx
new file mode 100644
index 00000000..68ff4a01
--- /dev/null
+++ b/packages/svelte2tsx/test/htmlx2jsx/samples/comments-around-if/expected.jsx
@@ -0,0 +1,1 @@
+<><div>{(true) ? <><span>Hey!</span></> : (!true) ? <><span>there...</span></> : <></> }</div></>
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/comments-around-if/input.svelte b/packages/svelte2tsx/test/htmlx2jsx/samples/comments-around-if/input.svelte
new file mode 100644
index 00000000..5ef44325
--- /dev/null
+++ b/packages/svelte2tsx/test/htmlx2jsx/samples/comments-around-if/input.svelte
@@ -0,0 +1,7 @@
+<div><!--
+-->{#if true}<!--
+   --><span>Hey!</span><!--
+-->{:else if !true}<!--
+   --><span>there...</span><!--
+-->{/if}<!--
+--></div>
\ No newline at end of file
Repository: sveltejs/language-tools
Pull request #966 (2021-04-26 03:12:59)

(svelte2tsx) type assertion in module script
#964 


Patch:
diff --git a/packages/svelte2tsx/src/svelte2tsx/processModuleScriptTag.ts b/packages/svelte2tsx/src/svelte2tsx/processModuleScriptTag.ts
index bfd9e141..ee3df17f 100644
--- a/packages/svelte2tsx/src/svelte2tsx/processModuleScriptTag.ts
+++ b/packages/svelte2tsx/src/svelte2tsx/processModuleScriptTag.ts
@@ -2,6 +2,7 @@ import MagicString from 'magic-string';
 import { Node } from 'estree-walker';
 import ts from 'typescript';
 import { ImplicitStoreValues } from './nodes/ImplicitStoreValues';
+import { handleTypeAssertion } from './nodes/handleTypeAssertion';
 
 export function processModuleScriptTag(
     str: MagicString,
@@ -47,6 +48,10 @@ function resolveImplicitStores(
             implicitStoreValues.addImportStatement(node);
         }
 
+        if (ts.isTypeAssertionExpression?.(node)) {
+            handleTypeAssertion(str, node, astOffset);
+        }
+
         ts.forEachChild(node, (n) => walk(n));
     };
 


Test patch:
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/expected.tsx b/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/expected.tsx
index 1853e99e..e4e510d8 100644
--- a/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/expected.tsx
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/expected.tsx
@@ -1,9 +1,13 @@
 ///<reference types="svelte" />
-<></>;function render() {
+<></>;
+    let a = '' as string;
+;<></>;function render() {
 
     let a = document.querySelector('#id') as HTMLInputElement;
 ;
-() => (<></>);
+() => (<>
+
+</>);
 return { props: {}, slots: {}, getters: {}, events: {} }}
 
 export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial_ts(__sveltets_with_any_event(render))) {
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/input.svelte
index 01d77b6a..4cab6f34 100644
--- a/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/input.svelte
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/ts-type-assertion/input.svelte
@@ -1,3 +1,7 @@
-<script>
+<script lang="ts" context="module">
+    let a = <string>'';
+</script>
+
+<script lang="ts" >
     let a = <HTMLInputElement>document.querySelector('#id');
 </script>
Repository: sveltejs/language-tools
Pull request #1064 (2021-06-20 08:07:29)

(fix) correct transformation of as expression in reactive assignment
#1046


Patch:
diff --git a/packages/svelte2tsx/src/svelte2tsx/nodes/ImplicitTopLevelNames.ts b/packages/svelte2tsx/src/svelte2tsx/nodes/ImplicitTopLevelNames.ts
index f8d9c761..71596cfa 100644
--- a/packages/svelte2tsx/src/svelte2tsx/nodes/ImplicitTopLevelNames.ts
+++ b/packages/svelte2tsx/src/svelte2tsx/nodes/ImplicitTopLevelNames.ts
@@ -38,8 +38,8 @@ export class ImplicitTopLevelNames {
         const start = expression.getStart() + this.astOffset;
         const end = expression.getEnd() + this.astOffset;
 
-        // () => ({})
-        if (ts.isObjectLiteralExpression(expression)) {
+        // $: a = { .. }  /  $: a = .. as ..  =>   () => ( .. )
+        if (ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression)) {
             this.str.appendLeft(start, '(');
             this.str.appendRight(end, ')');
         }


Test patch:
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/reactive-assignment-type-cast/expected.tsx b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-assignment-type-cast/expected.tsx
new file mode 100644
index 00000000..759939a6
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-assignment-type-cast/expected.tsx
@@ -0,0 +1,11 @@
+///<reference types="svelte" />
+<></>;function render() {
+
+	type Team = any;
+	let  team = __sveltets_invalidate(() => ({ search: "Real", players: [] } as Team));
+;
+() => (<></>);
+return { props: {}, slots: {}, getters: {}, events: {} }}
+
+export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render()))) {
+}
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/reactive-assignment-type-cast/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-assignment-type-cast/input.svelte
new file mode 100644
index 00000000..7a3b827a
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/reactive-assignment-type-cast/input.svelte
@@ -0,0 +1,4 @@
+<script lang="ts">
+	type Team = any;
+	$: team = { search: "Real", players: [] } as Team;
+</script>
Repository: sveltejs/prettier-plugin-svelte
Pull request #145 (2020-09-24 12:16:03)

(fix) don't format class attribute
Prettier HTML does not format attributes at all and to be consistent we should not format it, too.


Patch:
diff --git a/src/lib/elements.ts b/src/lib/elements.ts
index a45bec0..54e84eb 100644
--- a/src/lib/elements.ts
+++ b/src/lib/elements.ts
@@ -77,5 +77,7 @@ export const inlineElements: TagName[] = [
  * HTML attributes that we may safely reformat (trim whitespace, add or remove newlines)
  */
 export const formattableAttributes = [
-  'class'
+  // None at the moment
+  // Prettier HTML does not format attributes at all
+  // and to be consistent we leave this array empty for now
 ]


Test patch:
diff --git a/test/formatting/samples/attribute-with-linebreaks/output.html b/test/formatting/samples/attribute-with-linebreaks/output.html
index d28db2c..8ee1490 100644
--- a/test/formatting/samples/attribute-with-linebreaks/output.html
+++ b/test/formatting/samples/attribute-with-linebreaks/output.html
@@ -1,6 +1,5 @@
 <div
-    class="{longExpressionThatForcesLinebreaks} longExpressionThatForcesLinebreaks
-        longExpressionThatForcesLinebreaks"
+    class=" {longExpressionThatForcesLinebreaks} longExpressionThatForcesLinebreaks longExpressionThatForcesLinebreaks  "
     alt="When reformatting class attributes it is fine to trim and add new line breaks. 
 That's not the case with other attributes. "
     data-value={array.map((item) => {
Repository: sveltejs/prettier-plugin-svelte
Pull request #188 (2021-01-08 19:24:08)

(fix) svelteBracketNewLine true print > in separate line
When `svelteBracketNewLine` is set to `true` and only the closing tag is hugged, print the closing `>` in a separate line. Fixes a bug introduced in 2.0.3.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b04538..8b7ed6e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # prettier-plugin-svelte changelog
 
+## 2.0.4 (Unreleased)
+
+* When `svelteBracketNewLine` is set to `true` and only the closing tag is hugged, print the closing `>` in a separate line.
+
 ## 2.0.3
 
 * When `svelteBracketNewLine` is set to `false`, don't print the closing `>` in a separate line if possible ([#183](https://github.com/sveltejs/prettier-plugin-svelte/issues/183))
diff --git a/src/print/index.ts b/src/print/index.ts
index d4bca62..ea1174f 100644
--- a/src/print/index.ts
+++ b/src/print/index.ts
@@ -324,7 +324,7 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
                             concat([noHugSeparatorStart, groupConcat([body(), `</${node.name}`])]),
                         ),
                     ),
-                    canOmitSoftlineBeforeClosingTag(node, path, options) ? '' : '',
+                    canOmitSoftlineBeforeClosingTag(node, path, options) ? '' : softline,
                     '>',
                 ]);
             }


Test patch:
diff --git a/test/formatting/samples/inline-element-with-children-ws/input.html b/test/formatting/samples/inline-element-with-children-ws/input.html
index b33733b..34a1c54 100644
--- a/test/formatting/samples/inline-element-with-children-ws/input.html
+++ b/test/formatting/samples/inline-element-with-children-ws/input.html
@@ -12,4 +12,6 @@
 
   <Tag />
 
-</b>
\ No newline at end of file
+</b>
+
+<span class="asd asd asd asd asd asd asd asda sd asd asd"> <Component foo="bar" />Text</span>
\ No newline at end of file
diff --git a/test/formatting/samples/inline-element-with-children-ws/output.html b/test/formatting/samples/inline-element-with-children-ws/output.html
index 10ae26b..4caa663 100644
--- a/test/formatting/samples/inline-element-with-children-ws/output.html
+++ b/test/formatting/samples/inline-element-with-children-ws/output.html
@@ -10,3 +10,7 @@
 
     <Tag />
 </b>
+
+<span class="asd asd asd asd asd asd asd asda sd asd asd">
+    <Component foo="bar" />Text</span
+>