How do I stop Visual Studio Code (VSCode) from linting new, unsaved files?

Viewed 422

In Visual Studio Code (VSCode), I often want to temporarily store some text while coding. A quick way to do this is to hit Ctrl + N (to open a new file in a new tab) and then Ctrl + V (to paste the text). I can then go back to the new tab later on and retrieve the text. This is safer than using the clipboard, because I don't want to accidentally blow it away by copying something else.

However, the ESLint extension for VSCode will automatically detect that I have pasted some JavaScript code into a new file and will immediately start linting it, even though it is a brand new & unsaved file. This clutters up the "Problems" pane with spurious errors.

How do I prevent this from happening?

2 Answers

Search preferences for "Format on paste" or in settings.json enter:

"editor.formatOnPaste": true

The solution is to click on the language icon in the bottom right hand corner, and switch it to Plain Text (plaintext).

This will obviously disable the linter, because it won't be a JavaScript/TypeScript file anymore.

It's also probably possible to make a VSCode hotkey that will do this in one keystroke, but I don't really do this pattern often enough to justify making a custom hotkey for it.

Related