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.
Related
I recently started writing SCSS in VSCode. VSCode itself along with vscode-scss extension provides relatively good support for SCSS, but an important feature seems missing - error checking.
Though VSCode and vscode-scss can offer suggestions through Intellisense based on scanning, no errors will be prompted if I misspelled a variable, or used a mixin that hadn't been imported yet. Also, no auto refactoring takes place after renaming an SCSS file that has been used by other sources.
Is there any VSCode extension that provides such validations? Or maybe they can be turned on through some options in extension settings?
Note: I do have noticed the scss.showErrors option of vscode-scss, but no errors get prompted in scenarios mentioned above after turning this option on.
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 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.
If I start an .ejs file with a tag like h1, it is underlined in red, like VSCode expects me to add the whole typical html boilerplate. However, I have seen many videos where the host doesn't get this underlining.
I have tried extensions, I have modified the settings.json with "*.ejs": "html", but nothing works.
Do you know how I can get rid of it without having to add DOCTYPE, , etc.?
So after figuring out that this problem caused by a lint or other validator (in this case W3C Validator) installed as an extension in Visual Studio Code, you can disable its warnings by going to extensions and disable the validator.
However, those tools are here for a reason :) and they help us write better code that fits to known standards and syntax issues, so disabling them is less recommended. (Although it can become bit annoying while using external third-party libs which can be can some warnings by that validator too - for that, some lints offers ignoring logic which let you ignore some of the files or lines in the code).
Good Luck, Happy coding!
Is there any way to override global settings only for a specific file format, like disabling IntelliSense for the .txt and .md only, and leave it enabled for everything else?
I know there is a lot a issues filed in the vscode repository regarding disabling IntelliSense for the .txt files, but there is a global option
editor.wordBasedCompletion: false
which could do this globally. Is there a way to override it for the .txt only?
UPD. Looks like there is no possibility built-in, but there is a feature request here
https://github.com/Microsoft/vscode/issues/11879
Please go vote for the issue, so they'd implement it faster.