Alex
Alex

Reputation: 2875

MSBuild compiler warning for javascript debugger statement

There has been more than one occasion where I have mistakenly left a debugger keyword in a javascript file, and rather than finding these (or not) in code reviews, I'd quite like the Visual Studio build process to warn me about this so I remember to remove them - especially in a Release Mode build.

Likewise, maybe some warnings about console.log type of code.

How can I generate an MSBuild warning/error for this?

Upvotes: 0

Views: 35

Answers (1)

Leo Liu
Leo Liu

Reputation: 76760

MSBuild compiler warning for javascript debugger statement

Just like as mentioned in the previously deleted answer, this issue should be more related to the Visual Studio extension rather than MSBuild.

You can use the Visual Studio extensions:

JSLint for Visual Studio

JSHint for Visual Studio

I'm currently using the JSLint from the link above and it works great. Here are some screen shots of the settings / and my code with an error. It won't prevent you from checking in, there would likely need to be a check-in policy on the TFS server, but it will notify you of the error when you build and save.

Here is the initial page where you can specify how to display the JSLint validation messages. All of the options across the top you can set to your liking. You can cancel the build and run the lint process during save and / or build.

These are all of the specific JSLint rules that you can turn on or off. I have highlighted the debugger rule that you asked about in your question.

enter image description here

Certificate: Don't let check in with “debugger” in Visual Studio 2012

Hope this helps.

Upvotes: 1

Related Questions