Closed tjx666 closed 1 year ago
@daidodo @zddai any problems when implement vue support? Vue user amount is very large...
I'm not familiar with Vue and don't have much time to ramp up. If someone with experience can help, that'd be great!
@daidodo
This should also works for svelte
Many thanks for your PR (https://github.com/daidodo/format-imports/pull/19)!
Before shipping it to production, I still have a few questions:
What are the supported lang
values?
For example, if <script lang="coffee">
, the plugin should skip. I assume they are default value (js
?), plus ts
. Are there other values (tsx
, jsx
)?
How is tsconfig.json resolved?
The plugin uses TypeScript API to find it for source file. I'm not sure if it's the same way in Vue?
Another minor question is: From the doc, seems jsx
is always preserved in Vue, which means import React from 'react'
should be kept. But in your test case it's removed. Am I missing something?
From these examples it seems names can be imported in <script>
and used in <template>
. How to handle such cases?
I've added some test cases (which may fail) to reflect my questions.
vue only support js/jsx/ts/tsx
tsconfig should be resolved same like rename the .vue extension to .ts. Vue jsx needn't react, jsx is not designed for react.
seems I didn't implement the remove unused imports
complented. In fact, variables can even be used in style block
jsx
and tsx
)<script lang>
.@tjx666 I've released a new version to support Vue, with removing unused imports is disabled.
Please take a try and tell me if you find any issue. Thanks!
simple try, and works good
This extension is very useful to format ts/js file imports, but seems not support .vue yet. @daidodo