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

js_beautify bookmarklet

Expand Messages
  • walfisch1
    My new employer has a non-JSLint-compliant white-space code convention. No options will make this validate. To use JSLint nontheless I wrote a bookmarklet that
    Message 1 of 5 , Jan 26, 2011
    • 0 Attachment
      My new employer has a non-JSLint-compliant white-space code convention. No options will make this validate.
      To use JSLint nontheless I wrote a bookmarklet that fetches jsbeautifier and beautifies the JSLint input field.
      Feel free to use or modify.
      (You want to see this monospaced and indented? Click "Show Message Option" on the right and select "Use Fixed Width Font".)

      /*global js_beautify*/
      (function () {
      var execute, input, lock, script;

      execute = function () {
      if (lock) {
      setTimeout(execute, 1000);
      return;
      }
      input = document.getElementById("JSLINT_INPUT");
      input.value = js_beautify(input.value, {
      space_after_anon_function: true
      });
      };

      if (typeof js_beautify === "undefined" &&
      !document.getElementById("_beauty_lint_")) {
      lock = true;
      script = document.createElement("script");
      script.id = "_beauty_lint_";
      script.src = "http://jsbeautifier.org/beautify.js";
      script.onload = function () {
      lock = false;
      };
      document.body.appendChild(script);
      }

      execute();
      }());
    • walfisch1
      Here is an example, why I did that: /*jslint white: false, indent: 0 */ if(1) { var x = 2; } Error: Problem at line 2 character 3: Expected exactly one space
      Message 2 of 5 , Jan 26, 2011
      • 0 Attachment
        Here is an example, why I did that:

        /*jslint white: false, indent: 0 */
        if(1)
        {
        var x = 2;
        }


        Error:

        Problem at line 2 character 3: Expected exactly one space between 'if' and '('.

        if(1)

        Problem at line 3 character 1: Expected exactly one space between ')' and '{'.

        {
      • Douglas Crockford
        ... I made JSLint in the hope of removing a little bit of stupidity from the world. This makes me sad.
        Message 3 of 5 , Jan 27, 2011
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "walfisch1" <christian.wirkus@...> wrote:
          >
          > My new employer has a non-JSLint-compliant white-space code convention. No options will make this validate.
          > To use JSLint nontheless I wrote a bookmarklet that fetches jsbeautifier and beautifies the JSLint input field.
          > Feel free to use or modify.

          I made JSLint in the hope of removing a little bit of stupidity from the world. This makes me sad.
        • walfisch1
          I m sorry to hear that. JSLint is a great tool. I don t want to miss it just because the whitespace doesn t match with my new code conventions.
          Message 4 of 5 , Jan 27, 2011
          • 0 Attachment
            I'm sorry to hear that.
            JSLint is a great tool. I don't want to miss it just because the whitespace doesn't match with my new code conventions.
          • walfisch1
            I know it s your program, sorry I treated it that way.
            Message 5 of 5 , Jan 27, 2011
            • 0 Attachment
              I know it's your program, sorry I treated it that way.

              --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
              >
              > --- In jslint_com@yahoogroups.com, "walfisch1" <christian.wirkus@> wrote:
              > >
              > > My new employer has a non-JSLint-compliant white-space code convention. No options will make this validate.
              > > To use JSLint nontheless I wrote a bookmarklet that fetches jsbeautifier and beautifies the JSLint input field.
              > > Feel free to use or modify.
              >
              > I made JSLint in the hope of removing a little bit of stupidity from the world. This makes me sad.
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.