IanVS / prettier-plugin-sort-imports

An opinionated but flexible prettier plugin to sort import statements
Apache License 2.0
951 stars 21 forks source link

Fix dollar sign ($) issue in Vue SFC #101

Closed istiak-tridip closed 1 year ago

istiak-tridip commented 1 year ago

Fixes #100

When replacing a string if the provided replacement is a string it will replace the original string using pattern matching. In the vue preprocessor, the $ in the code is seen as a regex pattern. Passing a function as a replacement escapes that issue.

IanVS commented 1 year ago

Oh beautiful, thanks for digging in and submitting a fix + snapshot test.

IanVS commented 1 year ago

@fbartho it sounds like we were hitting this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement

fbartho commented 1 year ago

Ah! I didn't know there was extra special escapes in that case. Thanks for replying!