Skip to content

Commit dc138f6

Browse files
authored
(chore) fix tests + lint (#894)
#882
1 parent 8d7dfd6 commit dc138f6

File tree

7 files changed

+20
-13
lines changed

7 files changed

+20
-13
lines changed

packages/svelte2tsx/src/svelte2tsx/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,20 @@ function addComponentExport({
329329
? uses$$propsOr$$restProps
330330
? `__sveltets_with_any(${eventsDef})`
331331
: eventsDef
332-
: `__sveltets_partial${isTsFile ? '_ts' : ''}${uses$$propsOr$$restProps ? '_with_any' : ''
333-
}(${eventsDef})`;
332+
: `__sveltets_partial${isTsFile ? '_ts' : ''}${
333+
uses$$propsOr$$restProps ? '_with_any' : ''
334+
}(${eventsDef})`;
334335

335336
const doc = componentDocumentation.getFormatted();
336337
const className = fileName && classNameFromFilename(fileName);
337338

338339
const statement =
339-
`\n\n${doc}export default class${className ? ` ${className}` : ''
340+
`\n\n${doc}export default class${
341+
className ? ` ${className}` : ''
340342
} extends createSvelte2TsxComponent(${propDef}) {` +
341-
createClassGetters(getters) + createClassSetters(setters) + '\n}';
343+
createClassGetters(getters) +
344+
createClassSetters(setters) +
345+
'\n}';
342346

343347
str.append(statement);
344348
}
@@ -501,7 +505,13 @@ export function svelte2tsx(
501505
if (scriptTag.start != instanceScriptTarget) {
502506
str.move(scriptTag.start, scriptTag.end, instanceScriptTarget);
503507
}
504-
const res = processInstanceScriptContent(str, scriptTag, events, implicitStoreValues, usesAccessors);
508+
const res = processInstanceScriptContent(
509+
str,
510+
scriptTag,
511+
events,
512+
implicitStoreValues,
513+
usesAccessors
514+
);
505515
uses$$props = uses$$props || res.uses$$props;
506516
uses$$restProps = uses$$restProps || res.uses$$restProps;
507517
uses$$slots = uses$$slots || res.uses$$slots;

packages/svelte2tsx/src/svelte2tsx/nodes/exportgetters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const createClassGetter = (name: string) =>
2-
`\n${' '.repeat(4)}get ${name}() { return render().getters.${name} }`;
2+
`\n get ${name}() { return render().getters.${name} }`;
33
export const createClassGetters = (names: Set<string>) => {
44
return Array.from(names).map(createClassGetter).join('');
55
};
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export const createClassSetter = (name: string) =>
2-
`\n
3-
/**accessor*/\n${' '.repeat(4)}set ${name}(${name}) {}`;
2+
`\n /**accessor*/\n set ${name}(${name}) {}`;
43

54
export const createClassSetters = (names: Set<string>) => {
65
return Array.from(names).map(createClassSetter).join('');
@@ -9,4 +8,4 @@ export const createClassSetters = (names: Set<string>) => {
98
export function createRenderFunctionSetterStr(setters: Set<string>) {
109
const properties = Array.from(setters).map((name) => `${name}: ${name}`);
1110
return `{${properties.join(', ')}}`;
12-
}
11+
}

packages/svelte2tsx/test/svelte2tsx/samples/$store-as-directive/expected.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{...__sveltets_ensureAnimation((__sveltets_store_get(animateStore), $animateStore)(__sveltets_mapElementTag('div'),__sveltets_AnimationMove,{}))}
1818
>
1919
</div></>);
20-
return { props: {}, slots: {}, getters: {}, events: {} }}
20+
return { props: {}, slots: {}, getters: {}, setters: {}, events: {} }}
2121

2222
export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
2323
}

packages/svelte2tsx/test/svelte2tsx/samples/event-and-forwarded-event/expected.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function render() {
1111
() => (<>
1212

1313
<input onfocus={undefined} /></>);
14-
return { props: {}, slots: {}, getters: {}, events: {'focus':__sveltets_mapElementEvent('focus'), 'mount': __sveltets_customEvent} }}
14+
return { props: {}, slots: {}, getters: {}, setters: {}, events: {'focus':__sveltets_mapElementEvent('focus'), 'mount': __sveltets_customEvent} }}
1515

1616
export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
1717
}

packages/svelte2tsx/test/svelte2tsx/samples/uses-accessors-attr-present/expected.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ return { props: {foo: foo , bar: bar}, slots: {}, getters: {foo: foo, bar: bar},
1111
export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
1212
get foo() { return render().getters.foo }
1313
get bar() { return render().getters.bar }
14-
1514
/**accessor*/
1615
set foo(foo) {}
1716
}

packages/svelte2tsx/test/svelte2tsx/samples/uses-accessors-mustachetag-true/expected.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ return { props: {foo: foo , bar: bar}, slots: {}, getters: {foo: foo, bar: bar},
1111
export default class Input__SvelteComponent_ extends createSvelte2TsxComponent(__sveltets_partial(__sveltets_with_any_event(render))) {
1212
get foo() { return render().getters.foo }
1313
get bar() { return render().getters.bar }
14-
1514
/**accessor*/
1615
set foo(foo) {}
1716
}

0 commit comments

Comments
 (0)