6

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.

KallDrexx
  • 27,229
  • 33
  • 143
  • 254
  • 1
    possible duplicate http://stackoverflow.com/questions/4712058/how-to-enable-disable-compile-errors-warning-in-visual-studio – CyprUS Apr 26 '12 at 14:00
  • I need to disable the warnings, not what happens when an error happens – KallDrexx Apr 26 '12 at 14:04

5 Answers5

5

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
johlrich
  • 1,771
  • 1
  • 12
  • 11
4

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".

Rob Allen
  • 2,871
  • 2
  • 30
  • 48
  • Well that's annoying. That even turning that off every time I save it still generating the warnings. – KallDrexx May 04 '12 at 15:07
  • what kind of add-ons do you have installed? I've noticed some horrible things happening with various add-ons – Rob Allen May 07 '12 at 21:07
  • I only have the jscript editor extensions (which I uninstalled and still got the issue) and nuget. Although I didn't try uninstalling then unchecking that option, let me try that. – KallDrexx May 08 '12 at 12:40
  • Nope, even without jscript editor extensions those options still don't take effect :( – KallDrexx May 08 '12 at 12:43
1

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/

MCattle
  • 2,897
  • 2
  • 38
  • 54
0

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

Esen
  • 973
  • 1
  • 21
  • 47
0

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 )