On 11/30/2009 6:23 AM, kvz wrote:
> Hey guys,
>
> I've done some improvements on the site. Some bugs have been fixed
> (mostly comment&utf8 related) and I've made syntax highlighting look
> the same throughout the site.
>
Great. Is it possible to reenable the link to open a new page with the
code (so one can select all and copy without having to drag the mouse)?
I am very glad though that there is the option to copy without line
numbers appearing...
Great!
> Right now it all happens clientside. We could change that later if
> performance demands it.
>
> Now would probably be a good time to decide what jslint options we
> want to stick with. It's now configured as such:
>
> var lintOptions = {
> evil: true,
> nomen: false,
> onevar: false,
> regexp: false,
> strict: false
> };
>
> (except for strict, the options that Douglas Crockford uses on his own
> fulljslint.js) but they may not suit our needs and iirc Brett had some
> strong ideas on the topic.
>
>
Yeah, I guess I do. :)
For one, I wish his "switch" dogma could be mitigated by an option to
allow fall-throughs (at least with a comment or something). It's almost
not worth using a switch at all if you don't allow fall-throughs.
I also didn't agree with not checking for CDATA closings.
I can't remember other gripes at the moment, though these gripes are of
course by someone who is very grateful for jslint.
As far as the specific options...
1) A pity, but in a few cases we do need "evil" (eval) to true. On the
other hand, maybe we should set it to false so A) We may notice other
functions which use it but shouldn't, and B) Others who visit the
website can see that it uses eval() ?
2) If we don't set "forin" to true, there will be a lot of work to do
(and I think there may be a few cases where we need to tolerate it).
However, it is not a bad idea to make our code work with other libraries
that override the prototype (e.g., someone had a problem using one of
our functions with Prototype.js).
3) Didn't you want "onevar" as true? Seems you are trying to only define
once at the top, no? Or is that because you need inner functions to each
have their own "var"?
4) I agree with "nomen" and "strict" to false, though I think those are
the defaults anyways (though it doesn't hurt to spell it out).
5) I agree with regexp being false (also the default), but I don't
understand the rationale of turning it on to true.
FYI, you may want to add the options also at namespaced_template.js (you
can overwrite the ones I had there, except for "global window".
As far as being even stricter:
1) As far as requiring capitalization of constructors, as checked in
"new" invocations (and not allowing invocations of upper-case functions
without "new"), I'd like to add that more stringent (and non-default)
requirement:
newcap: true
2) What do you think about strict white space (white), strict white
space indentation (indent), disallow undefined variables (undef),
disallow == and != (eqeqeq), require parens around immediate invocations
(immed)? These all seem they might be good to follow (even if it'd be a
lot of work to correct).
As far as the other more strict requirements, it seems we cannot use
Adsafe since it objects to "this", etc.:
http://www.adsafe.org/ and I'm
not in favor of disallowing bitwise or ++/--.
> Not jslint but related: I'd like to ask you to try to stick to a max
> of 80chars per line and put comments on their own line where possible.
> My IDE can have some more before it looks messy, but for the site&
> other point of views it would look neat with 80 chars.
>
> This is not a complaint about previous code, but I see we have some
> inconsistencies here&there (we never had a policy about it). So if you
> agree i'd like to add the convention to our coding standards so in the
> future our code looks a bit more consistent.
>
A good idea, but unfortunately wrapping isn't a planned feature until at
least version 6.9 in Netbeans. However, I can try to remember to paste
into Notepad++ which at least shows the column. I read someone say
UltraEdit is the only one that auto-wraps at a given width.
best wishes,
Brett