VS Code - Prettier is formatting differently for me than others - visual-studio-code

Prettier is behaving differently for me compared to my team mates.
We all have same version 9.5.0 of prettier installed on our VS Code.
We all have same configuration of prettier.
Still it is formatting my typescript file differently for one particular line than others and because of this the deployment is failing when I push anything from my machine and works for everybody else.
Does anybody face this?
Which part should I check to see the difference?
Update 1
One thing we found that is different is the VS Code version.
I have version 1.67.2 installed my colleague has 1.63.2 installed.
Could this be the reason?
Update 2
This is the exact line where I am getting prettier error on my machine for wrong formatting while this same formatting is considered correct by prettier for other machines
And this is how prettier formats the line on my machine (then devops complaint that it is a wrong formatting)

I think there is a bug with the prettier extension. Although I had my default formatter set to the prettier extension in the settings UI, I had to re do it manually.
Open any file, right click in the editor screen, click Format document with and choose Prettier - Code formatter.
The local prettier config and the one vscode uses should work now

I faced the same isssue.
in my case I run
npx prettier --version
on both computer and each one return different prettier version.
so although the prettier extension in vscode was 9.5.0 for both pcs. the npm module installed for the project in node_modules was different.
I installed the same prettier module for both computer and the restart vscode and problem solved

You might have installed multiple formatters and you aren't using the correct one. Try to specify it manually in command palette. Check out this answer (Solution A)

Related

Prettier not working on VScode tried everything from stackoverflow still nothing happened?

Prettier not working on VSCode
I have been using prettier for java on vs code from very long everything was working smoothly till yesterday and suddenly prettier stopped working for java.
I have tried every available resource on Youtube and Stack Overflow still didn't solve my issue, please help.
I tried from changing default formatter and format on save to settings.json still now working showing error - FormattingExtension 'Prettier - Code formatter' is configured as formatter but it cannot format 'Java'-files
Normally this happens when you have another extension overlapping the prettier settings. Disabling other extensions normally solves the problem. Reinstalling visual studio can be your best option, but you have to remove all remaining settings, or it will just be the same.
You can always install directly in terminal using: https://prettier.io/docs/en/install.html
Confirm on extensions that prettier is enabled. Update Visual Studio and Windows.

The prettier extension will use 'node_modules/prettier/index.js' for validation

I have Prettier extension installed in my VS Code. Up until the last update everything worked fine, and now I am prompted with this question:
The Prettier extension will use 'node_modules/prettier/index.js' for
validation, which is installed locally in folder 'my_project_folder'.
Do you allow the execution of the Prettier version including all
plugins and configuration files it will load on your behalf?
Press 'Allow Everywhere' to remember the choice for all workspaces.
If I decline it, the Prettier formatting will not work.
Why am I prompted with this since I have Prettier installed as an Extension and not as npm package?
it is the VS Code extension and not some npm package?
The opposite is true. Prettier is not a VS Code extension. The extension is a bridge (integration) between your editor and the Prettier package installed in the project. In different projects, different versions of Prettier are installed, so to make sure all the collaborators get the same formatting, the local version must always be used. On the other hand, running code from node_modules in VS Code is a certain security risk (e.g., think of a malicious fork of Prettier), so the extension makes the user aware of that. You didn't see this prompt before because it has been added recently.

Couldn't start client ESLint message in VS Code

Recently I run into problem with ESlint extension in VS code. When I launch VS code and open up a js file, it popup message "Couldn't start client ESlint". It used to work fine. I tried to re-install eslint, VS code but it didn't help. Here are the versions I used.
VS code: 1.44.0 (user setup)
eslint: v6.8.0
ESLint Extension for VS code: 2.1.2
You need to dig a little bit more to get more details.
A good place to start would be to run the eslint show output command in VSCode. That should be a good starting point.
screenshot of ESLint: Show Output Command
The bottom line is that you need to follow the conventional installation path:
add eslint extension in vscode.
install eslint locally or globally via npm,
run eslint init in your project path and select proper configurations.
restart vscode just to make sure the settings are active.
again, the eslint output console should be a good starting point.
For me, it turns out I had the eslint.runtime and eslint.nodePath settings set to the specified node path on my system, but they were prefixed like this:
~/.nvm/versions/node/v14.17.0/bin/node
Using $HOME instead of ~ didn't solve it either.
I ended up having to specify an absolute path:
/home/<myusername>/.nvm/versions/node/v14.17.0/bin/node

Latex file on vs code does not autocompile on save

I use the extension Latex Workshop, however my preview does not auto update on save. I have to run pdflatex each time.
I tried uninstalling and installing the extension, deleting the extensions file, and even reinstalled vs code. Yet, the same thing persists.
Is there a specific setting, etc that needs to be changed?
Strangely for me it only seems to work when configuring
latex-workshop.latex.autoBuild.run: "onSave"
As from here the setting for this is:
latex-workshop.latex.autoBuild.run
With value "onFileChange".
Note that this is the default value for this setting, so it should detect the changes automatically, but give it a try.
Local and ssh installation:
For me the problem was that I had Latex Workshop installed on SSH but not locally. After installing locally, the LaTEX icon showed up and also auto-compile on save worked right away.

VSCode - TypeScript language service died unexpectedly 5 times in the last 5 minutes

This error message keeps sliding down from the top every few seconds. I click on the close button and it comes back again. I am not and don't plan on using TypeScript in any of my projects.
Is there a way to "silent" this warning message?
Is there a way to change the frequency that the warnings slide down on the screen?
This is happening in VSCode 1.8.1 and 1.9 on Windows 10 and Windows 8.
I work on TypeScript for VSCode.
The TypeScript language service powers language features for both TypeScript and JavaScript code. Without it, you do not get any suggestions or intellisense or any other nice language support.
Please open an issue against VSCode if you are seeing this error. You can also try upgrading the version of TypeScript that VS Code uses to pick up the latest fixes and features: https://code.visualstudio.com/Docs/languages/typescript#_using-newer-typescript-versions
(I'm also looking into a better way to handle this message since it can be very spammy when the TypeScript service crashes continually)
I resolve my problem by use this way:
first, open your typescript.tsserver.log to "verbose"
restart vscode, and open ts log
and you will find when make your tsserver so slow, as for me, jest_cache is the problem. so I add a exclude in my tsconfig.json
restart, and the problem solve.
I the same problem with VSCode using a workspace Yarn and Typescript. After a couple months without a solution, I tried updating the Yarn VSCode SDK using yarn dlx #yarnpkg/sdks vscode as part of these instructions and that fixed my problem.
you can try to install this vscode extension to make vscode use latest typescript version
To people getting here using WSL2 & Ubuntu(?)
rm -rf ./vscode-server worked for me
Disabling the "JavaScript and TypeScript Nightly" extension worked for me.
The error always said that the workspace was using an old verison of typescript and that I should upgrade although I was up to date. It looks the workspace was using the latest dev build of typescript because of the extension or something like that maybe caused the error.
For a temprary solution you need to rollback to an older version. In my case it worked with: https://code.visualstudio.com/updates/v1_39.
upgrading to TypeScript v3.7.3 and using VSCode Insider's Edition seems to fix the issue for me.
There are multiple ways to upgrade. One way is:
yarn add -D typescript#3.7.3
https://github.com/microsoft/vscode/issues/84618#issuecomment-562290275
Here is my solution which I spent 1 week.
Fallback version to Version: 1.61.2 (Universal)
Rmove your local VsCode totaly.
quit it
remove it from your Application folder
remove the file ~/.vscode
rm -rf ~/.vscode
Install the vsCode v1.61.2 and open it;
Close the aoto update. it's important
find the menu Code > preferences > settings
search keyword of update
set Application/Update/update > mode > none
Open your ts project
Hope help you
took me a few confusing days, as it kept trying to default to 16.8 which I had not installed via nvm
I installed and un-installed 16.8, set the default and system aliases (always alias to a version number without any letters ['v']
Finally I found a posting that said, no matter what you have installed for nvm MacOS will always use the system Node if there is one.
So: brew uninstall node got rid of a version that I didn't was on my mac... I've been using nvm for many years, so I don't know how it got there. Perhaps it came in as a dependency...
Since I use nvm, and always want the typescript support I pinned it to a particular version of node that I know has typescript installed globally
tsdk: /Users/ajoslin/.nvm/versions/node/v16.14.0/lib/node_modules/typescript/lib/
In my case, I didn't have the typescript compiler (tsc) installed on my system. So npm install -g typescript resolve my problem.