Coder Social home page Coder Social logo

lein-jslint's Introduction

lein-jslint

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.

Build Status Clojars Project

Pre-requirements

Install NodeJS and NPM (package manager for Node) to install JSHint:

  • On Ubuntu: sudo apt-get install nodejs
  • On Mac OS X: brew install node

Installation

Install JSLint to use lein-jslint plugin. It could be done in few ways:

  • Use NPM to install JSLint globally: npm install jslint -g
  • You can also install JSLint in the current directory: npm install jslint
  • Use lein-npm plugin: lein npm install
  • Use just Leiningen: lein deps

Setup

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"]]

Configuration

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

Hooks

To enable this plugin in compile stage, use the following hook:

:hooks [lein-jslint.plugin]

Examples

Detailed example

: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

Example project

Just clone the current repository and try to play with example project for better understanding how to use lein-jslint.

Unit testing

To run unit tests:

lein test

Thanks to

Douglas Crockford for the great JSLint project.

Might also like

  • lein-asciidoctor - A Leiningen plugin for generating documentation using Asciidoctor.
  • lein-plantuml - a Leiningen plugin for generating UML diagrams using PlantUML.
  • lein-coffeescript - a Leiningen plugin for running CoffeeScript compiler.
  • lein-typescript - a Leiningen plugin for running TypeScript compiler.
  • lein-jshint - a Leiningen plugin for running javascript code through JSHint.
  • jabberjay - a simple framework for creating Jabber bots.
  • coderwall-clj - a tiny CoderWall client for Clojure.

License

Copyright © 2014 Vladislav Bauer

Distributed under the Eclipse Public License, the same as Clojure.

lein-jslint's People

Contributors

vbauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

clojure-land

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.