fix: *.vue with `lang='tsx'` is not formatted (#3763)
parent
114895a8a2
commit
3f788d4fb6
|
@ -28,7 +28,7 @@ function embed(path, print, textToDoc, options) {
|
||||||
const langAttr = node.attrs.find(attr => attr.name === "lang");
|
const langAttr = node.attrs.find(attr => attr.name === "lang");
|
||||||
if (!langAttr) {
|
if (!langAttr) {
|
||||||
parser = "babylon";
|
parser = "babylon";
|
||||||
} else if (langAttr.value === "ts") {
|
} else if (langAttr.value === "ts" || langAttr.value === "tsx") {
|
||||||
parser = "typescript";
|
parser = "typescript";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,58 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`lang-ts.vue 1`] = `
|
||||||
|
<template>
|
||||||
|
<div>{{foo}}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
computed: { foo( ): string { return "foo"; }, },
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
<template>
|
||||||
|
<div>{{foo}}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
computed: {
|
||||||
|
foo(): string {
|
||||||
|
return "foo";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lang-tsx.vue 1`] = `
|
||||||
|
<script lang="tsx">
|
||||||
|
import {VNode} from "vue"
|
||||||
|
export default {
|
||||||
|
computed: { foo( ):string { return "foo" }, },
|
||||||
|
render(h):VNode { return <div>{ this.foo }</div> },
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
<script lang="tsx">
|
||||||
|
import { VNode } from "vue";
|
||||||
|
export default {
|
||||||
|
computed: {
|
||||||
|
foo(): string {
|
||||||
|
return "foo";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render(h): VNode {
|
||||||
|
return <div>{this.foo}</div>;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`template-bind.vue 1`] = `
|
exports[`template-bind.vue 1`] = `
|
||||||
<template>
|
<template>
|
||||||
<div v-bind:id=" 'list-' + id "></div>
|
<div v-bind:id=" 'list-' + id "></div>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<template>
|
||||||
|
<div>{{foo}}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
computed: { foo( ): string { return "foo"; }, },
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<script lang="tsx">
|
||||||
|
import {VNode} from "vue"
|
||||||
|
export default {
|
||||||
|
computed: { foo( ):string { return "foo" }, },
|
||||||
|
render(h):VNode { return <div>{ this.foo }</div> },
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue