JRS: In article <
[email protected]
m>, dated Fri, 4 Mar 2005 14:47:09, seen in
Douglas Crockford said:
Suppose that JSLINT's report contained a list of all of the member names
that it sees. It might be easier to spot a misspelled name in that list
than in the source. What do you think?
Agreed.
Errors in case are evidently fairly common and hard to spot, as we see
in this group. For example, onKeypress is a perfectly legitimate name;
nevertheless, it is probably a typo, and otherwise almost certainly
injudicious.
The number of names already known to the system is finite, though large;
but a list covering well over 99% of instances-of-use would not be very
long, and could probably be made by RegExp processing of existing
javascript documentation, sorting, de-duplicating, and hand-polishing.
The following line looks semi-promising as a start, mtr being MiniTrue
and DEDUPE being mine :-
mtr -o^ -x+ d:\jscrrefs\jsref\jsr13\*.htm ".*<code>(\w*)</code>.*" =
\1\r | sort | DEDUPE > file.txt
Or there might be a way of getting the list from a browser, or from
browser source code.
It could, IMHO, be useful to report as permissible but suspect any
instances of names that matched a well-known name case-independently but
differed in case.
It would also be useful to report instances of member names that were
duplicated but with case-differences, with a user-selectable parameter
for length (pragmatically, a page may well contain a J loop in one
routine and a j loop in another; but having a name Dustbin and another
DustBin should be viewed with suspicion [ either both should be
identical, or, for easier reading, one might become Dustpan ] ).
Perhaps the best would be to list all distinct names, sorted independent
of case, and annotated symbolically; a user could then process the list
either by eye or by code. Maybe in Column 1 a # for any name that
matches anything but only when case is ignored, else space; in Column 3
a % for a match with a "predefined" name; ...; in Column 2N+1 put the
name itself. Perhaps a column of frequency-count:
# % 2 gettimeout
# 15 getToadStool
# 1 getToadstool
1 getTodeStool
and it is also clear which are probably wrong.
H'mmm - and any name that is not "predefined" and is used only once is
also, IMHO, worth considering, though possibly legitimate especially in
a page with "working but incomplete" status.
IIRC, running jslint kills MSIE4; I consider that a superfluous effect,
perhaps removable by feature detection and/or substitution.