-1

Note there is a very similar question here but that is asking about ESLint, which is a completely different thing.

I would like to be able to disable the built-in Javascript validation for only one line. This kind of thing:

Javascript error

I do not want to disable it globally, and I am not using ESLint.

6
  • Try adding // @ts-ignore before that line Commented Dec 10, 2024 at 9:46
  • That works for type errors, but not e.g. syntax errors. If you change asdasd to == you still get Expression expected. even with // @ts-ignore. Commented Dec 10, 2024 at 9:55
  • 1
    Javascript per se doesn't do any such validation. It's some linter in your IDE. How exactly that can be disabled depends on the exact linter being used. Commented Dec 10, 2024 at 9:59
  • It's the built-in Javascript validation in VSCode, per the title. Commented Dec 10, 2024 at 10:02
  • 1
    @jabaa: That documentation is a bit misleading. See this later sentence: "You can leverage some of TypeScript's advanced type checking and error reporting functionality in regular JavaScript files too." Typescript support is built in, and it can be used to check Javascript. Commented Dec 11, 2024 at 14:44

1 Answer 1

-1

I'm not sure why do you want to do that. If you just want to put a marker or placeholder in a javascript file without VSCode freaking out, try using javascript compatible syntaxes.

For instance:

const a = 1;

// the following code does nothing
`
whaterver
`

console.log(a); // 1

Then you could replace or do anything to `whaterver` without breaking the code.

Or even better, put it in a comment block.

Sign up to request clarification or add additional context in comments.

5 Comments

It's templated data. It can't go in a comment or a string.
I don’t see why it can’t. When replacing the template, removing the delimiters all together. It’s much easier this way, or you would probably need some kind of extension to do that.
Because the template language I am using is Jinja2-like. It has to be {{foo}} which is not valid Javascript. I'm not just doing my_template.replace_all("whatever", ...
Sounds like an XY problem, you should've mentioned that in your original question.
It's not. You've given an XY answer; you think I should have been asking a different question. But you're wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.