Skip to content

Commit

Permalink
fix: remove new line
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx committed Apr 30, 2024
1 parent fccccb6 commit 9df23b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": false
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`snapshot > defineNuxtComponent 1`] = `
"
import { defineNuxtComponent, useNuxtApp } from '#imports';
"import { defineNuxtComponent, useNuxtApp } from '#imports';
const { $client } = useNuxtApp();
Expand All @@ -13,8 +12,7 @@ const onSubmit = () => {
`;

exports[`snapshot > lang=js 1`] = `
"
import { defineComponent, toRefs, computed, ref } from 'vue';
"import { defineComponent, toRefs, computed, ref } from 'vue';
const props = defineProps({
msg: {
type: String,
Expand All @@ -34,8 +32,7 @@ const count = ref(0);
`;

exports[`snapshot > lang=ts 1`] = `
"
import { defineComponent, toRefs, computed, ref } from 'vue';
"import { defineComponent, toRefs, computed, ref } from 'vue';
type Props = {
msg?: string;
foo: string;
Expand Down
22 changes: 11 additions & 11 deletions packages/vue-script-setup-converter/src/lib/convertSrc.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, describe, it } from 'vitest';
import { convertSrc } from './convertSrc';
import { expect, describe, it } from "vitest";
import { convertSrc } from "./convertSrc";

describe('snapshot', () => {
it('lang=js', () => {
describe("snapshot", () => {
it("lang=js", () => {
const output = convertSrc(`<script>
import { defineComponent, toRefs, computed, ref } from 'vue';
Expand Down Expand Up @@ -37,7 +37,7 @@ export default defineComponent({
expect(output).toMatchSnapshot();
});

it('lang=ts', () => {
it("lang=ts", () => {
const output = convertSrc(`<script lang="ts">
import { defineComponent, toRefs, computed, ref } from 'vue';
Expand Down Expand Up @@ -73,7 +73,7 @@ export default defineComponent({
expect(output).toMatchSnapshot();
});

it('defineNuxtComponent', () => {
it("defineNuxtComponent", () => {
const output = convertSrc(`<script lang="ts">
import { defineNuxtComponent, useNuxtApp } from '#imports';
Expand All @@ -96,7 +96,7 @@ export default defineNuxtComponent({
expect(output).toMatchSnapshot();
});

it('empty setup context', () => {
it("empty setup context", () => {
const output = convertSrc(`<script lang="ts">
import { defineComponent, toRefs, computed } from 'vue';
Expand All @@ -120,8 +120,7 @@ export default defineComponent({
</script>`);
expect(output).toMatchInlineSnapshot(
`
"
import { defineComponent, toRefs, computed } from 'vue';
"import { defineComponent, toRefs, computed } from 'vue';
type Props = { msg?: string; }; const props = withDefaults(defineProps<Props>(), { msg: 'HelloWorld' });
const { msg } = toRefs(props);
Expand All @@ -131,8 +130,9 @@ export default defineComponent({
);
});

it('props no toRefs', () => {
it("props no toRefs", () => {
const output = convertSrc(`<script lang="ts">
import type { PropType } from 'vue';
import { defineComponent, computed } from 'vue';
export default defineComponent({
Expand All @@ -154,7 +154,7 @@ export default defineComponent({
</script>`);
expect(output).toMatchInlineSnapshot(
`
"
"import type { PropType } from 'vue';
import { defineComponent, computed } from 'vue';
type Props = { msg?: string; }; const props = withDefaults(defineProps<Props>(), { msg: 'HelloWorld' });
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-script-setup-converter/src/lib/convertSrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const convertSrc = (input: string) => {
sourceFile
.getStatements()
.filter((state) => !Node.isExportAssignment(state))
.map((x) => x.getFullText())
.map((x) => x.getText())
);

statements.addStatements(props);
Expand Down

0 comments on commit 9df23b1

Please sign in to comment.