Skip to content
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

Please dont lock the @babel/parser version #141

Open
1 task
cncolder opened this issue Mar 11, 2022 · 6 comments
Open
1 task

Please dont lock the @babel/parser version #141

cncolder opened this issue Mar 11, 2022 · 6 comments

Comments

@cncolder
Copy link

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 🥇
@IanVS
Copy link

IanVS commented Mar 17, 2022

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

@cncolder
Copy link
Author

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"
    }
  }
}

@KilianB KilianB mentioned this issue Mar 30, 2022
1 task
@KilianB
Copy link

KilianB commented Mar 30, 2022

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 npm/cli#4232

"overrides": {
    "@babel/parser": "7.17.8"
  },

@jmfrancois
Copy link

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.

@fellnerse
Copy link

Is this going to be fixed?

@tyteen4a03
Copy link

Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants