ggascoigne / prettier-plugin-import-sort

Prettier plugin to pass javascript and typescript through import-sort
MIT License
110 stars 11 forks source link

Unable to use with TypeScript and custom Babel config #14

Closed mattwcole closed 4 years ago

mattwcole commented 4 years ago

Prettier fails to recognise TypeScript when this plugin is installed and a custom Babel config is used.

Steps to reproduce

npx create-react-app my-app --template typescript
cd my-app
yarn add prettier prettier-plugin-import-sort import-sort-style-module -D

package.json:

"importSort": {
  ".js, jsx, .ts, tsx": {
    "style": "module"
  }
}
yarn prettier --write .         # works great, imports sorted
echo {} > .babelrc
yarn prettier --write .         # typescript no longer recognised
yarn remove prettier-plugin-import-sort
yarn prettier --write .         # back to working
mattwcole commented 4 years ago

My mistake, I was missing "parser": "typescript" in the package.json!