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

2206Re: possible erroneous warning due to multi-line layout

Expand Messages
  • Douglas Crockford
    May 12, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Zhami" <stuart@...> wrote:
      >
      > I am receiving a warning about mis-positioning of text.
      > My practice is to declare my vars on multiple lines, where I distinguish
      > vars that hold variables from vars that hold functions, as is done in
      > the code snippet below (I have hollowed this out from actual code).
      > I use tabs for indenting, but substitute with leading periods so that
      > they are preserved ... please convert back to examine this in JSLint, or
      > pull from my gist: https://gist.github.com/969076
      > (function () {."use strict";
      > .var processTheForm;
      > .processTheForm = function () {
      > ..var resultObjHash,...// functions...createElemHandler,
      > createResultObj;
      > ..createElemHandler = function () {..}; ..createResultObj = function ()
      > {..}; ..resultObjHash = {}; .};}());
      > JSLint reportsProblem at line 11 character 32: Expected
      > 'createResultObj' at column 13, not column 32.
      > This warning will go away if a second non-function var is declared on
      > the first line of the var statement, as in:
      > ..var resultObjHash, another,
      > I believe that the warning reported when only one var is declared on the
      > first line is innapropriate.


      You have two options. You can either format it like this:

      (function () {
      ````'use strict';
      ````var processTheForm;
      ````processTheForm = function () {
      ````````var resultObjHash, // functions
      ````````````createElemHandler,
      ````````````createResultObj;
      ````````createElemHandler = function () {
      ````````};
      ````````createResultObj = function () {
      ````````};
      ````````resultObjHash = {};
      ````};
      }());

      or you can turn off the strict whitespace option.
    • Show all 7 messages in this topic