你如何使用JsHint ".jshintrc"带有 Visual Studio 2013 Web Essentials 扩展的文件? [英] How do you use JsHint ".jshintrc" file with Visual Studio 2013 Web Essentials extension?

查看:20
本文介绍了你如何使用JsHint ".jshintrc"带有 Visual Studio 2013 Web Essentials 扩展的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Web Essentials"扩展安装到 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 Essentials 扩展程序将其选中的文档.

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.

有什么想法吗?

更新

Hex 给出了正确答案.我不得不打开命令提示符来重命名文件,因为 Windows 资源管理器也不会让我命名以句点开头的文件.在那之后,我也遵循了 Hex 的建议,用花括号将整个事物包围起来.这是我的 .jshintrc 文件的内容....我在我的 WebApp 的根文件夹中...与其他文件(如 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"对象的 1000 万条不必要的警告.:) 谢谢十六进制!

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.

您可以使用命令行创建文件.只需使用您喜欢的工具创建文件,然后从 cmd 重命名它,例如ren 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.

这篇关于你如何使用JsHint ".jshintrc"带有 Visual Studio 2013 Web Essentials 扩展的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆