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.
Related
If this is due to an extension, how can I remove that extension?
It overwrites my custom snippet, which bothers me.
I disabled many extensions, but nothing changed.
What you're seeing in your screenshot (suggestions for dba_<etc.>) are not coming from any extension. One can verify that by running the command Developer: Reload With Extensions Disabled and trying triggering suggestions again. So this is just functionality that comes out-of-box with a standard VS Code installation. You don't even need to install any PHP extension to get this.
As for your custom snippets getting "overwritten", it's hard to tell without more detail why this is happening. If you're on version 1.75, it might just be due to a bug that will be fixed later (Ex. As was the case in this other recent Q&A: Visual Studio Code's recent update is disrupting autocompletion).
As #Mark showed in their answer, these are function suggestions. You can disable function suggestions with the following setting:
"[php]": {
"editor.suggest.showFunctions": false
}
Those icons indicate that those are Methods and Functions (not Snippets). See What do the Intellisense icons mean.
So you can try to disable two settings in your Settings UI:
Editor > Suggest: Show Methods
Editor > Suggest: Show Functions - this looks like the right one to disable
Of course, there might be situations where you want to see Function suggestions, so you will have to see if disabling the setting is acceptable.
You can disable those Function suggestions for php files only with this setting (in your settings.json):
"[php]": {
"editor.suggest.showFunctions": false
}
I have a legacy system that uses Razor templating.
When I open *.cshtml files in VSCode, I get linting errors reported in VSCode even though it's ultimately valid JavaScript.
Here's an easy example: Whatever linter it is complains I'm using "experimental decorators". I'm not.
Experimental support for decorators is a feature that is subject to change in a future release.
Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.`
It's a Razor comment, which is completely legit here:
#* If MathJax wasn't successfully loaded from cdn1, use the second: *#
I have eslint installed. I use that to lint "real" JavaScript files. That, with the VSCode eslint extension, works perfectly. And I don't mind having JavaScript linting in html, but whatever's running doesn't seem to be eslint.
I tried essentially following the instructions in the error & creating a jsconfig.json file with an ignore in it, but this did not seem to work either.
{
"compilerOptions": {
"target": "es6"
},
"exclude": ["**/*.cshtml"]
}
Perhaps I borked the glob? (I tried a few -- just *.cshtml, ./**/*.cshtml).
At any rate, I have no idea what's doing this linting. I searched my settings file (in raw JSON) for javascript and js and didn't find an obvious culprit there.
What linter is this? How do I make it cshtml aware? Or how do I turn linting off for *cshtml (and in this way, at least, my question is different than this question) completely?
Answering my own question for now with a workaround/less than perfect solution...
Looks like the setting to kill it is:
"html.validate.scripts": false,
I would still prefer to have scripts validated in a Razor template-aware way.
How to edit settings directly
Add this text to settings by...
Typing ctrl-p (cmd-p on macOS),
Typing JSON, and
Selecting Preferences: Open Settings (JSON).
Paste the snippet into the file that was opened.
Note: These reported errors may have been complicated by my mapping *.cshtml to *.html for it to otherwise be treated as html:
"files.associations": {
"*.cshtml": "html"
},
I have not yet tried removing that mapping to see if the script validation would continue.
Hat-tip
Hat-tip to this answer, which mentioned:
You can disable JavaScript build-in validation with "javascript.validate.enable": false in settings.json and then enable either ESLint or JSHint extensions to fine-tune errors and validations.
Just needed to edit that to its html equivalent.
I would like to disable linting for cells in the interactive window in Visual Studio Code.
I don't see how it is beneficial, since it is not possible to manipulate cells which have already been run (which is different from *.ipynb notebooks). I believe the linting inside the interactive window is a new feature, since it only started a while ago. Currently the only way to remove the linting warnings is removing the cells.
My workflow is usually as follows: I write *.py files and execute them using the "Jupyter: Run Current File in Interactive Window" command, so I can access the variables and experiment.
I already tried adding the following settings to my settings.json file:
"python.linting.ignorePatterns": [
"Interactive*",
"*.interactive"
],
This is what it looks like:
This behavior was treated as a bug and will be resolved in future releases. See here:
https://github.com/microsoft/vscode-jupyter/issues/8289
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.
I checked previous questions on SO here and here and VS Code's issues here and here.
I still don't know how I can comment jsx syntax in VS Code by cmd + /. I tried syntax JavaScript React and JavaScript Babel and add:
"files.associations": {
"*.js": "javascriptreact"
},
into user settings. Nothing helped. When I check Developer Tools, there are no error messages.
recording
If you have Babel ES6/ES7 plugin installed, disable it. Editor comments .jsx syntax by // instead of {/*. You see see the issue here.
It works for me, Remember Atom has this behavior, but VSCode looks a bit intelligent around this area.
I have no custom file associations defined. Also I am on the latest version of VsCode. Make sure you have no additional addins that takeover and change the behavior