Comments (6)
It looks like I am not able to reproduce this behavior anymore.
I reinstalled the plugin and tried running prettier from the command line like you said and it worked.
After that, I tried auto-formatting by saving again but it worked without any error. Really odd.
I reinstalled my OS in the last few days because I had problems with the update and that seems to have fixed it for now.
I will reopen the issue if I am able to reproduce this again. Thanks for your help!
from prettier-plugin-organize-imports.
Just looking at the call stack, it looks like the code that causes this is part of the TypeScript lib (processCommentPragmas
). All this plugin does is call organizeImports
of the TypeScript language service, so I wonder whether you run into the same issue when you use the "Organize Imports" action via the command palette (Ctrl + Shift + P)?
Is it a very large file that you're trying to format? You wouldn't be able to provide the file for debugging purposes, would you? Otherwise I'm sorry but I think this is out of my hands as the issue is most likely upstream (https://github.com/microsoft/TypeScript/blob/master/src/services/organizeImports.ts).
from prettier-plugin-organize-imports.
So sorry! Didn't see you replied to the issue. I usually check my notifications every day multiple times.
Must have skipped that.
I tried using the organizeImports
option from the command palette and it works fine.
I am not trying to format a large file. I can even create a new empty file and I will get the same result.
from prettier-plugin-organize-imports.
Hm ok, however I'm sorry but I'm not able to reproduce this. I don't have a Windows machine around.
I've added cross-platform matrix testing to the CI now to make sure the plugin code works on all platforms. It does: https://github.com/simonhaenisch/prettier-plugin-organize-imports/actions/runs/468671986.
The only thing I can think of is that it's an issue with the TypeScript version in your project. From looking at your log file I can tell that VS Code is not using the built-in TypeScript version but the one that's locally installed into your project. Which one is that? Also, which Node version are you on?
from prettier-plugin-organize-imports.
I am using Windows 10 Pro but my whole development environment is sitting in the WSL 2 environment which is running Ubuntu 20.02.
I am running TypeScript 4.1.3 in my project.
Node is running on 15.5.0.
from prettier-plugin-organize-imports.
Ok I'm using similar versions (same prettier, same plugin, same typescript, and Node 15.3), and everything works fine for me (however I'm on macOS).
What you can try to do is invoke prettier
from the command line in your project:
npx prettier --write path/to/some/file.ts
If that runs into the same issue, then at least we know it's not related to VS Code. In that case, can you also try to create a clean project and see whether it reproduces?
mkdir organize-imports-test
cd organize-imports-test
npm init -y
npm install --save-dev prettier prettier-plugin-organize-imports
touch file.ts
npx prettier --write file.ts
from prettier-plugin-organize-imports.
Related Issues (20)
- Sorting behavior inconsistent with prettier HOT 3
- How to disable this plugin? HOT 1
- Prettier 3 support HOT 3
- Cannot find module 'typescript' when adding this plugin to .prettierrc HOT 2
- Bug or feature? Once I type blank line between imports, imports are sorted within that group HOT 2
- Unable to auto-format imports in Vue SFCs HOT 4
- New typescript 5.0.0 `export type *` syntax not supported HOT 2
- Feature request: configurable import sort order HOT 3
- How to disable this plugin explicitly? HOT 1
- Imports may get removed if using Prettier range-start/range-end options HOT 22
- Sorting does not work if newline between imports HOT 1
- Imports get removed on save HOT 2
- Prettier much slower when using this plugin HOT 3
- Organize imports in Angular standalone components HOT 1
- Adding this plugin breaks github actions HOT 2
- Sort default imports and named imports HOT 1
- I would like to ask the author, this plugin collation and later support custom collation? HOT 1
- Using this plugin can be devastating for some types HOT 2
- Support for CommonJS HOT 1
- import 'reflect-metadata'; Needs to be the first/top import to work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier-plugin-organize-imports.