Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update of jshint to 2.1.4 #29

Open
Knusp opened this Issue · 9 comments

5 participants

@Knusp

Thank You!

@kruser

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
Owner

Let me see this weekend.

@Knusp

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

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

@prols

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

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

@kruser

@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

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

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
Something went wrong with that request. Please try again.