繁体   English   中英

jslint4java外部jslint选项被忽略

[英]jslint4java external jslint options are ignored

我正在使用phing-drupal-template并且遇到jslinting问题。 当使用带有--jslint选项的外部jslint时 ,也不会识别--browser选项和内联选项

/*jslint browser: true */

任何帮助将非常感激。 谢谢。

java -jar tools/jslint4java/jslint4java-2.0.5/jslint4java-2.0.5.jar
     --browser 
     --predef "jQuery,$,Modernizr" 
     ../sites/all/modules/custom/zendigital/js/frontpage.js



java -jar tools/jslint4java/jslint4java-2.0.5/jslint4java-2.0.5.jar 
     --jslint tools/jslint/fulljslint.js
     --browser
     --predef "jQuery,$,Modernizr"
     ../sites/all/modules/custom/zendigital/js/frontpage.js 


jslint:...frontpage.js:59:40:'window' is not defined.
jslint:...frontpage.js:84:23:'window' is not defined.
jslint:...frontpage.js:104:36:'window' is not defined.
jslint:...frontpage.js:105:23:'window' is not defined.
jslint:...frontpage.js:180:25:'Modernizr' is not defined.
jslint:...frontpage.js:250:65:'window' is not defined.
jslint:...frontpage.js:250:86:'window' is not defined.
jslint:...frontpage.js:278:4:'jQuery' is not defined.

如果您使用规范的jslint文件 ,行为是否存在? 您在四年前分支的那个,尚未更新,似乎并不尊重window

在规范的当前JSLint文件中比较此部分,该文件包含window
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),

...自2010年11月以来,您的版本没有任何更新, 不包含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文件,更不用说已经使用了四年的文件。 您正在使用哪些更改? 将它添加到一个尊重window更新的JSLint版本可能更容易 - 或者使用JSHint来获得相同的更改,如果它们在那里有用的话。 (或者,正如我通常会说的那样,你总是可以接受JSLint的建议。; ^ D)

祝好运。 如果规范版本有效,请告诉我们。


编辑:您可以尝试过时版本的widget设置。 它似乎有window

// 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相关的内容),你真的应该放弃这个fork并更新到当前的规范版本。 这是一个“有趣的实验”,而不是推荐的修复。

您也可以将window: true,插入到browser数组中,但是,再次,您最好在当前版本的JSLint中使用该分支进行编辑,如果有的话使用JSHint,或者只是遵循当前版本的JSLint的建议。

也就是说,我无法使用旧的分支版本复制您使用最小JSLint包装器看到的问题; 它让大量的东西通过。 对不起,希望我能提供更多帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM