Loading ...
Sorry, an error occurred while loading the content.

2052[jslint] Re: JSLint Bug?

Expand Messages
  • spence.randall@ymail.com
    Mar 10, 2011
    • 0 Attachment
      Deprecated? No, I don't think so. There are almost always better ways of writing statements that more explicitly define what you are attempting to do without resorting to continue. JSLint is all about the good parts, and not about the parts that are acceptable. It forces you to use a higher standard than the one defined.

      Douglas says it best in his book:

      "The continue statement jumps to the top of the loop. I have never seen a piece of code that was not improved by refactoring it to remove the continue statement."

      -Randall

      --- In jslint_com@yahoogroups.com, Lindsay John Lawrence <thinknlive@...> wrote:
      >
      > Thanks! Why the change though? Is 'continue' being deprecated in the language?
      >
      > --Lindsay
      >
      >
      > --- On Thu, 3/10/11, spence.randall@... <randall@...> wrote:
      >
      > From: spence.randall@... <randall@...>
      > Subject: [jslint] Re: JSLint Bug?
      > To: jslint_com@yahoogroups.com
      > Date: Thursday, March 10, 2011, 11:00 AM
      >
      >
      >
      >
      >
      >
      >
      >  
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > It's not a bug, JSLint has a new(ish) "Tolerate continue" option. You can check that box in options, or add /*jslint continue:true*/ to your code.
      >
      >
      >
      > Or you could refactor your code to avoid the use of continue. In your example, you could just set i = 5 in the loop and drop the if check, or check if i > 5 then run nop().
      >
      >
      >
      > -Randall
      >
      >
      >
      > --- In jslint_com@yahoogroups.com, Lindsay John Lawrence <thinknlive@> wrote:
      >
      > >
      >
      > > Hello,
      >
      > >
      >
      > >       Problem at line 9 character 7: Unexpected 'continue'.
      >
      > >
      >
      > >
      >
      > > I now get an error like the above with loops that have a 'continue' of the form shown in the sample code below.
      >
      > >
      >
      > > Is this a bug in jslint or is it now enforcing some form I am not aware of?
      >
      > >
      >
      > > // --- start sample code ---
      >
      > > var nop = function () {
      >
      > >   return;
      >
      > > };
      >
      > >
      >
      > > var test = function () {
      >
      > >   var i;
      >
      > >   for (i=0; i<10; i+=1) {
      >
      > >     if (i<5) {
      >
      > >       continue;
      >
      > >     }
      >
      > >     nop();
      >
      > >   }
      >
      > > };
      >
      > > // --- end sample code ---
      >
      > >
      >
      > > Thanks in advancet,
      >
      > >
      >
      > > Lindsay
      >
      > >
      >
      > >
      >
      > >
      >
      > >
      >
      > >
      >
      > > [Non-text portions of this message have been removed]
      >
      > >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • Show all 24 messages in this topic