daidodo / format-imports

JavaScript and TypeScript Import/Export Sorter
MIT License
47 stars 2 forks source link

Support format vue file #11

Closed tjx666 closed 1 year ago

tjx666 commented 3 years ago

This extension is very useful to format ts/js file imports, but seems not support .vue yet. @daidodo

daidodo commented 2 years ago

Duplicate to https://github.com/daidodo/format-imports-vscode/issues/37.

tjx666 commented 1 year ago

@daidodo @zddai any problems when implement vue support? Vue user amount is very large...

daidodo commented 1 year ago

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!

tjx666 commented 1 year ago

@daidodo

  1. match the script tag in vue file by https://regex101.com/r/zvwJ1B/1
  2. format the script code
  3. insert the result code back

This should also works for svelte

daidodo commented 1 year ago

Many thanks for your PR (https://github.com/daidodo/format-imports/pull/19)!

Before shipping it to production, I still have a few questions:

I've added some test cases (which may fail) to reflect my questions.

tjx666 commented 1 year ago
daidodo commented 1 year ago
tjx666 commented 1 year ago
daidodo commented 1 year ago
daidodo commented 1 year ago

@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!

tjx666 commented 1 year ago

simple try, and works good