簡體   English   中英

更改grunt jshint的選項

[英]Changing option for grunt jshint

我有一個由yeoman webapp生成器創建的Web應用程序,具有以下結構:

myApp
    app
    node_modules
        grunt
        grunt-contrib-jshint
    test

我嘗試將quotmark: "single"選項jshintquotmark: true以關閉雙引號的錯誤。 我嘗試將其設置為:

  • 對myApp / .jshintrc
  • 對myApp / node_modules /咕嚕-的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

謝謝大家的幫助。 對此,我真的非常感激!

首先,永遠不要觸摸node_modules中的任何內容。 實際上,將您的編輯器和其他任何內容設置為不搜索/列出該文件夾。

其次,您應該查看jshint的有效選項: http ://jshint.com/docs/options/#quotmark

第三,使用您想要的有效選項編輯.myApp / .jshintrc文件。 選擇單引號或雙引號,並在整個項目中堅持使用它。 這就是為什么它抱怨。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM