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

Re: [jslint] How to lint a file with circular function calls ?

Expand Messages
  • Marcel Duran
    (function () { use strict ; var a, b, c, d; a = function () {}; b = function () {}; c = function () {b(c); a(d); }; d = function () {b(a); a(c); }; c(); d();
    Message 1 of 7 , Sep 7, 2012
    • 0 Attachment
      (function () {
      "use strict";
      var a, b, c, d;

      a = function () {};
      b = function () {};
      c = function () {b(c); a(d); };
      d = function () {b(a); a(c); };
      c();
      d();
      }());

      @marcelduran


      On Fri, Sep 7, 2012 at 12:56 PM, thomastraub2000
      <thomastraub2000@...>wrote:

      > **
      >
      >
      > Hi,
      >
      > I have a module which toggles two group of event handlers :
      >
      > // structure
      > (function () {
      > "use strict";
      > function a() {}
      > function b() {}
      > function c() {b(c); a(d); }
      > function d() {b(a); a(c); }
      > c();
      > d();
      > }());
      >
      > I cannot lint this file, in strict mode undef won't work.
      > To my surprise it does not lint in sloppy mode, neither (/*jslint undef:
      > true, sloppy: true */)
      >
      > I cannot think of another way to structure my code (avoiding calls prior
      > declaration)
      >
      > Thanks for Your attention,
      >
      > Thomas
      >
      > here the actual code (reduced):
      >
      > // Instructions for JSLint, see [jslint.com](http://www.jslint.com)
      > /*jslint undef: true, browser: true */
      >
      > // This projects namespace
      > var Sem = Sem || {};
      >
      > // #Gallery Image Drag'n Drop Module
      > //
      > // Allow the user to add images to an
      > // existing image gallery
      > (function (Sem) {
      >
      > "use strict";
      >
      > function addClickEvent(clickType, handler) {
      >
      > var i, els = document.querySelectorAll('.gallery');
      >
      > for (i = 0; i < els.length; i += 1) {
      >
      > els[i].addEventListener(clickType, handler, false);
      > }
      > }
      >
      > function removeClickEvent(clickType, handler) {
      >
      > var i, els = document.querySelectorAll('.gallery');
      >
      > for (i = 0; i < els.length; i += 1) {
      >
      > els[i].removeEventListener(clickType, handler, false);
      > }
      > }
      >
      > function openList(ev) {
      >
      > if (ev.target && ev.target.nodeName === 'IMG') {
      >
      > removeClickEvent('dblclick', openList);
      > addClickEvent('dblclick', closeList);
      >
      > // removed
      > }
      > }
      >
      > function closeList(ev) {
      >
      > if (ev.target && ev.target.nodeName === 'IMG') {
      >
      > removeClickEvent('dblclick', closeList);
      > addClickEvent('dblclick', openList);
      >
      > // removed
      > }
      > }
      >
      > if (document.addEventListener) {
      >
      > document.addEventListener('DOMContentLoaded', function () {
      >
      > Sem.closeList = closeList;
      > Sem.openList = openList;
      >
      > }, false);
      > }
      >
      > }(Sem));
      >
      >
      >


      [Non-text portions of this message have been removed]
    • thomastraub2000
      Thanks, I should have thought of that
      Message 2 of 7 , Sep 7, 2012
      • 0 Attachment
        Thanks, I should have thought of that

        --- In jslint_com@yahoogroups.com, "Felix E. Klee" <felix.klee@...> wrote:
        >
        > (function () {
        > "use strict";
        >
        > var d;
        >
        > function a() {}
        > function b() {}
        > function c() { b(c); a(d); }
        > d = function () { b(a); a(c); };
        > c();
        > d();
        > }());
        >
      • thomastraub2000
        Thanks, it s just that I liked my notation so much that I did not want to remember how it can be done.
        Message 3 of 7 , Sep 8, 2012
        • 0 Attachment
          Thanks, it's just that I liked my notation so much that I did not want to remember how it can be done.

          --- In jslint_com@yahoogroups.com, Marcel Duran <marcelduran@...> wrote:
          >
          > (function () {
          > "use strict";
          > var a, b, c, d;
          >
          > a = function () {};
          > b = function () {};
          > c = function () {b(c); a(d); };
          > d = function () {b(a); a(c); };
          > c();
          > d();
          > }());
        Your message has been successfully submitted and would be delivered to recipients shortly.