My project has a prettier.config.js. My colleagues and I use prettier, and format documents on save.
On my machine, but not my colleague's machines, saving files changes the indentation for multiline code (function arguments, objects, etc). See below.
On my colleagues machines it doesn't - if I give them I file I have saved with prettier, it will change the multiline formatting back.
I have deleted and reinstalled the prettier (esbenp.prettier-vscode) extension and this has not solved the problem.
What is this setting called? I have looked in the prettier docs regarding multiline statements.
Why is prettier using a different setting from prettier.config.js?
Here is a diff, when I saved (and ran prettier) over some vcode that my colleagues have already ran prettier over:
Related
This problem is very weird to describe...
Sometimes null characters are added to the end of the open document.
Other times lines are deleted from the end of the document.
I feel like these must be related in a way.
I cannot reliably reproduce the error. But it seems to be connected to when I save the document since it happens much more frequently when autosave is enabled.
Installed extensions are:
Python,
Jupyter,
GithubCopilot,
R
The problem appears as soon as the jupyter extension is enabled.
The funny thing is I have the exact same setup on my desktop with absolutely no problems.
I tried removing visual studio code and the files created in the following folders:
%APPDATA%\Code and %USERPROFILE%.vscode - along with the other extension files like .jupyter.
Reinstalled everything.
Same problem.
You may install the Prettier extension. Prettier would suggest you add a blank line at the end of files so it may prevent cutting the final line in your saved files. I usually use this method.
You can find it on VS Code Marketplace or the documentation.
I love what prettier does in tandem with eslint. I am glad that we can't push up misformatted code without errors, but is there a way to turn off the complaints in vscode? I don't need vscode giving things a red underline because I hit enter and now something is on a new line that the formatter doesn't like, especially when I have format on save. I would guess that the only solution to this is to remove all linting related to formatting and just have things fixed with the running of formatting in pre commit hooks and github actions...
To add onto this. I think the errors I'm getting come from this plugin included in .eslintrc:
"plugin:prettier/recommended"
When I turn it off the errors go away. My preference would be to find a way to hide these errors in vscode while keeping this plugin
I am using the Python and Pylance extensions in Visual Studio Code for the benefit of syntax highlighting, auto completion and code suggestions.
Whenever I save a file within the workspace, the linter automatically parses the file and makes corrections where necessary, in my case this also adds a large amount of unrequired new lines around my inline documentation.
Here is a demonstration of the above mentioned behaviour after a file is saved:
I have attempted to disable the Python Linter for VSC through numerous methods mentioned in other questions to no avail. Whenever I save a file within the workspace, the linter automatically parses the file and makes corrections where necessary, in my case this also adds a large amount of unrequired new lines around my inline documentation.
settings.json file:
{
"python.linting.enabled": false,
"python.languageServer": "None",
"python.linting.ignorePatterns": [
".vscode/*.py",
],
}
The Linter setting is disabled within my VSC workspace and user settings:
What I don't understand additionally is that I have disabled Lint On Save though this behaviour still persists:
I have confirmed this is definitely behaviour coming from the Pylance/Python extensions, when I disable them the issue goes away.
Turns out the setting editor.formatOnSave in VSC does this globally for all languages and seems to have resolved automatic formatting.
In VSCode is there any way to disable linting for a specific JSON file? Here are some extra words to make StackOverflow happy.
It's not exactly what I wanted, but if you are willing to accept some limitations this kind of works:
Add the following to your settings:
"files.associations": {
"your_specific_file.json": "plain"
}
It's probably best to add it to Workspace or Folder settings rather than global settings. It eliminates linting errors for that file. The downsides are:
All files with that name in the workspace/folder have linting disabled.
You also lose syntax highlighting etc. VSCode treats it as plain text.
My Problem
When I compare two versions of a file with VS Code and the built-in Git features TSLint does not ignore the revisions but marks the errors. Since the diff files are located in AppData\Local\Temp on Windows the path checking fails and other things as well.
However, most annoying is not the red line in the file view but that they are listed in the Problem Panel and I get like 20+ problems just because opening one file revision and they won't go away until I reopen VS Code, so they add up during time.
That makes the panel useless for me, since I see lots of pseudo-problems, I won't notice an actual problem.
What I tried
I tried in my settings.json
"tslint.exclude": ["**/AppData/**"]
but that didn't work out.
Any suggestions would be much appreciated.
Well, it appears that this is an issue with the GitLens extension which will be fixed with the upcoming version:
this issue has been fixed in the GitLens 9 release which will be coming very soon.
~ eamodio
(Source: https://github.com/eamodio/vscode-gitlens/issues/430#issuecomment-440731347)