JSLint is a static code analysis tool used in software development for checking if JavaScript source code complies with coding rules.
lein-jslint is a Leiningen plugin for running javascript code through JSLint.
Install NodeJS and NPM (package manager for Node) to install JSHint:
sudo apt-get install nodejs
brew install node
Install JSLint to use lein-jslint plugin. It could be done in few ways:
npm install jslint -g
npm install jslint
lein npm install
lein deps
To enable lein-jslint for your project, put the following in the :plugins vector of your project.clj file:
; Use latest version instead of "X.X.X"
:plugins [[lein-jslint "X.X.X"]]
You can specify places, where JS files will be located with:
:jslint {
:includes ["resources/public/js/*.js"
"resources/js/*.js"]
}
You can also specify JS files that should be excluded from checking:
:jslint { :excludes ["resources/public/lib/*.js"] }
To specify :includes and :excludes options, it is possible to use Glob Patterns.
JSLint rules could be configured with :config parameter:
; It specifies which JSLint options to turn on or off
:jslint {
:debug true ; To debug processing
:config {:predef {"angular" "console" "$"}
:nomen true
:eqeq true
...}}
You can use both variants to specify keys: string values or keywords.
All available parameters are described in the official documentation here
To enable this plugin in compile stage, use the following hook:
:hooks [lein-jslint.plugin]
:jslint {
:includes ["resources/public/js/*.js"]
; This configuration is used by default
:config {:confusion true
:continue true
:regexp true
:unparam true
:vars true}}
Another example of configuration file: .jslintrc
Just clone the current repository and try to play with example project for better understanding how to use lein-jslint.
To run unit tests:
lein test
Douglas Crockford for the great JSLint project.
Copyright © 2014 Vladislav Bauer
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close