Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

jslint_com · This group has moved to Google Plus.

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 584
  • Category: JavaScript
  • Founded: Mar 7, 2008
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 1825 - 1854 of 3202   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#1825 From: Jim Auldridge <auldridgej@...>
Date: Wed Jan 26, 2011 6:41 pm
Subject: Re: Problems with immediately invoked function expressions
jaaulde
Send Email Send Email
 
Sorry--to clarify, I have Strict whitespace unchecked, and indent set to 0

Thanks,
Jim

On Wed, Jan 26, 2011 at 1:40 PM, Jim Auldridge <auldridgej@...> wrote:

> Can anyone tell me why the code in this paste:
> http://pastie.textmate.org/private/gd8xrctmenh3qu2jrxintq
> generates these errors:
>
> Problem at line 7 character 1: Expected ';' and instead saw '}'.
>
> }() );
>
> Problem at line 7 character 2: Unreachable '(' after 'return'.
>
> }() );
>
> Problem at line 7 character 3: Expected an identifier and instead saw ')'.
>
> }() );
>
> Problem at line 7 character 3: Stopping, unable to continue. (100%
> scanned).
>
>
>
> Thanks,
> Jim
>
> --
> Jim Auldridge
>  11012 Lincoln Ave
>  Hagerstown MD 21740
>  240.520.0240 (m)
>  auldridgej@...
>  http://jaaulde.com
>



--
Jim Auldridge
  11012 Lincoln Ave
  Hagerstown MD 21740
  240.520.0240 (m)
  auldridgej@...
  http://jaaulde.com


[Non-text portions of this message have been removed]

#1826 From: "Douglas Crockford" <douglas@...>
Date: Wed Jan 26, 2011 6:58 pm
Subject: Re: Problems with immediately invoked function expressions
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, Jim Auldridge <auldridgej@...> wrote:
>
> Can anyone tell me why the code in this paste:
> http://pastie.textmate.org/private/gd8xrctmenh3qu2jrxintq
> generates these errors:
>
> Problem at line 7 character 1: Expected ';' and instead saw '}'.
>
> }() );

Did you try to insert the missing semicolon where JSLint recommended?

#1827 From: Jim Auldridge <auldridgej@...>
Date: Wed Jan 26, 2011 6:50 pm
Subject: predefined list being ignored?
jaaulde
Send Email Send Email
 
This line of code:
     var href = window.location.href;

causes this error
     Problem at line 1 character 12: 'window' is not defined.


With 'window' in the predefined list.

Any thoughts?

Thanks,
Jim

--
Jim Auldridge
  11012 Lincoln Ave
  Hagerstown MD 21740
  240.520.0240 (m)
  auldridgej@...
  http://jaaulde.com


[Non-text portions of this message have been removed]

#1828 From: "abyssoft@..." <abyssoft@...>
Date: Wed Jan 26, 2011 7:18 pm
Subject: Re: Problems with immediately invoked function expressions
abyssoft...
Send Email Send Email
 
Return statements should terminate in a ;

var foo = ( function()
{
     return function()
     {
         window.alert( 'bar' );
     }; <---
}() );

--- In jslint_com@yahoogroups.com, Jim Auldridge <auldridgej@...> wrote:
>
> Can anyone tell me why the code in this paste:
> http://pastie.textmate.org/private/gd8xrctmenh3qu2jrxintq
> generates these errors:
>
> Problem at line 7 character 1: Expected ';' and instead saw '}'.
>
> }() );
>
> Problem at line 7 character 2: Unreachable '(' after 'return'.
>
> }() );
>
> Problem at line 7 character 3: Expected an identifier and instead saw ')'.
>
> }() );
>
> Problem at line 7 character 3: Stopping, unable to continue. (100% scanned).
>
>
>
> Thanks,
> Jim
>
> --
> Jim Auldridge
>  11012 Lincoln Ave
>  Hagerstown MD 21740
>  240.520.0240 (m)
>  auldridgej@...
>  http://jaaulde.com
>
>
> [Non-text portions of this message have been removed]
>

#1829 From: Jim Auldridge <auldridgej@...>
Date: Wed Jan 26, 2011 7:02 pm
Subject: Re: [jslint] Re: Problems with immediately invoked function expressions
jaaulde
Send Email Send Email
 
Groooan, I'm so sorry for wasting your time. I needed the semicolon after
the returned anon-function--I was looking below.

Thanks for cluing me into JSLints already clear clue *roll eyes at self*

Jim

On Wed, Jan 26, 2011 at 1:58 PM, Douglas Crockford <douglas@...>wrote:

>
>
>
> --- In jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com>, Jim
> Auldridge <auldridgej@...> wrote:
> >
> > Can anyone tell me why the code in this paste:
> > http://pastie.textmate.org/private/gd8xrctmenh3qu2jrxintq
> > generates these errors:
> >
> > Problem at line 7 character 1: Expected ';' and instead saw '}'.
> >
> > }() );
>
> Did you try to insert the missing semicolon where JSLint recommended?
>
>
>



--
Jim Auldridge
  11012 Lincoln Ave
  Hagerstown MD 21740
  240.520.0240 (m)
  auldridgej@...
  http://jaaulde.com


[Non-text portions of this message have been removed]

#1830 From: Jim Auldridge <auldridgej@...>
Date: Wed Jan 26, 2011 6:47 pm
Subject: Cannot have line break after if(), before {
jaaulde
Send Email Send Email
 
Can anyone please tell me why the code in this pastie:
http://pastie.textmate.org/private/h0awaucqk6b25kjqfxuw9g
generates this error:

Problem at line 4 character 1: Expected exactly one space between ')' and
'{'.

{
Strict whitespace if off, indent is at 0

Thanks,
Jim

--
Jim Auldridge
  11012 Lincoln Ave
  Hagerstown MD 21740
  240.520.0240 (m)
  auldridgej@...
  http://jaaulde.com


[Non-text portions of this message have been removed]

#1831 From: "walfisch1" <christian.wirkus@...>
Date: Wed Jan 26, 2011 8:14 pm
Subject: Re: SV: [jslint] js_beautify bookmarklet
walfisch1
Send Email Send Email
 
"what's the value of linting a beautified version of some script?"
It's better than not linting at all.
True, I don't get what I'd like to get, and JSLint might not find all errors it
could. But it still can tell me about missing semicola, lax regexps, implied
globals, ...
I like JSLint's code conventions (http://javascript.crockford.com/code.html) and
use them in my private projects, but in a team with lots of projects I can't
switch the code conventions or just write my own style.



--- In jslint_com@yahoogroups.com, "Jakob Kruse" <kruse@...> wrote:
>
> Maybe I'm just being dumb, but what's the value of linting a beautified
version of some script? Assuming (as you state) that turning off strict
whitespace checking is not enough, chances are the original script has bugs that
jslint fails to find because the beautifier changes or removes them.
>
> You should convince your employer that following the advice of jslint is
better for everyone.
>
> /Jakob
>
> Fra: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] På vegne
af walfisch1
> Sendt: 26. januar 2011 14:26
> Til: jslint_com@yahoogroups.com
> Emne: [jslint] js_beautify bookmarklet
>
>
> My new employer has a non-JSLint-compliant white-space code convention. No
options will make this validate.
> To use JSLint nontheless I wrote a bookmarklet that fetches jsbeautifier and
beautifies the JSLint input field.
> Feel free to use or modify.
> (You want to see this monospaced and indented? Click "Show Message Option" on
the right and select "Use Fixed Width Font".)
>
> /*global js_beautify*/
> (function () {
> var execute, input, lock, script;
>
> execute = function () {
> if (lock) {
> setTimeout(execute, 1000);
> return;
> }
> input = document.getElementById("JSLINT_INPUT");
> input.value = js_beautify(input.value, {
> space_after_anon_function: true
> });
> };
>
> if (typeof js_beautify === "undefined" &&
> !document.getElementById("_beauty_lint_")) {
> lock = true;
> script = document.createElement("script");
> script.id = "_beauty_lint_";
> script.src = "http://jsbeautifier.org/beautify.js";
> script.onload = function () {
> lock = false;
> };
> document.body.appendChild(script);
> }
>
> execute();
> }());
>
>
> [Non-text portions of this message have been removed]
>

#1832 From: "abyssoft@..." <abyssoft@...>
Date: Wed Jan 26, 2011 8:21 pm
Subject: Re: predefined list being ignored?
abyssoft...
Send Email Send Email
 
works as designed
add
/*global window*/

to your code to ensure registering predifned
--- In jslint_com@yahoogroups.com, Jim Auldridge <auldridgej@...> wrote:
>
> This line of code:
>     var href = window.location.href;
>
> causes this error
>     Problem at line 1 character 12: 'window' is not defined.
>
>
> With 'window' in the predefined list.
>
> Any thoughts?
>
> Thanks,
> Jim
>
> --
> Jim Auldridge
>  11012 Lincoln Ave
>  Hagerstown MD 21740
>  240.520.0240 (m)
>  auldridgej@...
>  http://jaaulde.com
>
>
> [Non-text portions of this message have been removed]
>

#1833 From: "Jim Auldridge" <auldridgej@...>
Date: Wed Jan 26, 2011 8:23 pm
Subject: Re: predefined list being ignored?
jaaulde
Send Email Send Email
 
Isn't that what the "predefined" input field is for in the web interface? I have
window in that field (as noted in my original message) but I am told it is
undefined. Am I confused or is the input being ignored?

--- In jslint_com@yahoogroups.com, "abyssoft@..." <abyssoft@...> wrote:
>
> works as designed
> add
> /*global window*/
>
> to your code to ensure registering predifned
> --- In jslint_com@yahoogroups.com, Jim Auldridge <auldridgej@> wrote:
> >
> > This line of code:
> >     var href = window.location.href;
> >
> > causes this error
> >     Problem at line 1 character 12: 'window' is not defined.
> >
> >
> > With 'window' in the predefined list.
> >
> > Any thoughts?
> >
> > Thanks,
> > Jim
> >
> > --
> > Jim Auldridge
> >  11012 Lincoln Ave
> >  Hagerstown MD 21740
> >  240.520.0240 (m)
> >  auldridgej@
> >  http://jaaulde.com
> >
> >
> > [Non-text portions of this message have been removed]
> >
>

#1834 From: "abyssoft@..." <abyssoft@...>
Date: Wed Jan 26, 2011 8:44 pm
Subject: Re: predefined list being ignored?
abyssoft...
Send Email Send Email
 
Refreshed screen and re-tested

Indeed it is ignoring manual entries via input field.



--- In jslint_com@yahoogroups.com, "Jim Auldridge" <auldridgej@...> wrote:
>
> Isn't that what the "predefined" input field is for in the web interface? I
have window in that field (as noted in my original message) but I am told it is
undefined. Am I confused or is the input being ignored?
>
> --- In jslint_com@yahoogroups.com, "abyssoft@" <abyssoft@> wrote:
> >
> > works as designed
> > add
> > /*global window*/
> >
> > to your code to ensure registering predifned
> > --- In jslint_com@yahoogroups.com, Jim Auldridge <auldridgej@> wrote:
> > >
> > > This line of code:
> > >     var href = window.location.href;
> > >
> > > causes this error
> > >     Problem at line 1 character 12: 'window' is not defined.
> > >
> > >
> > > With 'window' in the predefined list.
> > >
> > > Any thoughts?
> > >
> > > Thanks,
> > > Jim
> > >
> > > --
> > > Jim Auldridge
> > >  11012 Lincoln Ave
> > >  Hagerstown MD 21740
> > >  240.520.0240 (m)
> > >  auldridgej@
> > >  http://jaaulde.com
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
>

#1835 From: "Merlin" <g7awz@...>
Date: Wed Jan 26, 2011 8:56 pm
Subject: Re: predefined list being ignored?
harry152566
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "abyssoft@..." <abyssoft@...> wrote:
>
> Refreshed screen and re-tested
>
> Indeed it is ignoring manual entries via input field.

The predefined field is working in JSLint in the WidgetTester Widget, so it must
be the web interface rather than JSLint itself.

Harry.

#1836 From: Frederik Dohr <fdg001@...>
Date: Wed Jan 26, 2011 9:00 pm
Subject: ANN: JSLint Reporter (Node.js wrapper)
ace_noone
Send Email Send Email
 
Here's yet another[1] JSLint wrapper for command-line enthusiasts.

Since my Python wrapper[2] for JSLint always seemed overly complex, I've
created a pure-JavaScript wrapper using Node.js:
     https://github.com/FND/jslint-reporter

I've attempted to keep it as simple as possible; the makefile adds only
a single line to JSLint (`make jslint`) for Node.js-compatibility
("module.exports.JSLINT = JSLINT;") - the rest (i.e. wrapper.js) is just
some glue to pass data to JSLINT.

The output is in standard error format (<file>:<line>:<char>:<error>),
so it can easily be used from within editors like Vim et al.

Since folks here are very good at uncovering unexpected behavior, I'd
greatly appreciate some feedback.


-- F.


[1]
http://tech.groups.yahoo.com/group/jslint_com/database?method=reportRows&tbl=1
[2] https://github.com/FND/jslint-cli

#1837 From: "Merlin" <g7awz@...>
Date: Wed Jan 26, 2011 9:16 pm
Subject: Re: ANN: JSLint Reporter (Node.js wrapper)
harry152566
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, Frederik Dohr <fdg001@...> wrote:
> Here's yet another[1] JSLint wrapper for command-line enthusiasts.

Rather than using fulljslint.js, why not use the minified version from

http://www.JSLint.com/jslint.js  ?

Harry.

#1838 From: Jim Auldridge <auldridgej@...>
Date: Wed Jan 26, 2011 7:23 pm
Subject: Re: [jslint] Re: Problems with immediately invoked function expressions
jaaulde
Send Email Send Email
 
Indeed, I am a bonehead.  Thanks!

On Wed, Jan 26, 2011 at 2:18 PM, abyssoft@... <abyssoft@...>wrote:

>
>
>
>
> Return statements should terminate in a ;
>
> var foo = ( function()
> {
> return function()
> {
> window.alert( 'bar' );
> }; <---
> }() );
>
>
> --- In jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com>, Jim
> Auldridge <auldridgej@...> wrote:
> >
> > Can anyone tell me why the code in this paste:
> > http://pastie.textmate.org/private/gd8xrctmenh3qu2jrxintq
> > generates these errors:
> >
> > Problem at line 7 character 1: Expected ';' and instead saw '}'.
> >
> > }() );
> >
> > Problem at line 7 character 2: Unreachable '(' after 'return'.
> >
> > }() );
> >
> > Problem at line 7 character 3: Expected an identifier and instead saw
> ')'.
> >
> > }() );
> >
> > Problem at line 7 character 3: Stopping, unable to continue. (100%
> scanned).
> >
> >
> >
> > Thanks,
> > Jim
> >
> > --
> > Jim Auldridge
> > 11012 Lincoln Ave
> > Hagerstown MD 21740
> > 240.520.0240 (m)
> > auldridgej@...
> > http://jaaulde.com
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>



--
Jim Auldridge
  11012 Lincoln Ave
  Hagerstown MD 21740
  240.520.0240 (m)
  auldridgej@...
  http://jaaulde.com


[Non-text portions of this message have been removed]

#1839 From: Frederik Dohr <fdg001@...>
Date: Thu Jan 27, 2011 6:52 am
Subject: Re: [jslint] Re: ANN: JSLint Reporter (Node.js wrapper)
ace_noone
Send Email Send Email
 
> Rather than using fulljslint.js, why not use the minified version
> from http://www.JSLint.com/jslint.js  ?

Well, given that HTTP overhead is not a concern in this context, I don't
see any benefit in using the minified version.

Having said that, it's probably best to use jslint.com/fulljslint.js
rather than GitHub, as that seems like the canonical URL.


-- F.

#1840 From: "Merlin" <g7awz@...>
Date: Thu Jan 27, 2011 3:43 pm
Subject: Re: ANN: JSLint Reporter (Node.js wrapper)
harry152566
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, Frederik Dohr <fdg001@...> wrote:
>
> Here's yet another[1] JSLint wrapper for command-line enthusiasts.

> Since folks here are very good at uncovering unexpected behavior, I'd
> greatly appreciate some feedback.

It would be good if it were possible to set options off with something like:

node wrapper.js --goodparts --nomen=false example.js  .

That would obviate the need to list all of the good options bar one.

Also something like:

node wrapper.js --predef "window, ..." test.js

to be able to set predefined items.

Harry.

#1841 From: "Douglas Crockford" <douglas@...>
Date: Thu Jan 27, 2011 8:26 pm
Subject: Re: js_beautify bookmarklet
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "walfisch1" <christian.wirkus@...> wrote:
>
> My new employer has a non-JSLint-compliant white-space code convention. No
options will make this validate.
> To use JSLint nontheless I wrote a bookmarklet that fetches jsbeautifier and
beautifies the JSLint input field.
> Feel free to use or modify.

I made JSLint in the hope of removing a little bit of stupidity from the world.
This makes me sad.

#1842 From: "Douglas Crockford" <douglas@...>
Date: Thu Jan 27, 2011 8:41 pm
Subject: Re: predefined list being ignored?
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, Jim Auldridge <auldridgej@...> wrote:
>
> This line of code:
>     var href = window.location.href;
>
> causes this error
>     Problem at line 1 character 12: 'window' is not defined.
>
>
> With 'window' in the predefined list.

Please try it now.

#1843 From: Jim Auldridge <auldridgej@...>
Date: Thu Jan 27, 2011 8:44 pm
Subject: Re: [jslint] Re: predefined list being ignored?
jaaulde
Send Email Send Email
 
Looks good, thanks!

On Thu, Jan 27, 2011 at 3:41 PM, Douglas Crockford <douglas@...>wrote:

>
>
> --- In jslint_com@yahoogroups.com <jslint_com%40yahoogroups.com>, Jim
> Auldridge <auldridgej@...> wrote:
> >
> > This line of code:
> > var href = window.location.href;
> >
> > causes this error
> > Problem at line 1 character 12: 'window' is not defined.
> >
> >
> > With 'window' in the predefined list.
>
> Please try it now.
>
>
>



--
Jim Auldridge
  11012 Lincoln Ave
  Hagerstown MD 21740
  240.520.0240 (m)
  auldridgej@...
  http://jaaulde.com


[Non-text portions of this message have been removed]

#1844 From: "walfisch1" <christian.wirkus@...>
Date: Thu Jan 27, 2011 10:23 pm
Subject: Re: js_beautify bookmarklet
walfisch1
Send Email Send Email
 
I'm sorry to hear that.
JSLint is a great tool. I don't want to miss it just because the whitespace
doesn't match with my new code conventions.

#1845 From: "walfisch1" <christian.wirkus@...>
Date: Fri Jan 28, 2011 7:24 am
Subject: Re: js_beautify bookmarklet
walfisch1
Send Email Send Email
 
I know it's your program, sorry I treated it that way.

--- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
>
> --- In jslint_com@yahoogroups.com, "walfisch1" <christian.wirkus@> wrote:
> >
> > My new employer has a non-JSLint-compliant white-space code convention. No
options will make this validate.
> > To use JSLint nontheless I wrote a bookmarklet that fetches jsbeautifier and
beautifies the JSLint input field.
> > Feel free to use or modify.
>
> I made JSLint in the hope of removing a little bit of stupidity from the
world. This makes me sad.
>

#1846 From: Frederik Dohr <fdg001@...>
Date: Fri Jan 28, 2011 8:13 am
Subject: Re: [jslint] Re: ANN: JSLint Reporter (Node.js wrapper)
ace_noone
Send Email Send Email
 
> It would be good if it were possible to set options off with
> something like:
> node wrapper.js --goodparts --nomen=false example.js  .
> That would obviate the need to list all of the good options bar one.

That seems like a reasonable thing to do. It'll require a slightly
different approach to parsing command-line arguments though - I'll look
into that next week. (While there are plenty of option parsers for
Node.js, I was trying to avoid external dependencies.)

> Also something like:
> node wrapper.js --predef "window, ..." test.js
> to be able to set predefined items.

Indeed, predef is currently unsupported - I suspect this will fall out
of the refactoring above.

FWIW, I'm also planning to add an --upgrade option to grab the latest
version of fulljslint.js, thus rendering the makefile obsolete (cf.
external dependencies).


-- F.

#1847 From: "Merlin" <g7awz@...>
Date: Fri Jan 28, 2011 11:52 am
Subject: Re: ANN: JSLint Reporter (Node.js wrapper)
harry152566
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, Frederik Dohr <fdg001@...> wrote:
>
> > It would be good if it were possible to set options off with
> > something like:
> > node wrapper.js --goodparts --nomen=false example.js  .
> > That would obviate the need to list all of the good options bar one.
>
> That seems like a reasonable thing to do. It'll require a slightly
> different approach to parsing command-line arguments though - I'll look
> into that next week. (While there are plenty of option parsers for
> Node.js, I was trying to avoid external dependencies.)

The conventions on Unix for "negative" options have always been a bit quaint.
However, I would guess that you could do something like:

node wrapper.js --goodparts -nomen example.js  (note single minus sign on nomen)

fairly easily, without having to use an external parser. It would seem odd to
use +nomen
to turn the option off.

>
> > Also something like:
> > node wrapper.js --predef "window, ..." test.js
> > to be able to set predefined items.
>
> Indeed, predef is currently unsupported - I suspect this will fall out
> of the refactoring above.
>
> FWIW, I'm also planning to add an --upgrade option to grab the latest
> version of fulljslint.js, thus rendering the makefile obsolete (cf.
> external dependencies).

That is an excellent idea. Ideally you should limit how often you upgrade to
save load on the servers. In my Widget Tester Widget, I pull the JSLint file no
more than once a day.

Harry.

#1848 From: "Jakob Kruse" <kruse@...>
Date: Fri Jan 28, 2011 12:36 pm
Subject: SV: [jslint] Re: ANN: JSLint Reporter (Node.js wrapper)
thekrucible
Send Email Send Email
 
Do please consider the security aspects. When modifying jslint to run as a Node
module, you are also giving it complete access to the computer on which it runs.
If someone were to inject malicious code into the script you download, it could
have severe consequences. It *is* possible to run JavaScript code sandboxed in
Node. Maybe you should consider that, instead of the module approach.
/Jakob
> FWIW, I'm also planning to add an --upgrade option to grab the latest
> version of fulljslint.js, thus rendering the makefile obsolete (cf.
> external dependencies).

[Non-text portions of this message have been removed]

#1849 From: "thomasrutter" <trr@...>
Date: Mon Jan 31, 2011 12:36 am
Subject: Wrapping assignment in extra parentheses no longer working.
thomasrutter
Send Email Send Email
 
The documentation states,

     If you really intend an assignment, wrap it in another set of parens:

     if ((a = b)) {
         ...
     }

This used to work until recently, but now for me, JSLint is giving me this
error:

     Problem at line 32 character 25: Expected a conditional expression and
instead saw an assignment.

     while ((element = element.previousSibling)) {

As you can see from my code, the assignment is wrapped in extra parentheses,
which in my understanding (and the documentation) SHOULD be acceptable to
JSLint.  Indeed, this used to work in JSLint until recently.

Cheers,
Thomas

#1850 From: "Douglas Crockford" <douglas@...>
Date: Mon Jan 31, 2011 1:22 am
Subject: Re: Wrapping assignment in extra parentheses no longer working.
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "thomasrutter" <trr@...> wrote:
>
> The documentation states,
>
>     If you really intend an assignment, wrap it in another set of parens:
>
>     if ((a = b)) {
>         ...
>     }

You are right. Thanks. That has been corrected.

> This used to work until recently, but now for me, JSLint is giving me this
error:
>
>     Problem at line 32 character 25: Expected a conditional expression and
instead saw an assignment.
>
>     while ((element = element.previousSibling)) {
>
> As you can see from my code, the assignment is wrapped in extra parentheses,
which in my understanding (and the documentation) SHOULD be acceptable to
JSLint.  Indeed, this used to work in JSLint until recently.


I found that there were cases where people would take the erroneous code and
wrap parens around it to avoid the warning.

The assumptions behind JSLint call for subsetting the language so that the
correct constructs are more easily distinguished from errors.

#1851 From: "thomasrutter" <trr@...>
Date: Mon Jan 31, 2011 2:53 am
Subject: Re: Wrapping assignment in extra parentheses no longer working.
thomasrutter
Send Email Send Email
 
Unfortunately I'm in the situation of having a large amount of code using the
old jslint custom - a common pattern being

   while ((a = a.next)) {

This code can be rewritten eventually, though in the meantime, there are a lot
of jslint errors coming up for code that I'm confident is working and
well-tested for now.

A jslint flag allowing it to use the old behaviour would be helpful.  Otherwise,
I guess there is
- trying to use an earlier jslint
- ignoring the jslint errors for a while

As for rewriting this code, any equivalent that avoids repeating oneself? e.g.

   a = a.next;
   while (a) {
     //...
     a = a.next;
   }

I'm wondering if I can reach out to other people on this list for suggestions.

Thanks

#1852 From: "luke.a.page" <luke.a.page@...>
Date: Mon Jan 31, 2011 1:14 pm
Subject: Re: [jslint] Re: Wrapping assignment in extra parentheses no longer working.
page.luke...
Send Email Send Email
 
for (a = a.next; a;) {
//...
a = a.next;
}

but generally where there is code repetition (a = a.next) I tend to find a
bigger refactor is needed - why isn't the first a in the while loop? You are
skipping the first element, so make the reason for that obvious by the
structure of the code, instead of trying to disguise it by only executing
the statement once. If you are skipping the head, can you make it more
obvious, e.g.

var head = a; tail = a.next;

//process head

while(tail) {
     // process tail
     tail = tail.next;
}

and then, rather than code repetition you have something that looks like it
is - a statement to get the tail and a while loop to process everything in
the tail.

On 31 January 2011 02:53, thomasrutter <trr@...> wrote:

>
>
> Unfortunately I'm in the situation of having a large amount of code using
> the old jslint custom - a common pattern being
>
> while ((a = a.next)) {
>
> This code can be rewritten eventually, though in the meantime, there are a
> lot of jslint errors coming up for code that I'm confident is working and
> well-tested for now.
>
> A jslint flag allowing it to use the old behaviour would be helpful.
> Otherwise, I guess there is
> - trying to use an earlier jslint
> - ignoring the jslint errors for a while
>
> As for rewriting this code, any equivalent that avoids repeating oneself?
> e.g.
>
> a = a.next;
> while (a) {
> //...
> a = a.next;
> }
>
> I'm wondering if I can reach out to other people on this list for
> suggestions.
>
> Thanks
>
>
>


[Non-text portions of this message have been removed]

#1853 From: Morgaut Alexandre Louis Marc <morgaut@...>
Date: Mon Jan 31, 2011 1:59 pm
Subject: Re: [jslint] Re: Wrapping assignment in extra parentheses no longer working.
morgaut_a
Send Email Send Email
 
> for (a = a.next; a;) {
> //...
> a = a.next;
> }

Which can also be written like this:

for (a = a.next; a; a = a.next) {
   //...
}

This notation show even more explicitly the iteration statement

The second example proposed by luke with head and tail is important,
it gives the code a better semantic

for the same objective, we can also write

var
     current;

for (current = a; current !== undefined; current = current.next) {
    // ...
}


PS:

It could have been even better if JavaScript supported
"current .= next;"
as
"current = current . next;"
and then
"current = current.next;"

But it may be confusing for people coming from PHP ;-)

#1854 From: "Jakob Kruse" <kruse@...>
Date: Mon Jan 31, 2011 4:40 pm
Subject: SV: [jslint] Re: Wrapping assignment in extra parentheses no longer working.
thekrucible
Send Email Send Email
 
And of course, if the intention was to include the first element of the linked
list, the jslint safe version could be:

// initialize a
while (a) {
     // use a
     a = a.next;
}

This being the more common scenario (compared to skipping the first element) is
probably part of the reason why jslint frowns on “while (a = a.next)”.

/Jakob

[Non-text portions of this message have been removed]

Messages 1825 - 1854 of 3202   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help