How to configure JSHint with maven

让人想犯罪 __ 提交于 2019-12-24 19:48:34

问题


I am using JSHint for my maven project (Executing mvn jshint:lint will display warnings). There are two configuration methods provided on http://www.jshint.com/docs/

Currently i am using the Inline configuration, but i am interested in using package.json file which they have mentioned in Configuration, but i don't know where to put this file.

How to configure the maven project to use package.json or .jshintrc config file with jshint?


回答1:


You could create a grunt task which can be called by Maven client to run your jshint stuff. See:

http://addyosmani.com/blog/making-maven-grunt/




回答2:


Here my maven config, maybe it helps:

    <build>
        <plugins>

            <!-- ... -->

            <plugin>
                <groupId>com.cj.jshintmojo</groupId>
                <artifactId>jshint-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <configuration>
                            <version>2.5.6</version>
                            <failOnError>false</failOnError>

                            <configFile>src/main/javascript/jshint.package.json</configFile>

                            <directories>
                                <directory>src/main/javascript</directory>
                            </directories>

                            <!--<reporter>jslint</reporter><reportFile>target/jslint.xml</reportFile>-->
                            <!--<reporter>html</reporter><reportFile>target/jshint.html</reportFile>-->
                            <reporter>checkstyle</reporter>
                            <reportFile>target/checkstyle-jshint.xml</reportFile>

                            <failOnError>false</failOnError> <!-- this seems to be ignored -->
                        </configuration>

                        <goals>
                            <goal>lint</goal> <!-- jshint:lint -->
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

The plugin documentation is quite hard to find. Please try here: https://github.com/cjdev/jshint-mojo



来源:https://stackoverflow.com/questions/24802243/how-to-configure-jshint-with-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!