如果您使用canonical jslint file,行爲是否存在?你連接的那個在四年前分支了,沒有被更新,並且似乎沒有尊重window
。自2010年11月,它沒有按您的版本沒有任何更新
https://github.com/douglascrockford/JSLint/blob/master/jslint.js#L343
// browser contains a set of global names that are commonly provided by a
// web browser environment.
browser = array_to_object([
'clearInterval', 'clearTimeout', 'document', 'event', 'FormData',
'frames', 'history', 'Image', 'localStorage', 'location', 'name',
'navigator', 'Option', 'parent', 'screen', 'sessionStorage',
'setInterval', 'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
], false),
...這一點:
比較規範,目前JSLint的文件本節中,其中確實包含window
不包含window
。
https://github.com/mikewest/JSLint/blob/master/fulljslint.js#L340
// browser contains a set of global names which are commonly provided by a
// web browser environment.
browser = {
addEventListener: false,
blur : false,
clearInterval : false,
clearTimeout : false,
close : false,
closed : false,
defaultStatus : false,
document : false,
event : false,
focus : false,
frames : false,
getComputedStyle: false,
history : false,
Image : false,
length : false,
location : false,
moveBy : false,
moveTo : false,
name : false,
navigator : false,
onbeforeunload : true,
onblur : true,
onerror : true,
onfocus : true,
onload : true,
onresize : true,
onunload : true,
open : false,
opener : false,
Option : false,
parent : false,
print : false,
removeEventListener: false,
resizeBy : false,
resizeTo : false,
screen : false,
scroll : false,
scrollBy : false,
scrollTo : false,
setInterval : false,
setTimeout : false,
status : false,
top : false,
XMLHttpRequest : false
},
我還沒有研究--predef "jQuery,$,Modernizr"
可言。
我不會建議一般使用相對匿名分支的JSLint文件,更不用說坐了四年的文件。你正在使用哪些變化?將它添加到更新的JSLint版本中可能更容易,該版本尊重window
- 或者使用JSHint獲取相同的更改(如果它們有用且存在)。 (或者,正如我通常所說的那樣,你總是可以採取JSLint的建議;^D)
祝你好運。讓我們知道規範版本是否有效。
編輯:您可以試着widget
設置爲您出的最新版本。 That appears to have window
in it:
// widget contains the global names which are provided to a Yahoo //
(fna Konfabulator) widget.
widget = {
alert : true,
animator : true,
appleScript : true,
beep : true,
//...
Window : true,
XMLDOM : true,
XMLHttpRequest : true,
yahooCheckLogin : true,
yahooLogin : true,
yahooLogout : true
},
這就是說,你在這一點上,以便非標準(widget
是不當前JSLint的指令,並含有大量的Konfabulator相關的克魯夫特的),你真的應該拋棄這個叉子更新到當前的規範版本。這更像是一個「有趣的實驗」而非推薦的修補程序。
你也可以只插入window: true,
到browser
陣列,但同樣,你最好讓你在JSLint的當前版本的分支所需要的修改,使用JSHint如果有他們,或只需遵循當前版本的JSLint建議即可。
這就是說,我不能複製你看到的與舊的分支版本a minimal JSLint wrapper的問題;它讓大量的東西通過。對不起,希望我能更有幫助。
規範版本按預期工作。謝謝!它是Jenkins CI的一部分,我使用的[在上面鏈接]的build.xml包含這個舊的jslint分支。我也會試試JSHint。原來的jslint太傷人了。 thx再次。 – zsd 2015-03-03 20:20:41
太棒了!很高興工作。與JSLint一起追溯到很久很有趣。 – ruffin 2015-03-04 15:41:37