diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..1ca87ab --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": false +} diff --git a/packages/vue-script-setup-converter/src/lib/__snapshots__/convertSrc.test.ts.snap b/packages/vue-script-setup-converter/src/lib/__snapshots__/convertSrc.test.ts.snap index 8849e88..145bec7 100644 --- a/packages/vue-script-setup-converter/src/lib/__snapshots__/convertSrc.test.ts.snap +++ b/packages/vue-script-setup-converter/src/lib/__snapshots__/convertSrc.test.ts.snap @@ -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(); @@ -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, @@ -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; diff --git a/packages/vue-script-setup-converter/src/lib/convertSrc.test.ts b/packages/vue-script-setup-converter/src/lib/convertSrc.test.ts index bd92169..c0a5d64 100644 --- a/packages/vue-script-setup-converter/src/lib/convertSrc.test.ts +++ b/packages/vue-script-setup-converter/src/lib/convertSrc.test.ts @@ -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(``); expect(output).toMatchInlineSnapshot( ` - " - import { defineComponent, toRefs, computed } from 'vue'; + "import { defineComponent, toRefs, computed } from 'vue'; type Props = { msg?: string; }; const props = withDefaults(defineProps(), { msg: 'HelloWorld' }); const { msg } = toRefs(props); @@ -131,8 +130,9 @@ export default defineComponent({ ); }); - it('props no toRefs', () => { + it("props no toRefs", () => { const output = convertSrc(``); expect(output).toMatchInlineSnapshot( ` - " + "import type { PropType } from 'vue'; import { defineComponent, computed } from 'vue'; type Props = { msg?: string; }; const props = withDefaults(defineProps(), { msg: 'HelloWorld' }); diff --git a/packages/vue-script-setup-converter/src/lib/convertSrc.ts b/packages/vue-script-setup-converter/src/lib/convertSrc.ts index 3e5a532..e096dca 100644 --- a/packages/vue-script-setup-converter/src/lib/convertSrc.ts +++ b/packages/vue-script-setup-converter/src/lib/convertSrc.ts @@ -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);