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

Re: [jslint] Can JSLint work on multiple files?

Expand Messages
  • Eriks Nukis
    Hi, Or JSLint plugin for Sonar: http://docs.codehaus.org/display/SONAR/JavaScript+Plugin Regards, Eriks On Saturday, December 24, 2011, Toby Maxwell-Lyte
    Message 1 of 9 , Dec 24, 2011
    • 0 Attachment
      Hi,

      Or JSLint plugin for Sonar:
      http://docs.codehaus.org/display/SONAR/JavaScript+Plugin

      Regards,
      Eriks


      On Saturday, December 24, 2011, Toby Maxwell-Lyte <
      toby.maxwelllyte@...> wrote:
      >
      >
      > For JSLinting whole projects take a look at the JSLint-4-Java ant task.
      >
      > http://docs.jslint4java.googlecode.com/git/2.0.1/ant.html
      >
      > Regards,
      > Toby
      >
      > On 23 December 2011 16:52, mruhrbach <mruhrbach@...> wrote:
      >> Gentlemen,
      >>
      >> after setting JSLint loose on my code I find myself with some bugs
      corrected. However, as my project is set up in many separate script files,
      I have to define a lot of global parser instructions just to tell JSLint
      that the given variables exist (in other files).
      >>
      >> Files may be included through window.importScripts() or HTML <script/>
      blocks.
      >>
      >> This made me wonder:
      >>
      >> - can you tell JSLint to honor [window].importScripts()?
      >> - can you tell JSLint to work on a folder instead of a single file?
      >>
      >> I'd be interested to learn how you cope with this issue in your
      projects. Here, I am using the maven plugin:
      http://mojo.codehaus.org/jslint-maven-plugin/
      >>
      >> Thanks!
      >>
      >>
      >>
      >> ------------------------------------
      >>
      >> Yahoo! Groups Links
      >>
      >>
      >>
      >
      > --
      > Toby Maxwell-Lyte
      > 07816 836300
      > 01443 239692
      >
      >


      [Non-text portions of this message have been removed]
    • Mark Ruhrbach
      Hi Toby, thanks for the link. I have tested it in my project. It appears the Ant task shows the same behaviour as the Maven plugin: both require /*global ...*/
      Message 2 of 9 , Dec 25, 2011
      • 0 Attachment
        Hi Toby,

        thanks for the link. I have tested it in my project. It appears the Ant task shows the same behaviour as the Maven plugin: both require /*global ...*/ comments to work.

        I have attached a small sample program to demonstrate the issue.

        To recap: in a large project with many JS files, there should be a way to tell JSLint to look at the entire set of files. Thus, if one library file contains function doSomething(), the other files could use this function right away, without writing in each file:

        /*global doSomething: false*/

        (Having one responsibility per file is considered good practice, even if the file might be merged by a minifier later.) The Ant task can be told what globals exists program wide. The problem here would be it still requires management of known variables, making working with many files cumbersome - to some degree.


        How do you guys feel about it?

        Best regards,


        ________________________________
        From: Toby Maxwell-Lyte <toby.maxwelllyte@...>
        To: jslint_com@yahoogroups.com
        Sent: Saturday, December 24, 2011 3:31 PM
        Subject: Re: [jslint] Can JSLint work on multiple files?


         
        For JSLinting whole projects take a look at the JSLint-4-Java ant task.

        http://docs.jslint4java.googlecode.com/git/2.0.1/ant.html

        Regards,
        Toby

        On 23 December 2011 16:52, mruhrbach <mruhrbach@...> wrote:
        > Gentlemen,
        >
        > after setting JSLint loose on my code I find myself with some bugs corrected. However, as my project is set up in many separate script files, I have to define a lot of global parser instructions just to tell JSLint that the given variables exist (in other files).
        >
        > Files may be included through window.importScripts() or HTML <script/> blocks.
        >
        > This made me wonder:
        >
        > - can you tell JSLint to honor [window].importScripts()?
        > - can you tell JSLint to work on a folder instead of a single file?
        >
        > I'd be interested to learn how you cope with this issue in your projects. Here, I am using the maven plugin: http://mojo.codehaus.org/jslint-maven-plugin/
        >
        > Thanks!
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >

        --
        Toby Maxwell-Lyte
        07816 836300
        01443 239692



        [Non-text portions of this message have been removed]
      • mruhrbach
        Oops, the attachment got lost. See instead: https://github.com/mruhrbach/jslint-test-fixture ... Ant task shows the same behaviour as the Maven plugin: both
        Message 3 of 9 , Dec 25, 2011
        • 0 Attachment
          Oops, the attachment got lost. See instead:
          https://github.com/mruhrbach/jslint-test-fixture

          --- In jslint_com@yahoogroups.com, Mark Ruhrbach <mruhrbach@...> wrote:
          >
          > Hi Toby,
          >
          > thanks for the link. I have tested it in my project. It appears the
          Ant task shows the same behaviour as the Maven plugin: both require
          /*global ...*/ comments to work.
          >
          > I have attached a small sample program to demonstrate the issue.
          >
          > To recap: in a large project with many JS files, there should be a way
          to tell JSLint to look at the entire set of files. Thus, if one library
          file contains function doSomething(), the other files could use this
          function right away, without writing in each file:
          >
          > /*global doSomething: false*/
          >
          > (Having one responsibility per file is considered good practice, even
          if the file might be merged by a minifier later.) The Ant task can be
          told what globals exists program wide. The problem here would be it
          still requires management of known variables, making working with many
          files cumbersome - to some degree.
          >
          >
          > How do you guys feel about it?
          >
          > Best regards,
          >
          >
          > ________________________________
          > From: Toby Maxwell-Lyte toby.maxwelllyte@...
          > To: jslint_com@yahoogroups.com
          > Sent: Saturday, December 24, 2011 3:31 PM
          > Subject: Re: [jslint] Can JSLint work on multiple files?
          >
          >
          > Â
          > For JSLinting whole projects take a look at the JSLint-4-Java ant
          task.
          >
          > http://docs.jslint4java.googlecode.com/git/2.0.1/ant.html
          >
          > Regards,
          > Toby
          >
          > On 23 December 2011 16:52, mruhrbach mruhrbach@... wrote:
          > > Gentlemen,
          > >
          > > after setting JSLint loose on my code I find myself with some bugs
          corrected. However, as my project is set up in many separate script
          files, I have to define a lot of global parser instructions just to tell
          JSLint that the given variables exist (in other files).
          > >
          > > Files may be included through window.importScripts() or HTML
          <script/> blocks.
          > >
          > > This made me wonder:
          > >
          > > - can you tell JSLint to honor [window].importScripts()?
          > > - can you tell JSLint to work on a folder instead of a single file?
          > >
          > > I'd be interested to learn how you cope with this issue in your
          projects. Here, I am using the maven plugin:
          http://mojo.codehaus.org/jslint-maven-plugin/
          > >
          > > Thanks!
          > >
          > >
          > >
          > > ------------------------------------
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          >
          > --
          > Toby Maxwell-Lyte
          > 07816 836300
          > 01443 239692
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • Frederik Dohr
          ... I very much disagree. Relying heavily on globals like that is a pretty clear sign that something s awry. You might want to use namespaces, i.e. moving
          Message 4 of 9 , Dec 26, 2011
          • 0 Attachment
            > in a large project with many JS files, there should be a way to tell
            > JSLint to look at the entire set of files. Thus, if one library file
            > contains function doSomething(), the other files could use this
            > function right away, without writing in each file:
            > /*global doSomething: false*/

            I very much disagree. Relying heavily on globals like that is a pretty
            clear sign that something's awry.

            You might want to use namespaces, i.e. moving related objects into a
            single global object:

            ....MYLIB = {
            ........HelloWorld: function ... ,
            ........LoremIpsum: ...
            ....};


            -- F.
          • mruhrbach
            Hi F., I agree that globals should be minimized. Just here is where the beast starts to chase its own tail. In any file I might go like: File A: MY_APP = { ...
            Message 5 of 9 , Dec 26, 2011
            • 0 Attachment
              Hi F.,

              I agree that globals should be minimized. Just here is where the beast starts to chase its own tail. In any file I might go like:

              File A: MY_APP = { ... };
              File B: MY_APP = { ... }; // or MY_APP.whatever = ...;

              There is my namespace, but how would file A know, there is a MY_APP.doSomething() in file B? I still need to plaster /*global MY_APP: false */ statements all around. Otherwise JSLint will complain about trying to modify an uninitialized object.

              Alternatively, one could check in every file for the namespace to be present:

              if(!MY_APP) {
              var MY_APP = ...;
              }

              Again, to me this seems like putting the cart before the donkey.

              It's all gravy as long as there is _one_ source file. And while using a top-level namespace object minimizes the amount of objects to import, it is no where close to having JSLint automatically knowing what files are referenced.

              Maybe I should mention Java and CI servers like Jenkins (with static code analysis tools) are the standard I'm used to. They parse import statements correctly, with no need for global definitions. Of course, being compiled and statically typed makes Java destined to be easy parsable.

              It seems no one has implemented that into JSLint so far. Wouldn't that be a nice feature?

              Best regards,

              --- In jslint_com@yahoogroups.com, Frederik Dohr <fdg001@...> wrote:
              >
              > > in a large project with many JS files, there should be a way to tell
              > > JSLint to look at the entire set of files. Thus, if one library file
              > > contains function doSomething(), the other files could use this
              > > function right away, without writing in each file:
              > > /*global doSomething: false*/
              >
              > I very much disagree. Relying heavily on globals like that is a pretty
              > clear sign that something's awry.
              >
              > You might want to use namespaces, i.e. moving related objects into a
              > single global object:
              >
              > ....MYLIB = {
              > ........HelloWorld: function ... ,
              > ........LoremIpsum: ...
              > ....};
              >
              >
              > -- F.
              >
            • Frederik Dohr
              ... IMO, explicitly declaring dependencies is a _good_ thing - so I don t see a problem with this. -- F.
              Message 6 of 9 , Dec 27, 2011
              • 0 Attachment
                > There is my namespace, but how would file A know, there is a
                > MY_APP.doSomething() in file B? I still need to plaster
                > /*global MY_APP: false */ statements all around.

                IMO, explicitly declaring dependencies is a _good_ thing - so I don't
                see a problem with this.


                -- F.
              • Toby Maxwell-Lyte
                We use a global namespace and use it in the following way var myNameSpace = myNameSpace || {}; myNameSpace.myFunct = function () {...}; ... -- Toby
                Message 7 of 9 , Jan 1, 2012
                • 0 Attachment
                  We use a global namespace and use it in the following way

                  var myNameSpace = myNameSpace || {};
                  myNameSpace.myFunct = function () {...};

                  On 27 December 2011 08:28, Frederik Dohr <fdg001@...> wrote:
                  >> There is my namespace, but how would file A know, there is a
                  >> MY_APP.doSomething() in file B? I still need to plaster
                  >> /*global MY_APP: false */ statements all around.
                  >
                  > IMO, explicitly declaring dependencies is a _good_ thing - so I don't
                  > see a problem with this.
                  >
                  >
                  > -- F.
                  >
                  >
                  > ------------------------------------
                  >
                  > Yahoo! Groups Links
                  >
                  >
                  >



                  --
                  Toby Maxwell-Lyte
                  07816 836300
                  01443 239692
                Your message has been successfully submitted and would be delivered to recipients shortly.