-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmanual.txt
More file actions
158 lines (116 loc) · 5.04 KB
/
manual.txt
File metadata and controls
158 lines (116 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Jsure
=====
Copyright(C) 2007 Exalead SA.
Released under the GNU Library General Public License.
Description
===========
Jsure is a "lint" for Javascript, which is also known as Ecmascript.
It checks syntax and a little bit of semantics.
Usage
=====
You run jsure on your source files and jsure spits out ANSI-colored
warnings and errors with excerpts from your code on your terminal.
jsure [options] file_1.js file_2.js ... file_n.js
This is equivalent to
cat file_1.js ... file_n.js > file.js
jsure [options] file.js
except for the reported error locations.
Actions
=======
jsure will read and parse the input files. If there is any unparseable file,
it will report an error and stop.
By default, Jsure will only check the syntax. For more advanced checking,
you must use on or more of the following options:
-check : The most useful, all-purpose check (unused vars, etc.)
-forbidden-properties : Some property names such as 'name' cause problems;
jsure can detect static instances of those problematic names.
-list-props : Will list all the (static) property names used in the
file.
Miscellaneous options
=====================
-quiet Suppress informative messages
-no-warnings Suppress warnings
Changing behaviour on certain subdirectories
============================================
Errors and warnings produced by source files whose name starts with a prefix
given by an -ignorify (resp. -warnify) option will be ignored (resp. transformed
into warnings).
Detection of anomalies
======================
Anomalies, such as using an uninitialized variable, are legal language
constructs that are bad coding practice or likely errors.
Each anomaly has an associated action, which can be changed with a one-letter
flag by an option. The actions are ignore (i), warn (w) or error (e).
Anomalies
=========
-toplevel-bindings
Setting global properties without a "var".
-assigning-to-args
Assigning to a function argument.
-uninitialized-vars
Using uninitialized variables. In Javascript, uninitialized variables are set
to undefined.
Unused identifiers
==================
Jsure can detect unused variables (-unused-vars), arguments (-unused-args) or
functions (-unused-funs).
Sometimes it is unavoidable to have unused arguments - for example when you have
to furnish a callback but have no need for all of its arguments.
Jsure will ignore any variable, argument or function whose name starts with an
underscore (_) will be ignored. (The rule for flagging unused variables can be
changed with the -unused-ident-regexp option.) Using such a variable is an
anomaly (-using-unused).
Summary of anomalies
====================
-unused-args Function arguments unused in the body of the function.
-using-unused Using variables or arguments lexically declared to be unused
-unused-vars Unused variables
-unused-funs Unused functions
-shadowing-args Arguments shadowed by variables
-dangling-commas Dangling commas in object and array litterals
Not yet implemented:
-unreachable-code Unreachable code
Environment variables
=====================
It is possible to change the behaviour of jsure thru the environment variables
JSURE and JSURE_BEFORE. These variables define options to be processed before
(JSURE_BEFORE) and after (JSURE) the processing of command-line options.
The syntax for the environment variable is a little different than that of the
command-line options. For instance, the set of command-line options
-toplevel-bindings e -dont-catch
would translate to
JSURE="toplevel_bindings=e;dont_catch"
In other words, the first dash (-) of the option names is to be removed,
remaining dashes are to be replaced by underscores (_), options are to
be separated by semicolons (;) and an equal sign (=) should separate
option names from their arguments.
Excerpts and colorization
=========================
Jsure can show the context surrounding errors. This is settable with the
-errors option: -errors t will display text, -errors p will only display the
error position. The same thing applies to warnings with the -warnings option.
Jsure can also brighten up your life by partially colorizing error or warning
messages. These colors can be configured using the following options:
-info-color <color> Info color
-warning-color <color> Warning color
-error-color <color> Error color
-number-color <color> Line number color
-code-color <color> Code color
-hl-color <color> Code highlight color
Here, <color> is one of;
black
red
green
yellow
blue
magenta
cyan
white
none
and will produce corresponding ANSI escape sequences, which may or may not,
given the configuration of your terminal, produce the expected colors.
Caching parse trees
===================
To accelerate parsing, use the -cache <filename> option; jsure will then
cache parse trees in the file <filename>.dir, which will also be linked to
<filename>.pag (this behaviour is defined by your system's DBM library).