trivago / prettier-plugin-sort-imports

A prettier plugin to sort imports in typescript and javascript files by the provided RegEx order.
Apache License 2.0
3.37k stars 133 forks source link

Multiple dollar sign $ in .vue files formats incorrectly #184

Open strickczq opened 2 years ago

strickczq commented 2 years ago

Your Environment

Describe the bug

with @trivago/prettier-plugin-sort-imports: 3.4.0, code $$(0); will be formatted to $(0); in .vue files, which is unacceptable when using Vue3's Reactivity Transform

note that it works normally when:

To Reproduce

there is a file test.vue

<script setup>
$$(0);
</script>

and then I run prettier --plugin @trivago/prettier-plugin-sort-imports --write test.vue

the file is formatted to

<script setup>
$(0);
</script>

interestingly

Expected behavior

the file test.vue should be unchanged

<script setup>
$$(0);
</script>

Screenshots, code sample, etc

image

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

prettier's default config with just @trivago/prettier-plugin-sort-imports plugin

Error log

N/A

Contribute to @trivago/prettier-plugin-sort-imports

michaelwilson-deswik commented 2 months ago

This seems to also affects template literals which causes a change to the output of a string.

<script lang="ts">
const variableName = `$${true}`;
</script>

becomes

<script lang="ts">
const variableName = `${true}`;
</script>