Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of jshint to 2.1.4 #29

Open
Knusp opened this issue Jul 19, 2013 · 9 comments
Open

Update of jshint to 2.1.4 #29

Knusp opened this issue Jul 19, 2013 · 9 comments

Comments

@Knusp
Copy link

Knusp commented Jul 19, 2013

Thank You!

@kruser
Copy link

kruser commented Jul 25, 2013

Phil, let me know if we can do anything to help get this going. I'm super new to jshint but I need to get our build going with a 2.x version so it doesn't differ so much from my team's use of the eclipse plugin. If you have an idea of how hard it will be to upgrade the plugin let me know and I may be able to contribute.

@philmander
Copy link
Owner

Let me see this weekend.

@Knusp
Copy link
Author

Knusp commented Jul 29, 2013

Is it possible, to change the request to jshint 2.1.6? The new version came out just yesterday: http://www.jshint.com/blog/2013-07-28/2-1-6/ .

Thank you!

@kruser
Copy link

kruser commented Aug 1, 2013

I ended up just exec tasking to the jshint command line. That'll do for me for now.

@prols
Copy link

prols commented Oct 11, 2013

Any news on that issue?

We are using the jshint-eclipse integration plugin in the development environment. This plugin is using the version 2.1.10 of jshint in which some behavior has changed (for ex for trailing whitespace in the comments...)

As a consequence we would like to use the same version of jshint in our ant-based build.
But it is not possible to use a jshint recent release....(tried with 2.1.10, 2.1.11, ...)

Thanks,
Philippe.

@Knusp
Copy link
Author

Knusp commented Jan 13, 2014

@kruser Can you show me the way you achieve this? Thanks in advance! :)

@kruser
Copy link

kruser commented Jan 13, 2014

@Knusp - it's more simple on unix-only. Someone here has updated our builds to work on either NodeJS for windows or linux though, so here are those details.

First, install NodeJS and the jshint module.

Then, in your Ant build file, define the module that can exec to this jshint module on either OS:

    <macrodef name="exec-node">
        <attribute name="module" description="The name of the NodeJS module to execute"/>
        <attribute name="failonerror" default="true" description="Fail if the exit code is not 0"/>
        <element name="args" implicit="yes" description="Argument to pass to the exec task"/>
        <sequential>
            <exec executable="cmd.exe" failonerror="@{failonerror}" osfamily="winnt">
              <!-- Windows cmd output workaround: http://stackoverflow.com/a/10359327/227349 -->
              <!-- Forces node's stderror and stdout to a temporary file -->
              <arg line=" &gt; _tempfile.out 2&lt;&amp;1"/>

              <!-- If command exits with an error, then output the temporary file        -->
              <!-- to stdout delete the temporary file and finally exit with error level 1  -->
              <!-- so that the apply task can catch the error if @failonerror="true"        -->
              <arg line=" || (type _tempfile.out &amp; del _tempfile.out &amp; exit /b 1)"/>

              <!-- Otherwise, just type the temporary file and delete it-->
              <arg line=" &amp; type _tempfile.out &amp; del _tempfile.out &amp;"/>      

        <arg line="/c  @{module}" />
        <args/>
            </exec>
            <exec executable="@{module}" failonerror="@{failonerror}" osfamily="unix">
            <args/>
            </exec>
        </sequential>
    </macrodef>

Then we simple add a new target that allows us to 'ant jshint'. The node executable sends back the correct return code and we failonerror in our macro definition such that our continuous build server does the right thing.

    <target name="jshint">
        <echo message="Executing jshint against the source"></echo>
        <exec-node module="jshint">
            <arg value="--config=../coding-standards/jshint/options.json" />
            <arg value="${src.dir}" />
        </exec-node>
    </target>

@Knusp
Copy link
Author

Knusp commented Jan 24, 2014

Thank you @kruser ! :)

I encountered an "out of range index exception" with the current versions of JSHint (2.2 to 2.4.2), so I had to downgrade to 2.1.11: https://raw2.github.com/jshint/jshint/2.2.0/dist/jshint-rhino.js

FYI: This bug will be fixed soon: jshint/jshint#1333

@twasink
Copy link
Contributor

twasink commented Feb 27, 2014

FWIW, I've submitted a pull request (#32) that upgrades ant-jshint to use JSHint 2.4.4, and which works around the JSHint/Rhino problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants