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

1047Re: [jslint] Re: several JSLint errors I can't understand

Expand Messages
  • Tom Byers
    Jan 7, 2010
    • 0 Attachment
      Interesting and kind of a catch 22. If �kr�m substitutes let and const then
      he is using the syntax of the language he is working in against the spec,
      the very thing JSLint is meant to prevent.

      From what I read let is an additional way to define block scope so you could
      do some pre-processing that wrapped it in a function and split the variable
      assignments in the brackets out into separate variable assignments. This
      should let you test the scope correctly:

      var x = 5;
      var y = 0;

      let (x = x+10, y = 12) {
      print(x+y + "\n");
      }

      print((x + y) + "\n");

      as

      var x = 5;
      var y = 0;

      var let1 = function() {
      var x = x+10, y = 12;
      print(x+y + "\n");
      }

      print((x + y) + "\n");

      Print should also be commented.

      As for const, this provides something that standard Javascript doesn't
      currently support - proper constants. You can declare them as vars for the
      purposes of Linting but this JSLint will not actually check that your
      developers are staying true to the syntax.

      https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/const

      Tom

      p.s. don't worry to Simon, just trying to get this interesting discussion
      back on track :)

      On Thu, Jan 7, 2010 at 1:18 PM, Ekrem Tomur <ekrem.tomur@...> wrote:

      >
      >
      > Hi Harry,
      >
      > Thank you for your helpful thoughts. But since I am a tester on a mozilla
      > extension project and those js code I am testing meant to run on mozilla
      > javascript engine, I can not ask developers to use standard javascript
      > instead of mozilla one. I must test their code, I hope JSLint can help me a
      > little bit.
      >
      > You are right, now I also think treating let and const as var is a bad
      > idea,
      > since they are not quiet similar and also should be tested as a way they
      > should be tested. So I like Tom's idea, add an Mozilla option since this is
      > also quiet popular version of JS. If that could be done I will happy to
      > contribute.
      >
      > Br,
      > �kr�m
      >
      > On Thu, Jan 7, 2010 at 2:45 PM, Harry Whitfield <g7awz@...<g7awz%40btinternet.com>
      > >wrote:
      >
      >
      > >
      > >
      > > �kr�m,
      > >
      > > Instead of trying to modify JSLint to accept non-standard JavaScript, you
      > > could consider altering the JavaScript code to make it conform to the
      > > standard.
      > > That would be my preferred solution.
      > >
      > > Another possibility would be to pre-process the code to replace "let" and
      > > "const" by "var". It would also be fairly easy to modify JSLint or its
      > file
      > > input code to do that.
      > > However, if I remember correctly, the semantics of "let" is not quite the
      > > same as that of "var".
      > >
      > > Harry.
      > >
      > >
      > >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 16 messages in this topic