2013-02-11 62 views
0

編譯任何代碼bare = falseUnused variable: _thisJShint
結果掉毛它。的CoffeeScript + jshint =未使用的變量:_this

解決方法?
bare = true應該保留,
除了我很高興有jshint檢查未使用的變量。我只想在這裏有個例外。


順便說一句,我也讓你走過jshint寫成的CoffeeScript的

Move the invocation into the parens that contain the function. 
}).call(this); 
+0

你爲什麼指裸露和裸露? – placeybordeaux 2013-02-11 16:23:12

+0

錯字在問題中。 '--bare' – Alex 2013-02-11 16:26:35

回答

1

你爲什麼運行的東西? jshint是不是應該和手寫的javascript一起使用?

如果你真的想使用皮棉工具你爲什麼不使用http://www.coffeelint.org/

最後,這是非常相似的question這裏,這是封閉的作爲是一個真正的問題。

+0

你的代碼是如何產生的?原始文件中也可能出現錯誤。編譯期間的Coffeescript不知道未使用的變量,未定義的變量,camel_case樣式強制以及您的代碼應符合的大量其他選項。 – Alex 2013-02-11 16:28:34

+0

Coffeelint特別不知道已使用/未使用的變量,並擁有1/3提供的jshint選項。包括使用未定義的變量和模塊。 – Alex 2013-02-11 16:57:08

0

如果你真的要貫穿JSHint生成的JS,你可以通過options忽略這個警告,就像這樣:

###jshint node: true, unused: false ### 

其編譯成

/*jshint node: true, unused: false */ 
0

我用下面的.jshintrc settings在我面向瀏覽器的Coffeescript項目中

// be sure to turn off 'devel' before shipping. 
{ 
    "devel": true, 
    "bitwise": true, 
    "boss": true, 
    "browser": true, 
    "camelcase": true, 
    "curly": true, 
    "eqeqeq": true, 
    "eqnull": true, 
    "es3": false, 
    "esnext": true, 
    "forin": false, 
    "freeze": true, 
    "immed": true, 
    "indent": 2, 
    "jquery": true, 
    "latedef": true, 
    "newcap": true, 
    "noarg": true, 
    "noempty": true, 
    "nonbsp": true, 
    "nonew": true, 
    "plusplus": false, 
    "quotmark": "double", 
    "strict": false, 
    "trailing": true, 
    "undef": true, 
    "unused": false, 
    "predef": ["jQuery", "console"] 
}