javascript 调试器语句的 MSBuild 编译器警告

MSBuild compiler warning for javascript debugger statement

不止一次我在 javascript 文件中错误地留下了 debugger 关键字,而不是在代码审查中找到(或找不到)这些关键字,我宁愿就像 Visual Studio 构建过程警告我这一点,所以我记得删除它们 - 特别是在发布模式构建中。

同样,可能会有一些关于 console.log 类型代码的警告。

如何为此生成 MSBuild warning/error?

MSBuild compiler warning for javascript debugger statement

就像之前删除的答案中提到的那样,这个问题应该更多地与 Visual Studio 扩展相关,而不是 MSBuild。

您可以使用 Visual Studio 扩展:

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.

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

希望对您有所帮助。