Is JSLint available for offline use?

前端 未结 17 1723
暖寄归人
暖寄归人 2020-12-29 23:36

I\'d like to use JSLint, but I am wary of tools that have access to my unfiltered source code. Is there an offline version or is there another similar tool that does \"

相关标签:
17条回答
  • 2020-12-30 00:13

    YSlow for Firebug has this feature built in

    0 讨论(0)
  • 2020-12-30 00:15

    If you like the JSLint web interface, you can do File > Save Page As... and Save as type: Web Page, complete (in Firefox, doing it in Internet Explorer may be slightly different) to a local folder.

    I change the name to jslint.htm to get it under 8.3 with no spaces.

    It seems to work when saved locally.

    Three things:

    1. This may violate his license, although I leave the Copyright intact and don't modify any of his code, and technically my web browser already created a copy of his site on my local HD, so I'm not sure whether I'm in violation or not and I'm not a lawyer so I'll keep doing this until I get a letter telling me to stop.
    2. The page may somehow still be able to send your code to the Internet, although the chance of it being possible is very remote. That said, the WSH or Rhino versions could probably send the code you submit to the Internet easier than a version in a locally saved web page could (if you're paranoid).
    3. You'll get behind on any bug fixes or updates Douglas does. But the same thing applies to the WSH or Rhino versions if you don't update them regularly.
    0 讨论(0)
  • 2020-12-30 00:15

    There's another JS Linter, called JavaScript Lint, that has both online and downloadable command line versions. I use the downloadable version all time. I've been thinking about integrating it into SVN as part of a hook. I like it better than JSLint because it has more options and seems to detect more things. It can be configured to treat certain identifiers as predefined, for toolkits and the like, which allows it to check for usage of undefined variables, which I'm pretty sure JSLint can't do.

    0 讨论(0)
  • 2020-12-30 00:16

    Try the Google Closure Linter. It has more features than JSLint, too.

    0 讨论(0)
  • 2020-12-30 00:16

    It's pretty easy to recreate what Crockford has on JSLint.com. JSLint.com's online version of the .js is a minified conglomeration of a few files that includes some overhead I don't quite understand, like that ADSAFE stuff. Let's strip it down to a simplest case wrapper instead.

    Building your own HTML wrapper for JSLint:

    Here's the code to a web page that'll look for jslint.js (the latest version of JSLint can currently be found in github here as raw text) in the same directory and fire away in a similar fashion as JSLint.com does now.

    <html>
        <head>
            <script src="jslint.js"></script>
    
            <script>
                function jslintalizeMe()
                {
                    var i, divOut, errs, errsMsg = "";
    
                    divOut = document.getElementById("errors");
                    divOut.innerHTML = "";
    
                    if (!JSLINT(document.forms[0].elements[0].value))
                    {
                        errs = JSLINT.errors;
                        for (i=0; i < errs.length; i++)
                        {
                            err = errs[i];
                            if (null !== err)
                            {
                                if (undefined !== err.id)
                                {
                                    errsMsg += "Error: " 
                                    + err.code 
                                    + " -- line " 
                                    + err.line 
                                    + " char " 
                                    + err.character + "<br />"
                                    + "    " 
                                    + err.evidence + "<br />"
                                    + "    " +
                                     err.reason + "<br /><br />\n";
                                }
                                else
                                {
                                    errsMsg += err.reason;
                                }
                            }
                        }
                        divOut.innerHTML = errsMsg;
                    }
                }
            </script>
    
        </head>
    
        <body>
    
            <form>
                <textarea rows="24" cols="80"
                    placeholder="// Paste quality code here"></textarea>
                <br />
                <button onclick="jslintalizeMe();return false;">JSLint</button>
            </form>
    
            <div id="errors"></div>
        </body>
    </html>
    

    ^ From an old blog post of mine.

    It's up to the proverbial reader to make the GUI more gooey, but this reports as well as the JSLint site does now.

    sample JSLint output from wrapper code

    0 讨论(0)
提交回复
热议问题