1 | jslint(1) -- a code quality tool
|
2 | ================================
|
3 | ## SYNOPSIS
|
4 |
|
5 | jslint.js [--anon] [--ass] [--bitwise] [--browser] [--closure] [--color] [--continue] [--debug] [--devel] [--edition] [--eqeq] [--es5] [--evil] [--forin] [--indent] [--json] [--maxerr] [--maxlen] [--newcap] [--node] [--nomen] [--on] [--passfail] [--plusplus] [--predef] [--properties] [--regexp] [--rhino] [--sloppy] [--stupid] [--sub] [--terse] [--todo] [--undef] [--unparam] [--vars] [--white] [--] <scriptfile>...
|
6 |
|
7 | ## DESCRIPTION
|
8 |
|
9 | JSLint is a static analysis tool to locate and correct style problems in Javascript (ECMAScript etc.) source code.
|
10 |
|
11 | ## META OPTIONS
|
12 | `--color` write output in color
|
13 |
|
14 | `--terse` report one error per line with parseable source file/line
|
15 |
|
16 | `--json` output in JSON format
|
17 |
|
18 | `--edition` specify which edition of jslint to use
|
19 |
|
20 | ## LINTING OPTIONS
|
21 | `--ass` Tolerate assignment expressions
|
22 |
|
23 | `--bitwise` Tolerate bitwise operators
|
24 |
|
25 | `--browser` Assume a browser
|
26 |
|
27 | `--closure` Tolerate Google Closure idioms
|
28 |
|
29 | `--continue` Tolerate continue
|
30 |
|
31 | `--debug` Tolerate debugger statements
|
32 |
|
33 | `--devel` Assume console,alert, ...
|
34 |
|
35 | `--eqeq` Tolerate == and !=
|
36 |
|
37 | `--evil` Tolerate eval
|
38 |
|
39 | `--forin` Tolerate unfiltered for in
|
40 |
|
41 | `--indent` Strict white space indentation
|
42 |
|
43 | `--maxerr` Maximum number of errors
|
44 |
|
45 | `--maxlen` Maximum line length
|
46 |
|
47 | `--newcap` Tolerate uncapitalized constructors
|
48 |
|
49 | `--node` Assume Node.js
|
50 |
|
51 | `--nomen` Tolerate dangling underscore in identifiers
|
52 |
|
53 | `--passfail` Stop on first error
|
54 |
|
55 | `--plusplus` Tolerate ++ and --
|
56 |
|
57 | `--predef` Declare additional predefined globals
|
58 |
|
59 | `--properties` Require all property names to be declared with /*properties*/
|
60 |
|
61 | `--regexp` Tolerate . and [^...]. in /RegExp/
|
62 |
|
63 | `--rhino` Assume Rhino
|
64 |
|
65 | `--sloppy` Tolerate missing 'use strict' pragma
|
66 |
|
67 | `--stupid` Tolerate stupidity (typically, use of sync functions)
|
68 |
|
69 | `--sub` Tolerate inefficient subscripting
|
70 |
|
71 | `--todo` Tolerate TODO comments
|
72 |
|
73 | `--unparam` Tolerate unused parameters
|
74 |
|
75 | `--vars` Tolerate many var statements per function
|
76 |
|
77 | `--white` Tolerate messy white space
|
78 |
|
79 | ## DEPRECATED OPTIONS
|
80 |
|
81 | `--anon` Tolerate no space in anonymous function definition
|
82 |
|
83 | `--es5` Tolerate ECMAScript 5 syntax
|
84 |
|
85 | `--undef` Tolerate variables used before declaration
|
86 |
|
87 | `--on` Tolerate HTML event handlers
|
88 |
|
89 | `--windows` Assume existence of Windows globals
|
90 |
|
91 | ##EXAMPLES
|
92 |
|
93 | *Multiple files:*
|
94 |
|
95 | jslint lib/color.js lib/reporter.js
|
96 |
|
97 | *All JSLint options supported*
|
98 |
|
99 | jslint --white --vars --regexp lib/color.js
|
100 |
|
101 | *Defaults to true, but you can specify false*
|
102 |
|
103 | jslint --bitwise false lib/color.js
|
104 |
|
105 | *Pass arrays*
|
106 |
|
107 | jslint --predef $ --predef Backbone lib/color.js
|
108 |
|
109 | *JSLint your entire project*
|
110 |
|
111 | find . -name "*.js" -print0 | xargs -0 jslint
|
112 |
|
113 | *Using JSLint with a config file*
|
114 |
|
115 | Start with the included example jslintrc file and customize your options per project
|
116 | or copy it to $HOME/.jslintrc to apply your setting globally
|
117 |
|
118 | ##INSTALLATION
|
119 |
|
120 | To install jslint globally, use
|
121 | npm install jslint -g
|
122 |
|
123 | To install jslint locally, use
|
124 | npm install jslint
|
125 |
|
126 | When installed locally, jslint can be run as
|
127 | ./node_modules/.bin/jslint
|
128 |
|
129 | ##FILES
|
130 |
|
131 | jslint looks for the following config files at startup:
|
132 |
|
133 | $HOME/.jslintrc
|
134 | ./jslintrc
|
135 | ./.jslintrc
|
136 |
|
137 | The format of a jslint options file is a JSON file containing a single object
|
138 | where the keys are jslint option names and the values are the option argument;
|
139 | use `true` to enable and `false` to disable boolean options. An example of a
|
140 | valid option file is:
|
141 |
|
142 | {
|
143 | vars: true,
|
144 | white: true,
|
145 | maxlen: 100,
|
146 | predef: "foo,bar,baz"
|
147 | }
|
148 |
|
149 | Comments are not allowed in option files.
|
150 |
|
151 | ##PRECEDENCE
|
152 |
|
153 | The order of precedence for options is as follows:
|
154 |
|
155 | 1. in the $HOME/.jslintrc
|
156 | 1. in ./jslintrc or ./.jslintrc
|
157 | 1. on the command line
|
158 | 1. in a /\*jslint\*/ comment
|
159 |
|
160 | A higher number indicates a higher precedence, i.e. command line options
|
161 | override options specified by an options file, and /\*jslint\*/ comments
|
162 | in the file being examined have the highest precedence.
|
163 |
|
164 | ##EDITIONS
|
165 |
|
166 | You can now specify the edition of jslint with the *--edition* option.
|
167 |
|
168 | Future versions of this package may include newer editions of jslint;
|
169 | to always use the latest edition of jslint, specify --edition=latest:
|
170 |
|
171 | jslint --edition=latest lib/*.js
|
172 |
|
173 | The default edition of jslint will remain stable as long as the leading
|
174 | two components of the version number are the same. New minor editions
|
175 | may have a different default edition.
|
176 |
|
177 | The previous version of this package (0.1.9) shipped an older edition
|
178 | (2013-02-03) of jslint. To revert to that behavior but still have the
|
179 | new config file features, upgrade to 0.2.1 of this package and specify
|
180 | `edition: '2012-02-03'` in your jslintrc file or `--edition=2013-02-03`
|
181 | on the command line.
|
182 |
|
183 | We recommend the following practices:
|
184 |
|
185 | ###If your project is in maintenance mode
|
186 |
|
187 | Choose an edition of jslint and hardcode it into your project's lint config files, e.g.,
|
188 | `edition: '2012-02-03'`. Specify a fixed version of jslint (e.g., "0.2.1") as a
|
189 | devDependency in package.json
|
190 |
|
191 | ###If your project needs temporary stability (e.g., release phase)
|
192 |
|
193 | Use the default edition of jslint (no `--edition` argument needed) and specify
|
194 | a fixed minor version (e.g, "~0.2") as a devDependency in package.json
|
195 |
|
196 | ###If you want the bleeding-edge version
|
197 |
|
198 | Specify `edition: 'latest'` and use any 'latest version' behavior in package.json,
|
199 | e.g., "*" or ">0.2.1"
|
200 |
|
201 | ##RETURN VALUES
|
202 |
|
203 | jslint returns 1 if it found any problems, 0 otherwise.
|
204 |
|
205 | ##AUTHOR
|
206 |
|
207 | jslint is written and maintained by Douglas Crockford [https://github.com/douglascrockford/JSLint](https://github.com/douglascrockford/JSLint)
|
208 |
|
209 | This package is node-jslint, which provides a command-line interface for
|
210 | running jslint using the nodejs platform. node-jslint was written by Reid Burke
|
211 | and is maintained by Reid Burke, Ryuichi Okumura, and Sam Mikes.
|
212 |
|
213 | ##BUGS
|
214 |
|
215 | There are no known bugs. Submit bugs to [https://github.com/reid/node-jslint/issues](https://github.com/reid/node-jslint/issues)
|
216 |
|
217 | Note that if you are reporting a problem with the way jslint works rather than the way
|
218 | the command-line tools work, we will probably refer you to the JSLint community [https://plus.google.com/communities/104441363299760713736](https://plus.google.com/communities/104441363299760713736) or the issue tracker at
|
219 | [https://github.com/douglascrockford/JSLint/issues](https://github.com/douglascrockford/JSLint/issues)
|