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 9:46 AM
    • 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 11:21 AM
      • 0 Attachment
        Thanks, I should have thought of that


        --- In jslint_com@yahoogroups.com, Mike On Mobile <z_mikowski@...> wrote:
        >
        > Assign your functions to variables. Declare your variables at the top of your script.
        >
        > "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();
        > >}());
        > >
        > >
        > >
        > ><!-- #ygrp-mkp { border: 1px solid #d8d8d8; font-family: Arial; margin: 10px 0; padding: 0 10px; } #ygrp-mkp hr { border: 1px solid #d8d8d8; } #ygrp-mkp #hd { color: #628c2a; font-size: 85%; font-weight: 700; line-height: 122%; margin: 10px 0; } #ygrp-mkp #ads { margin-bottom: 10px; } #ygrp-mkp .ad { padding: 0 0; } #ygrp-mkp .ad p { margin: 0; } #ygrp-mkp .ad a { color: #0000ff; text-decoration: none; } #ygrp-sponsor #ygrp-lc { font-family: Arial; } #ygrp-sponsor #ygrp-lc #hd { margin: 10px 0px; font-weight: 700; font-size: 78%; line-height: 122%; } #ygrp-sponsor #ygrp-lc .ad { margin-bottom: 10px; padding: 0 0; } a { color: #1e66ae; } #actions { font-family: Verdana; font-size: 11px; padding: 10px 0; } #activity { background-color: #e0ecee; float: left; font-family: Verdana; font-size: 10px; padding: 10px; } #activity span { font-weight: 700; } #activity span:first-child { text-transform: uppercase; } #activity span a { color: #5085b6; text-decoration: none; } #activity span span { color: #ff7900; } #activity span .underline { text-decoration: underline; } .attach { clear: both; display: table; font-family: Arial; font-size: 12px; padding: 10px 0; width: 400px; } .attach div a { text-decoration: none; } .attach img { border: none; padding-right: 5px; } .attach label { display: block; margin-bottom: 5px; } .attach label a { text-decoration: none; } blockquote { margin: 0 0 0 4px; } .bold { font-family: Arial; font-size: 13px; font-weight: 700; } .bold a { text-decoration: none; } dd.last p a { font-family: Verdana; font-weight: 700; } dd.last p span { margin-right: 10px; font-family: Verdana; font-weight: 700; } dd.last p span.yshortcuts { margin-right: 0; } div.attach-table div div a { text-decoration: none; } div.attach-table { width: 400px; } div.file-title a, div.file-title a:active, div.file-title a:hover, div.file-title a:visited { text-decoration: none; } div.photo-title a, div.photo-title a:active, div.photo-title a:hover, div.photo-title a:visited { text-decoration: none; } div#ygrp-mlmsg #ygrp-msg p a span.yshortcuts { font-family: Verdana; font-size: 10px; font-weight: normal; } .green { color: #628c2a; } .MsoNormal { margin: 0 0 0 0; } o { font-size: 0; } #photos div { float: left; width: 72px; } #photos div div { border: 1px solid #666666; height: 62px; overflow: hidden; width: 62px; } #photos div label { color: #666666; font-size: 10px; overflow: hidden; text-align: center; white-space: nowrap; width: 64px; } #reco-category { font-size: 77%; } #reco-desc { font-size: 77%; } .replbq { margin: 4px; } #ygrp-actbar div a:first-child { /* border-right: 0px solid #000;*/ margin-right: 2px; padding-right: 5px; } #ygrp-mlmsg { font-size: 13px; font-family: Arial, helvetica,clean, sans-serif; *font-size: small; *font: x-small; } #ygrp-mlmsg table { font-size: inherit; font: 100%; } #ygrp-mlmsg select, input, textarea { font: 99% Arial, Helvetica, clean, sans-serif; } #ygrp-mlmsg pre, code { font:115% monospace; *font-size:100%; } #ygrp-mlmsg * { line-height: 1.22em; } #ygrp-mlmsg #logo { padding-bottom: 10px; } #ygrp-mlmsg a { color: #1E66AE; } #ygrp-msg p a { font-family: Verdana; } #ygrp-msg p#attach-count span { color: #1E66AE; font-weight: 700; } #ygrp-reco #reco-head { color: #ff7900; font-weight: 700; } #ygrp-reco { margin-bottom: 20px; padding: 0px; } #ygrp-sponsor #ov li a { font-size: 130%; text-decoration: none; } #ygrp-sponsor #ov li { font-size: 77%; list-style-type: square; padding: 6px 0; } #ygrp-sponsor #ov ul { margin: 0; padding: 0 0 0 8px; } #ygrp-text { font-family: Georgia; } #ygrp-text p { margin: 0 0 1em 0; } #ygrp-text tt { font-size: 120%; } #ygrp-vital ul li:last-child { border-right: none !important; } -->
        >
        > [Non-text portions of this message have been removed]
        >
      • thomastraub2000
        Thanks, I should have thought of that
        Message 3 of 7 , Sep 7 11:21 AM
        • 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 4 of 7 , Sep 8 4:36 AM
          • 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.