如何使用JsHint" .jshintrc"与Visual Studio 2013的Web纲要扩展文件?纲要、如何使用、文件、QUOT

2023-09-03 02:25:17 作者:穿着校服闯天下

我已经安装了网络要点扩展到Visual Studio 2013年。我现在越来越出现在我的错误列表窗口下的消息部分JSHint警告。然而,它抱怨一些它认为没有定义的全局变量

I have installed the "Web Essentials" extension into Visual Studio 2013. I am now getting JSHint warnings appearing in my "Error List" window under the Messages section. However, it is complaining about some global variables that it thinks are not defined.

从我读,你可以使用JSHint的.jshintrc文件中列出的全局变量,因此将停止抱怨他们。我想把它设置如下。 (这样它就会不停抱怨KO......这是一个KnockoutJs全局变量。)

From what I read, you can use JSHint's .jshintrc file to list global variables so it will stop complaining about them. I want to have it set up as follows. (so that it will stop complaining about "ko"... which is a KnockoutJs global variable.)

"globals": {
    "$": false,
    "jQuery": false,
    "ko": false
 }

如何以及在哪里你应该在你的VS项目创建这个.jshintrc文件?

我尝试添加该项目的根目录下的文件,硬是将其命名为.jshintrc,但Visual Studio中抱怨说:

I tried adding the file in the root of the project, naming it literally as ".jshintrc" but Visual Studio complains saying that:

"File and folder names cannot contain a leading period."

我似乎无法找到有关如何将此文件添加到您的Visual Studio项目,以便Web纲要扩展将它捡起来的任何文件。

I can't seem to find any documentation about how to add this file into your Visual Studio project so that the Web Essentials extension will pick it up.

任何想法?

更新

六角有正确的答案。我不得不打开命令提示符来重命名文件,Windows资源管理器不会让我的名字开始的一段是文件。在那之后,我也跟着十六进制的周围整个事情在大括号中的建议。这里是我的.jshintrc文件....我已经坐在我的Web应用程序的根文件夹中的内容......与其他文件,如web.config文件。

Hex had the correct answer. I had to open a command prompt to rename the file, as Windows Explorer wouldn't let me name a file starting with a period either. After that, I also followed Hex's advice on surrounding the entire thing in curly braces. Here are the contents of my .jshintrc file.... which I have sitting in my WebApp's root folder... alongside other files like web.config.

{
    "globals": {
        "$": false,
        "jQuery": false,
        "ko": false
      }
}

我不再获得千万有关KO的对象不必要的警告。 :)谢谢六角!

I no longer get 10 million unnecessary warnings about the "ko" object. :) Thanks Hex!

推荐答案

项目的根是好的。我的事情JsHint是一路寻找文件,文件系统的顶部。

Project root is fine. I thing JsHint is searching for file all the way to the top of filesystem.

您可以使用命令行创建文件。 只是用你最喜欢的工具创建文件,然后像仁jshintrc .jshintrc

You can create file using command line. just create file using your favorite tool and then rename it from cmd like "ren jshintrc .jshintrc"

此外,我发现,我需要重新启动VS它的负载变化jshintrc文件。

Also I found out that I need to restart VS for it to load changes in jshintrc file.

如果它仍然没有工作试图把整个文件中{}。我不知道这是否是必需的,但我在其他地方看到它。

If it's still not working try to put whole file in {}. I'm not sure if it is required but I see it elsewhere.