-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting Vue SFC Files Results in 'Cannot read properties of undefined (reading 'match')' Error #158
Comments
Thanks for the report, does this also happen with version |
I have the same issue, and it works with version
Reproduce at: |
Sure, I just started my new project, so they're all the latest versions. "@ianvs/prettier-plugin-sort-imports": "^4.2.0", |
this is my config
|
Same error, after upgrading this morning to the new version 4.2.0 from 4.1.1 |
Thanks for the reports, everyone. This broke because of the way we tried to detect vue 3 vs vue 2.7 when we added support for 2.7 in the last release. It seems that @vue/compiler-sfc had what I would consider a breaking change between version 3.3 and 3.4, removing an export. We were running our tests with 3.3 and everything worked, but the more recent versions break. I've pushed up a PR that will detect the vue version more reliably, and should continue to maintain support for both vue 3 and 2.7. |
Thank you! This is my first time mustering up the courage to raise an issue, and it has given me a great sense of accomplishment.😄 |
Fixes #158 The `transformRef` method is not found on the most recent versions of @vue/compiler-sfc (3.4.x), because it seems to have only existed for some versions of 3.x (including the version we use in devDependencies, which is why our tests passed). I couldn't find any mention of it in the Vue changelog, though it seems like it should have been a breaking change to remove the method. So, now instead of relying on the presence of a method, we'll import the package.json directly, look at the version field, and make our decision based on that, which should be much safer.
I met the same error, here's the version: {
"vue": "2.7.16",
"@vue/compiler-sfc": "2.7.16",
"@ianvs/prettier-plugin-sort-imports": "4.2.1"
} If I upgrade |
Thanks @shalldie. Were you using this plugin before 4.2.1 and was it working for you before? If you're willing to open a new issue and ideally include some steps to reproduce or a link to a reproduction, that would be awesome. |
Your Environment
Describe the bug
When attempting to format Vue Single File Components (SFC) with Prettier, I encounter a TypeError: Cannot read properties of undefined (reading 'match'). This issue arises specifically when using @ianvs/prettier-plugin-sort-imports. However, switching to @trivago/prettier-plugin-sort-imports does not produce this error.
To Reproduce
Expected behavior
Expected Prettier to format Vue SFC files without any errors, applying the configured code style rules.
Screenshots, code sample, etc
Not applicable due to sensitive content. The issue occurs with any Vue SFC file, regardless of its content.
Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)
Error log
Contribute to @ianvs/prettier-plugin-sort-imports
The text was updated successfully, but these errors were encountered: