JsLint for Grails
Dependency :
compile ":jslint:0.5"Custom repositories :
mavenRepo "http://grails.org/plugins" mavenRepo "http://snapshots.repository.codehaus.org/" mavenRepo "http://repository.codehaus.org/" mavenRepo "http://download.java.net/maven/2/" mavenRepo "http://repository.jboss.com/maven2/"
Summary
A Grails command line script to run JsLint on javascript files.There is also an option to produce html reports.
Installation
To install the plugin first make sure you have an appropriate repo added and then add the plugin dependency:grails-app/conf/BuildConfig.groovy
repositories {
grailsRepo 'http://grails.org/plugins' // Repo containing jslint 0.5
grailsPlugins()
grailsHome()
grailsCentral()
}plugins {
compile ':jslint:0.5'
}Description
JsLint for Grails
A Grails command line script to run JsLint on javascript files. This plugin will add a command jslint to the grails command line, which will run jslint on the web-app/js directory when you type in grails jslint. The plugin utilizes the jslint4java library and exposes the configuration through a grails config file. The output is configurable via the jslint.reports you must send the output somewhere.Installation
To install the plugin first make sure you have an appropriate repo added and then add the plugin dependency:grails-app/conf/BuildConfig.groovyrepositories {
grailsRepo 'http://grails.org/plugins' // Repo containing jslint 0.5
grailsPlugins()
grailsHome()
grailsCentral()
}plugins {
compile ':jslint:0.5'
}Configuration
You can configure the plugin by creating a JsLintConfig.groovy file. For more information on the jslint configuration options see the jslint4java ant task documentation.One difference is to define global variables that JSLint shouldn't complain about you need to pass them in via jslint.preDef not with the other options in jslint.optionsgrails-app/conf/JsLintConfig.groovyjslint.options = "white" jslint.directory = "web-app/js" jslint.includes = "**/*.js" jslint.excludes = "**/*.min.js, **/i18n/**/*.js, **/prototype/*.js,**/*-min.js,**/*.pack.js" jslint.haltOnFailure = false jslint.preDef= "\$" jslint.reports = { MyXmlReport('xml') { // The report name "MyXmlReport" is user-defined; Report type is 'xml' destfile = 'target/test-reports/jslint.xml' // Set the 'outputFile' property of the (XML) Report } MyHtmlReport('report') { // Report type is 'html' destfile = 'target/test-reports/jslint.html' } }
Example Usage
1 Create a JsLintConfig config file. This example file will run jslint on all js files in the web-app/js directory and exclude the prototype director.jslint.options = "white" jslint.directory = "web-app/js" jslint.includes = "**/*.js" jslint.excludes = "**/*.min.js, **/i18n/**/*.js, **/prototype/*.js,**/*-min.js,**/*.pack.js" jslint.haltOnFailure = false jslint.preDef = "\$" jslint.reports = { MyXmlReport('xml') { // The report name "MyXmlReport" is user-defined; Report type is 'xml' destfile = 'target/test-reports/jslint.xml' // Set the 'outputFile' property of the (XML) Report } MyHtmlReport('report') { // Report type is 'html' destfile = 'target/test-reports/jslint.html' } }
grails jslint