prettier-plugin-sort-imports icon indicating copy to clipboard operation
prettier-plugin-sort-imports copied to clipboard

Please dont lock the @babel/parser version

Open cncolder opened this issue 3 years ago • 6 comments

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 avatar Mar 11 '22 15:03 cncolder

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

IanVS avatar Mar 17 '22 02:03 IanVS

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

cncolder avatar Mar 17 '22 02:03 cncolder

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

KilianB avatar Mar 30 '22 12:03 KilianB

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.

jmfrancois avatar Apr 04 '22 15:04 jmfrancois

Is this going to be fixed?

fellnerse avatar Jun 20 '22 09:06 fellnerse

Bump

tyteen4a03 avatar Jul 11 '22 14:07 tyteen4a03