UNPKG

6.55 kBMarkdownView Raw
1jslint(1) -- a code quality tool
2================================
3## SYNOPSIS
4
5jslint.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
9JSLint 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
120To install jslint globally, use
121 npm install jslint -g
122
123To install jslint locally, use
124 npm install jslint
125
126When installed locally, jslint can be run as
127 ./node_modules/.bin/jslint
128
129##FILES
130
131jslint looks for the following config files at startup:
132
133 $HOME/.jslintrc
134 ./jslintrc
135 ./.jslintrc
136
137The format of a jslint options file is a JSON file containing a single object
138where the keys are jslint option names and the values are the option argument;
139use `true` to enable and `false` to disable boolean options. An example of a
140valid option file is:
141
142 {
143 vars: true,
144 white: true,
145 maxlen: 100,
146 predef: "foo,bar,baz"
147 }
148
149Comments are not allowed in option files.
150
151##PRECEDENCE
152
153The 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
160A higher number indicates a higher precedence, i.e. command line options
161override options specified by an options file, and /\*jslint\*/ comments
162in the file being examined have the highest precedence.
163
164##EDITIONS
165
166You can now specify the edition of jslint with the *--edition* option.
167
168Future versions of this package may include newer editions of jslint;
169to always use the latest edition of jslint, specify --edition=latest:
170
171 jslint --edition=latest lib/*.js
172
173The default edition of jslint will remain stable as long as the leading
174two components of the version number are the same. New minor editions
175may have a different default edition.
176
177The 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
179new 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`
181on the command line.
182
183We recommend the following practices:
184
185###If your project is in maintenance mode
186
187Choose 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
189devDependency in package.json
190
191###If your project needs temporary stability (e.g., release phase)
192
193Use the default edition of jslint (no `--edition` argument needed) and specify
194a fixed minor version (e.g, "~0.2") as a devDependency in package.json
195
196###If you want the bleeding-edge version
197
198Specify `edition: 'latest'` and use any 'latest version' behavior in package.json,
199e.g., "*" or ">0.2.1"
200
201##RETURN VALUES
202
203jslint returns 1 if it found any problems, 0 otherwise.
204
205##AUTHOR
206
207jslint is written and maintained by Douglas Crockford [https://github.com/douglascrockford/JSLint](https://github.com/douglascrockford/JSLint)
208
209This package is node-jslint, which provides a command-line interface for
210running jslint using the nodejs platform. node-jslint was written by Reid Burke
211and is maintained by Reid Burke, Ryuichi Okumura, and Sam Mikes.
212
213##BUGS
214
215There are no known bugs. Submit bugs to [https://github.com/reid/node-jslint/issues](https://github.com/reid/node-jslint/issues)
216
217Note that if you are reporting a problem with the way jslint works rather than the way
218the 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)