diff --git a/lib/service-host.js b/lib/service-host.js
index b950cd3..70e6450 100644
--- a/lib/service-host.js
+++ b/lib/service-host.js
@@ -34,6 +34,23 @@ function getTypeScriptLanguageServiceHost(path, content) {
return snapshot;
}
},
+ getScriptKind: (fileName) => {
+ const ext = fileName.substring(fileName.lastIndexOf('.') + 1);
+ switch (ext) {
+ case 'ts':
+ return ts.ScriptKind.TS;
+ case 'tsx':
+ return ts.ScriptKind.TSX;
+ case 'js':
+ return ts.ScriptKind.JS;
+ case 'jsx':
+ return ts.ScriptKind.JSX;
+ case 'json':
+ return ts.ScriptKind.JSON;
+ default:
+ return ts.ScriptKind.Unknown;
+ }
+ },
};
}
diff --git a/test/vue.js b/test/vue.js
index 9dea519..d377545 100644
--- a/test/vue.js
+++ b/test/vue.js
@@ -91,6 +91,109 @@ Foo
t.is(formattedCode, expected);
});
+test('works with JSX inside Vue files', async (t) => {
+ const code = `
+`;
+
+ const formattedCode = await prettify(code, { filepath: 'file.vue' });
+
+ t.is(formattedCode, code);
+});
+
+test('removes unused imports in Vue JSX files', async (t) => {
+ const code = `
+`;
+
+ const expected = `
+`;
+
+ const formattedCode = await prettify(code, { filepath: 'file.vue' });
+
+ t.is(formattedCode, expected);
+});
+
+test('works with TSX inside Vue files', async (t) => {
+ const code = `
+`;
+
+ const formattedCode = await prettify(code, { filepath: 'file.vue' });
+
+ t.is(formattedCode, code);
+});
+
+test('removes unused imports in Vue TSX files', async (t) => {
+ const code = `
+`;
+
+ const expected = `
+`;
+
+ const formattedCode = await prettify(code, { filepath: 'file.vue' });
+
+ t.is(formattedCode, expected);
+});
+
+test('works with JSX in Vue setup scripts', async (t) => {
+ const code = `
+`;
+
+ const formattedCode = await prettify(code, { filepath: 'file.vue' });
+
+ t.is(formattedCode, code);
+});
+
test.serial('works with Volar language plugins when not running from the project root', async (t) => {
const originalGetCurrentDir = ts.sys.getCurrentDirectory;