Skip to content

Wilfred/flymake-jshint.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

flymake-jshint

Installation

To use JSHint with emacs, you will need JSHint installed and available on your path. You should be able to do

$ jshint

without problem. To do this, you can install node.js, npm and jshint by doing the following:

$ apt-get install nodejs # or your distro / OS equivalent
$ sudo npm install -g jshint

You will probably want to configure the warnings that JSHint produces. The full list is at http://www.jshint.com/options/ but for reference I use:

{ "browser": true, //browser constants, such as alert
  "curly": true, // require {} on one-line if
  "undef": true, // non-globals must be declared before use
  "newcap": true, // constructors must start with capital letter
  "jquery": true, // jQuery constants
  "nomen": false, // permit leading/trailing underscores, these do actually mean private in jQuery plugins
  "nonew": true, // don't permit object creation for side-effects only
  "strict": true // require "use strict";
}

Save this in a file called whatever.json and then set jshint-configuration-path to point to it.

Usage

Add to your emacs config:

(require 'flymake-jshint)
(add-hook 'js-mode-hook 'flymake-mode)

making sure that flymake-jshint.el is on your load-path. If not, also add to your config:

(add-to-list 'load-path "~/.emacs.d/path/to/flymake-jshint.el")

Debugging

If JSHint isn't working for any reason, execute

M-x set-variable flymake-log-level <RET> 3

and you will see what is going wrong listed in the *Messages* buffer.

Alternatives

Changelog

v2.2 -- Reverted to creating temporary files in a temporary directory, to avoid problems with file watches (see issues #1 and #2).

v2.1 -- We now create temporary files in the same directory as the source file, so jshint can see .jshintrc configuration files.

v2.0 -- Updated usage instructions following the port to flymake-easy

v1.3 -- Refactored to use flymake-easy

About

JSHint with flymake for Emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published