Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
80 lines (64 sloc) 2.89 KB
;;; flymake-jslint.el --- Flymake support for javascript using jslint
;;; Author: Steve Purcell <>
;;; Homepage:
;;; Version: DEV
;;; Commentary:
;; References:
;; Usage: (add-hook 'js-mode-hook 'flymake-jslint-load)
(require 'flymake)
;;; Code:
(defgroup flymake-jslint nil
"Flymake checking of Javascript using jslint"
:group 'programming
:prefix "flymake-jslint-")
(defcustom flymake-jslint-detect-trailing-comma t
"Whether or not to report warnings about trailing commas."
:type 'boolean :group :flymake-jslint)
(defcustom flymake-jslint-command "jsl"
"Name (and optionally full path) of jslint executable."
:type 'string :group 'flymake-jslint)
(defvar flymake-jslint-err-line-patterns
'(("^\\(.+\\)\:\\([0-9]+\\)\: \\(SyntaxError\:.+\\)\:$" nil 2 nil 3)
("^\\(.+\\)(\\([0-9]+\\)): \\(SyntaxError:.+\\)$" nil 2 nil 3)
("^\\(.+\\)(\\([0-9]+\\)): \\(lint \\)?\\(warning:.+\\)$" nil 2 nil 4)))
(defvar flymake-jslint-trailing-comma-err-line-pattern
'("^\\(.+\\)\:\\([0-9]+\\)\: strict \\(warning: trailing comma.+\\)\:$" nil 2 nil 3))
(defun flymake-jslint--create-temp-in-system-tempdir (file-name prefix)
"Return a temporary file name into which flymake can save buffer contents.
This is tidier than `flymake-create-temp-inplace', and therefore
preferable when the checking doesn't depend on the file's exact
(make-temp-file (or prefix "flymake-jslint") nil ".js"))
(defun flymake-jslint-init ()
"Construct a command that flymake can use to check javascript source."
(list flymake-jslint-command (list "-process" (flymake-init-create-temp-buffer-copy
(defun flymake-jslint-load ()
"Configure flymake mode to check the current buffer's javascript syntax.
This function is designed to be called in `js-mode-hook' or
equivalent; it does not alter flymake's global configuration, so
function `flymake-mode' alone will not suffice."
(set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-jslint-init)))
(set (make-local-variable 'flymake-err-line-patterns) flymake-jslint-err-line-patterns)
(when flymake-jslint-detect-trailing-comma
(add-to-list 'flymake-err-line-patterns
(if (executable-find flymake-jslint-command)
(flymake-mode t)
(message "Not enabling flymake: jsl command not found")))
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
(setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)
(provide 'flymake-js)
;;; flymake-jslint.el ends here
Jump to Line
Something went wrong with that request. Please try again.