JSLint with multiple files

后端 未结 7 543
旧巷少年郎
旧巷少年郎 2020-12-11 14:22

JSLint works fine for just one JavaScript file. Recently, I\'ve started breaking my program into several pieces.

I don\'t want to be stringing the pieces each time I

相关标签:
7条回答
  • 2020-12-11 15:01

    You can run JSLint against HTML files, not just against JavaScript files (which makes sense, because of the <SCRIPT> tag). And JSLint is smart about external scripts - if it can locate them, it will load them as part of the processing. So try something like this:

    <html>
        <head>
            <script src="file1.js"></script>
            <script src="file2.js"></script>
            ...
            <script>mainRoutine();</script>
        </head>
    </html>
    

    Run JSLint on that, instead of on each of your files.

    0 讨论(0)
  • 2020-12-11 15:04

    There is a version of JSLint (node-JSLint) (command line) that allows you to check multiple files at once. Follow link for download at GitHub:

    https://github.com/reid/node-jslint

    The following examples of calling via the command line:

    JSLint app.js
    JSLint lib / lib worker.js / server.js # Multiple files
    JSLint - white - onevar - regexp app.js JSLint # All options supported
    JSLint - bitwise false app.js # Defaults to true, but You Can Specify false
    JSLint - goodparts - # undef false app.js The Good Parts, except undef
    JSLint-gp app.js # Shorthand for - goodparts:-gp
    find . -name "*.js" -print0 | xargs -0 jslint # JSLint JSLint your Entire Project
    

    Note: This application was developed to NodeJS.

    0 讨论(0)
  • 2020-12-11 15:08

    What's wrong with just running the command?

    jslint .
    

    will check all js files in the current directory and recurse down the tree.

    0 讨论(0)
  • 2020-12-11 15:09

    You can also have a look here: https://github.com/mikewest/jslint-utils It should work with either Rhino or NodeJS. You can also pass multiple files for checking. NB: if you have a command line script which doesn't take multiple files as arguments, you can always do something like: ls public/javascripts/**/*.js | jslint

    0 讨论(0)
  • 2020-12-11 15:11

    (This Is taken from this link and formatted)

    Rhino is a Javascript engine that is written entirely in Java. It can be used to run JSLint from the command line on systems with Java interpreters.

    The file jslint.js can be run by Rhino. It will read a JavaScript program from a file. If there are no problems, it terminates quietly. If there is a problem, it outputs a message. The WSH edition of JSLint does not produce a Function Report.

    One way to run JSLint is with this command:

    C:\> java org.mozilla.javascript.tools.shell.Main jslint.js myprogram.js
    

    It runs java which loads and runs Rhino which loads and runs jslint.js, which will read the file myprogram.js and report an error if found.

    Download jslint.js.

    0 讨论(0)
  • 2020-12-11 15:16

    The command line app JavaScript Lint (http://www.javascriptlint.com/) works with multiple files and can recurse directories. E.g.

    %JSLPATH%\jsl.exe +recurse -process src\scripts\*.js  
    
    0 讨论(0)
提交回复
热议问题