prettier-plugin-sort-imports
prettier-plugin-sort-imports copied to clipboard
Please dont lock the @babel/parser version
Your Environment
- Prettier version: 2.5.1
- node version: 16.14.0
- package manager: pnpm@6
- IDE: VScode
Describe the bug
Cannot format typescript type-only importing.
To Reproduce
import { type ParsedPath } from 'path';
Expected behavior
import { type ParsedPath } from 'path';
module.exports = {
singleQuote: true,
pluginSearchDirs: ['.']
}
SyntaxError: Unexpected token, expected ","
This happened because we use an old @babel/parser: 7.14.6. See https://babeljs.io/blog/2021/10/29/7.16.0
Contribute to @trivago/prettier-plugin-sort-imports
- [ ] I'm willing to fix this bug 🥇
@cncolder, I was having problems with this as well, so I updated my fork of this project to update/unpin the dependencies. Maybe it'll be useful for you too until/unless this project updates as well. (https://github.com/IanVS/prettier-plugin-sort-imports)
Hi. Thank you for your fix. I use pnpm so I override the dep version in package.json.
{
"pnpm": {
"overrides": {
"@trivago/prettier-plugin-sort-imports>@babel/parser": "7.17.3"
}
}
}
As @cncolder has mentioned we need to update the babel parser version. In general you can add the following to your package.json and all instances in your dependency tree will be updated.
Due to some bug with `npm´ this only works for the newest versions of released 8 days ago. see: npm https://github.com/npm/cli/issues/4232
"overrides": {
"@babel/parser": "7.17.8"
},
This is really not usual to lock version at the package level and ask projects to use overide. All the deps use here are well known and follow semver so please use caret to specify the dependencies.
Is this going to be fixed?
Bump