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

undef not working?

Expand Messages
  • ormico
    I posted this question on stackoverflow before I got access to this group.
    Message 1 of 3 , Aug 17 11:09 PM
    • 0 Attachment
      I posted this question on stackoverflow before I got access to this group.

      http://stackoverflow.com/questions/12013406/jslint-still-giving-warning-x-was-used-before-it-was-defined-even-when-undef

      You can read there for the full explanation, but essentially I'm trying to get some js to pass and I'm defining the undef flag but the jslint website is still issuing warnings that I'm using items before they are defined.

      Is this a bug in http://jslint.com or am I misunderstanding what this flag does.

      Here is the js that I'm testing (also on stackoverflow):
      /*jslint undef: true, white: true, browser: true */
      /*global jQuery */

      (function($){
      "use strict";

      $(function() {
      createDashboard();
      loadDashboardDataFromControls();
      });

      function loadDashboardDataFromControls()
      {
      }

      function createDashboard()
      {
      }
      }(jQuery));
    • Felix E. Klee
      ... According to JSLint source code, in strict mode, the `undef` flag is set to `false: function use_strict() { if (next_token.string === use strict ) { if
      Message 2 of 3 , Aug 18 12:43 AM
      • 0 Attachment
        On Sat, Aug 18, 2012 at 8:09 AM, ormico <tzmoore@...> wrote:
        > Is this a bug in http://jslint.com or am I misunderstanding what this
        > flag does. [...]

        According to JSLint source code, in strict mode, the `undef` flag is set
        to `false:

        function use_strict() {
        if (next_token.string === 'use strict') {
        if (strict_mode) {
        warn('unnecessary_use');
        }
        edge();
        advance();
        semicolon();
        strict_mode = true;
        option.undef = false;
        return true;
        }
        return false;
        }
      • Felix E. Klee
        Some thoughts: While in strict mode, variables need to be defined before being used, your code obviously *does not* violate that rule. So, in my opinion, what
        Message 3 of 3 , Aug 18 2:29 AM
        • 0 Attachment
          Some thoughts: While in strict mode, variables need to be defined before
          being used, your code obviously *does not* violate that rule. So, in my
          opinion, what we see is at least a documentation bug: JSLint
          documentation should state that in strict mode, the `undef` flag is set
          to `false`.
        Your message has been successfully submitted and would be delivered to recipients shortly.