Manjar
Manjar

Reputation: 3268

Don't let check in with "debugger" in Visual Studio 2012

I got a tricky question.

In our work we use a lot the Js debuggers, I mean:

<script>
debugger;
</script>

The problem is that we are not supposed to check-in it to the TFS, so I'm wondering if there is someway to check my .js files to see if there are "debuggers" and if so stop the check-in.

Do you have any magical idea?

Thank you all!

Upvotes: 1

Views: 133

Answers (1)

drneel
drneel

Reputation: 2907

There are several extensions that give you JSLint functionality that scans your javascript files for errors. Two that I have used are JSLint and JSHint.

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.

JSLint Options Page 1

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.

JSLint Options Page 2

I added a debugger statement to my javascript to show that it will show up in the error window.

Sample Javascript Debugger Statement

The error window which has caught the debugger statement and treated it as an error.

Example of Error Window Showing Debugger statement

Upvotes: 1

Related Questions