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

Re: Undetected errors

Expand Messages
  • Douglas Crockford
    ... return is short for return undefined; or return this;. Both are reasonable return values. I don t see a problem there. ... Missing default is not an error.
    Message 1 of 2 , May 27, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Jean-Charles Meyrignac <jcmeyrignac@...> wrote:
      >
      > JavascriptLint (or Firefox in maximum JS warning) is able to detect some
      > errors that JsLint doesn't see.
      >
      > The first is the ability to detect return values:
      >
      > buggy = function(ev) {
      > if (this.cursor[0] < 0 && this.cursor[1] < 0) {
      > return;
      > }
      >
      > if (ev.which == 0x20) {
      > return false;
      > }
      > }

      return is short for return undefined; or return this;.
      Both are reasonable return values. I don't see a problem there.


      > C:\Program Files\jsl-0.3.0\grid.js(351): warning: anonymous function does
      > not always return a value
      > return false;
      > ....................^
      >
      >
      > The second one is to detect missing default: in switch():
      > switch(a)
      > {
      > case 1:
      > break;
      > }
      >
      > C:\Program Files\jsl-0.3.0\grid.js(425): lint warning: missing default case
      > in switch statement
      > }
      > ........^

      Missing default is not an error.

      There is a balance here. I try to only report problems that are likely to lead to improvements in code quality. Some might argue with my choices, but that is the intent. I don't want to be rubbing people's faces into things of no consequence.
    Your message has been successfully submitted and would be delivered to recipients shortly.