Shazron
Shazron

Reputation: 2488

How do I make the Visual Studio Code linter ignore a line?

For example this, at the top of a node.js source file:

#!/usr/bin/env node

...or unused local variables, etc.

Upvotes: 24

Views: 87306

Answers (5)

Radi Totev
Radi Totev

Reputation: 99

You can select suggestion from PROBLEMS by hovering over the red x in the circle and then click on the lamp :

enter image description here enter image description here

Upvotes: 3

Mugshep
Mugshep

Reputation: 828

You can do this via inline - e.g.: // eslint-disable-next-line [RULE] on the line prior to the line of code you want it to ignore. The RULE is optional, and will tell it to ignore a specific rule; if you don't specify one, it will tell it to ignore all rules.

Lots of other options available - see the docs for more detail: https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments.

Upvotes: 0

distante
distante

Reputation: 7005

Late to the party but in VSCode you can write // @ts-ignore just before the line you want to ignore.

enter image description here enter image description here

It is important to notice that it will just ignore the line after the declaration.

enter image description here

There is more info about it in the official documentation.

Upvotes: 48

AJ Morris
AJ Morris

Reputation: 1109

You can tell jshint to ignore lines, or just certain rules. Here's how to ignore a line, from http://jshint.com/docs/

// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be ignored by JSHint.
/* jshint ignore:end */

Now, I'm just assuming that Code honors these directive.

Upvotes: 3

Sofian Hnaide
Sofian Hnaide

Reputation: 2364

For unused local variable, you can configure the user or the workspace settings.

From the preference menu item, choose user/workspace settings:

// Place your settings in this file to overwrite default and user settings.
{
    // Unused local variable.
    "javascript.validate.lint.unusedVariables": "ignore"
}

As for #!/usr/bin/env node what is the undesirable behavior that you want disable?

Upvotes: 6

Related Questions