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

Re: onevar

Expand Messages
  • Chris
    ... ASP uses to delimit areas of server-side ASP code. As ASP code can take the form of JScript, I have found JSLint to be a useful tool for
    Message 1 of 6 , Aug 23 12:41 PM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
      wrote:
      >
      > I increased the amount of rigor required of HTML files. Initially,
      > checking of HTML was minimal, just enough to locate the scripts.
      > JSLint seems to be evolving into an HTML verifier.
      >
      > There are a lot of changes in this update. Please let me know if I
      > broke anything.
      >

      ASP uses "<%" and "%>" to delimit areas of server-side ASP code. As ASP
      code can take the form of JScript, I have found JSLint to be a useful
      tool for maintaining this code.

      With the 2008-08-18 edition, this has become considerably more
      inconvenient. I now receive the following error:

      Problem at line 1 character 1: Bad identifier %.
      <%@Language="VBScript" CodePage=65001 %>

      Problem at line 1 character 1: Unrecognized tag '<%>'.
      <%@Language="VBScript" CodePage=65001 %>

      Problem at line 1 character 1: Stopping, unable to continue. (0%
      scanned).

      I can work around this by copy-pasting only the necessary portions to
      check, but of course, the line numbers no longer match up if I do this.

      Previously, the "Tolerate HTML fragments" option would allows these
      sorts of files to be checked, and now it won't. I do not know if this
      should be "fixed" or not. Perhaps it is more correct the way it is. I
      do note that Javascript can show up in some very surprising
      places--including some places that look like HTML but are not--and this
      change reduces the usefulness of JSLint to me.

      I also wonder what else may be broken by this. I know JavaScript can be
      used inside SVG files, using the familiar <script> tag. I tested one of
      these with the 2008-08-18 version, and found a similar error message: it
      refuses to scan past the <svg> on line one.

      Alas.



      [Non-text portions of this message have been removed]
    • santini.alberto
      ... [cut] ... I modified my code conventions. Before I wrote for the inner functions var my_function = function () { ... } Now, modifying the code complaining
      Message 2 of 6 , Sep 3, 2008
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
        wrote:
        >
        > I added a onevar option. It allows only one var statement per function.
        >
        [cut]
        >
        > There are a lot of changes in this update. Please let me know if I
        > broke anything.
        >

        I modified my code conventions.

        Before I wrote for the inner functions

        var my_function = function () {
        ...
        }

        Now, modifying the code complaining with onevar option, I have been
        writing

        function my_function() {
        ...
        }

        So I have not to define at the beginning of the (outer) function the
        variable containing the (inner) function.

        I know the two style are equivalents, but I was wondering if there is
        a subtle difference, maybe about the scope, I am missing. What is your
        style?

        Thanks in advance,
        Alberto Santini
      • ojacquem
        Hello, ... function. ... Personally I don t think this practice should be recommended. It contradicts the related recommendation in the Code Conventions
        Message 3 of 6 , Oct 17, 2008
        • 0 Attachment
          Hello,

          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
          wrote:
          >
          > I added a onevar option. It allows only one var statement per
          function.
          >
          Personally I don't think this practice should be recommended.
          It contradicts the related recommendation in the Code Conventions
          <http://javascript.crockford.com/code.html> page :-)

          It is preferred that each variable be given its own line and comment.
          (...)
          var currentEntry; // currently selected table entry

          var level; // indentation level
          var size; // size of table
          With a single var statement, all variables will typically be defined on
          the same line without comments, decreasing readability &
          maintainability.
          "Small code is more efficient in JavaScript"? This is the job of a
          minifier.

          Suggestion: check that all var statements are grouped at the beginning
          of the function. This will guarantee that scope problems are avoided,
          which was the purpose of introducing onevar, as I understand it.



          [Non-text portions of this message have been removed]
        • Jakob Kruse
          What s wrong with: var var1, // comment var2, // comment var3; // comment It usually works for me. /Jakob ... From: ojacquem To: jslint_com@yahoogroups.com
          Message 4 of 6 , Oct 17, 2008
          • 0 Attachment
            What's wrong with:

            var var1, // comment
            var2, // comment
            var3; // comment

            It usually works for me.

            /Jakob


            ----- Original Message -----
            From: ojacquem
            To: jslint_com@yahoogroups.com
            Sent: Friday, October 17, 2008 3:36 PM
            Subject: [jslint] Re: onevar


            Hello,

            --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
            wrote:
            >
            > I added a onevar option. It allows only one var statement per
            function.
            >
            Personally I don't think this practice should be recommended.
            It contradicts the related recommendation in the Code Conventions
            <http://javascript.crockford.com/code.html> page :-)

            It is preferred that each variable be given its own line and comment.
            (...)
            var currentEntry; // currently selected table entry

            var level; // indentation level
            var size; // size of table
            With a single var statement, all variables will typically be defined on
            the same line without comments, decreasing readability &
            maintainability.
            "Small code is more efficient in JavaScript"? This is the job of a
            minifier.

            Suggestion: check that all var statements are grouped at the beginning
            of the function. This will guarantee that scope problems are avoided,
            which was the purpose of introducing onevar, as I understand it.

            [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.