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

479getJSLintOptions()

Expand Messages
  • christian.wirkus
    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
    • Show all 2 messages in this topic