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

Re: RE: [jslint] Error Suggestion

Expand Messages
  • Luke Page
    Would it not be something like if the line above was an expression not ending in an operator or semi colon? In a similar way to jslints existing warning about
    Message 1 of 6 , Jan 4, 2011
    • 0 Attachment
      Would it not be something like if the line above was an expression not
      ending in an operator or semi colon? In a similar way to jslints existing
      warning about invalid line break if you have

      a
      +b

      Where jslint requires

      a+
      b
      On 5 Jan 2011 06:54, "Rob Richardson" <erobrich@...> wrote:
      > I like noting that a function execution without a function name is an
      error,
      > but how do we know it was a function execution and not parentheses for the
      > purpose of insuring math order of precedence?
      >
      > Rob
      >
      >
      > -----Original Message-----
      > From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On
      > Behalf Of Erik Eckhardt
      > Sent: Tuesday, January 04, 2011 10:04 PM
      > To: jslint_com@yahoogroups.com
      > Subject: Re: [jslint] Error Suggestion
      >
      > Most certainly a mistake, since a function invocation requires the opening
      > parenthesis right after the function name.
      >
      > So even if the function returned a function which was immediately
      executed,
      > putting it on the next line would be a mistake. I for one vote for your
      > suggestion to flag the line breaking you suggested as invalid.
      >
      > function fnReturningFn() {
      > return function() {alert('Hello World!');};
      > }
      >
      > fnReturningFn()(); // not sure if this is valid, but why not?
      >
      > fnReturningFn()
      > ___(); // I'm sure this isn't right
      >
      > On Tue, Jan 4, 2011 at 11:14 AM, Luke Page <luke.a.page@...> wrote:
      >
      >>
      >>
      >> yes and I don't think that should be stopped, but would it make sense to
      >> have
      >>
      >>
      >> $('#id').appendChild
      >> (div).css
      >> ('background-color', 'blue').show();
      >>
      >> I think that would always be a mistake?
      >>
      >>
      >> On 4 January 2011 18:37, Erik Eckhardt
      > <erik@...<erik%40eckhardts.com>>
      >> wrote:
      >>
      >> > In popular javascript libraries like jQuery that use chaining, line
      >> breaks
      >> > are common:
      >> >
      >> > $('#id').appendChild(div)
      >> > ___.css('background-color', 'blue')
      >> > ___.show();
      >> >
      >> > On Tue, Jan 4, 2011 at 5:50 AM, Luke Page
      > <luke.a.page@...<luke.a.page%40gmail.com>>
      >> wrote:
      >> >
      >> > >
      >> > >
      >> > > Can I suggest there should not be allowed to be a line break between
      a
      >> > > function and invoking it?
      >> > >
      >> > > I had something like the following code
      >> > >
      >> > > var a = b && (c || d)
      >> > > (e || f).push(g);
      >> > >
      >> > > where I had mistakenly missed a semi-colon and it was not picked up
      by
      >> > > JSLint.
      >> > >
      >> > > it causes an error because the result of "b && (c || d)" is a boolean
      >> and
      >> > > it
      >> > > is being run as a function.
      >> > >
      >> > > Would it ever be valid (or good practice) to have a newline before a
      >> > > function execution or is there some other way to pick this up in
      >> JSLint?
      >> > >
      >>
      >
      >
      > [Non-text portions of this message have been removed]
      >
      >


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.