Gruntjs 更改grunt jshint的选项

Gruntjs 更改grunt jshint的选项,gruntjs,yeoman,jshint,Gruntjs,Yeoman,Jshint,我有一个由yeomanwebappgenerator创建的web应用程序,其结构如下: myApp app node_modules grunt grunt-contrib-jshint test 我尝试将jshint的quotmark:single“选项更改为quotmark:true,以关闭双引号的错误。我尝试将其设置为: myApp/.jshintrc myApp/node_modules/grunt contrib jshint

我有一个由
yeoman
webappgenerator创建的web应用程序,其结构如下:

myApp
    app
    node_modules
        grunt
        grunt-contrib-jshint
    test
我尝试将
jshint
quotmark:single“
选项更改为
quotmark:true
,以关闭双引号的错误。我尝试将其设置为:

  • myApp/.jshintrc
  • myApp/node_modules/grunt contrib jshint/.jshintrc
但是,运行grunt时,我的更改似乎没有注册:
grunt jshint


我必须在其他地方进行更改吗?

你的Gruntfile看起来怎么样?你应该吃点类似的东西

jshint: {
    options: {
        jshintrc: '.jshintrc' // relative to Gruntfile
    }
}

我发现了我的问题。我有这样的经历:

var myVar = [
  {
    "name": "a name"   //  jshint warning: Mixed double and single quotes.
  }
];
我应该设置的正确选项是
“quotmark”:false
,而不是
“quotmark”:true
,以关闭引号检查,即使我不明白为什么在我的情况下它会成为一个问题

设置此选项的
.jshintrc
文件是:
myApp/.jshintrc


谢谢大家的帮助。我真的很感激

首先,切勿触摸节点_模块中的任何东西。事实上,将编辑器和其他设置为不搜索/列出该文件夹

其次,您应该查看jshint的有效选项:


第三,使用所需的有效选项编辑.myApp/.jshintrc文件。选择单引号或双引号,并在整个项目中坚持使用。这就是它抱怨的原因。

只需仔细检查一下,.jshintrc文件中的
quotmark
是否为
“quotmark”
?是的,
“quotmark”
在my.jshintrc中都是您建议的。首先,不要触摸节点模块中的任何东西。事实上,将编辑器和其他设置为不搜索/列出该文件夹。我有多个grunfile.js:
myApp/grunfile.js
myApp/node\u模块/grunt contrib jshint/Gruntfile.js
…它们都在
grunt.initConfig
中有
jshint
。它们是否包含对
jshintrc
的引用?这就是你需要的谢谢。是的,它们都有对
.jshintrc
的引用,它与Gruntfile.js放在同一个文件夹中。我试图修改
.jshintrc
,但仍然不起作用。