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

getJSLintOptions()

Expand Messages
  • christian.wirkus
    Hello! I think really neat would be something that generates the jslint-options-string (/*jslint ... */). I am writing a small Javascript Library and had the
    Message 1 of 2 , May 5, 2009
    • 0 Attachment
      Hello!
      I think really neat would be something that generates the
      jslint-options-string (/*jslint ... */).
      I am writing a small Javascript Library and had the good-parts
      and the assume-a-browser in my jslint-options; now I learned
      the good-parts have altered and I manually changed the string.
      I wrote myself this method to run in the js-console to get the
      checked options more convenient.

      var getJSLintOptions = function () {
      var result = [],
      walkTheDom = function walk(node, func) {
      func(node);
      node = node.firstChild;

      while (node) {
      walk(node, func);
      node = node.nextSibling;
      }
      };

      walkTheDom(document.getElementById("options"), function (node) {
      var nodeName = node.nodeName.toLowerCase(),
      id, type;
      if (nodeName === "input") {
      id = node.getAttribute("id");
      type = node.getAttribute("type");
      if (type === "checkbox" && node.checked) {
      result.push(id + ": true");
      }
      if (type === "text" && node.value) {
      result.push(id + ": " + node.value);
      }
      }
      });

      result = "\/*jslint " + result.join(", ") + " *\/";
      return result;
      };

      For this is my first post here, I think I might conclude:
      Thanks for JSLint (and the walkTheDom method)

      Christian
    • Douglas Crockford
      ... Interesting idea. http://www.JSLint.com/index.html now provides assistance in building /*jslint*/ and /*global*/ comments.
      Message 2 of 2 , May 5, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "christian.wirkus" <christian.wirkus@...> wrote:
        >
        > Hello!
        > I think really neat would be something that generates the
        > jslint-options-string (/*jslint ... */).

        Interesting idea.

        http://www.JSLint.com/index.html now provides assistance in building /*jslint*/ and /*global*/ comments.
      Your message has been successfully submitted and would be delivered to recipients shortly.