KallDrexx
KallDrexx

Reputation: 27803

How can I disable javascript compile warnings in VS 2010?

Visual studio seems intent that my javascript code is bad, mostly because it has no knowledge of jquery or some plugins I am using. Therefore, every time I compile my product it gives me a lot of warnings, most of them are incorrect ($ is not defined, window is not defined, etc...).

I have /// <reference path="" /> tags setup in my javascript with intellisense working properly so I know these are just not real issues.

How can I disable these warnings?

edit to be clear, I need these disabled because it's causing 100+ warnings that are making me lose sight of REAL c# warnings.

Upvotes: 6

Views: 2453

Answers (5)

johlrich
johlrich

Reputation: 1781

I had the exact same issue you were having: 100s of incorrect errors every save. For me the issue was with Chirpy, which was a prerequisite for another extension. For whatever reason on my end, Chirpy was not in my Extension Manager so it took me a while to find.

Check and see if you have it installed. If so disable JSHint.

  1. Tool -> Options
  2. Chirpy -> JSHint
  3. Uncheck: Run JS Hint

Upvotes: 5

Serenity Stack Holder
Serenity Stack Holder

Reputation: 297

What about this one?

To disable a single compiler warning

With a project selected in Solution Explorer, on the Project menu, click Properties.

Click the Compile tab.

In the Warning configurations table, set the Notification value for the warning to None.

or perhaps this one

Tools > Options > Text Editor > JScript > Misc > Show errors as warnings( uncheck only this )

Upvotes: 0

Esen
Esen

Reputation: 973

Interesting I am not able to reproduce your issue in neither VS2010 "website" project nor vs2010 "web application" project. It has to do with the add-ons that you installed. Probably you may have a setting in that add-on (who ever is causing this) to disable warnings.

To me the warning sounds like the add-on (who ever is causing this) is not intelligent enough. Try the below changes and see if that helps.

  1. If you have master page then try move the jquery*.js script reference from master page to your actual page
  2. Move all your javascript code into a js file instead of writing it them under script tag

Thanks,

Esen

Upvotes: 0

Rob Allen
Rob Allen

Reputation: 2921

try this and let me know if it works.

Enter the options through Tools > Options.

In the tree to the left, choose Text Editor > JScript > Miscellaneous. Uncheck "Show syntax errors".

Upvotes: 4

MCattle
MCattle

Reputation: 3167

I don't have a javascript source file on the computer I'm on at the moment to test this, but you may be able to use the #pragma command to disable particular warnings:

#pragma warning disable will disable all warnings, and #pragma warning restore will restore all warnings when placed at the end of your code block. You can also tell it to disable only particular warnings, such as #pragma warning disable 0219,0168.

http://abhijitjana.net/2010/08/27/how-to-suppress-complier-warning-using-pragma-warning-directives-in-visual-studio/

Upvotes: 1

Related Questions