-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathflymake-jscheckstyle.el
51 lines (42 loc) · 1.66 KB
/
flymake-jscheckstyle.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;; On-the-fly syntax checking of javascript using jscheckstyle to run JSLint.
;;
;; Changes to this file have been released into the Public Domain.
;; Adapted from http://www.emacswiki.org/emacs/FlymakeJavaScript
;;
;; Installation:
;;
;; Put this in your load-path, then add the following to your .emacs.
;; You substitude espresso-mode-hook for javascript-mode-hook if you
;; use espresso or js2-mode-hook if using js2-mode.
;;
;; (require 'flymake-jscheckstyle)
;; (add-hook 'javascript-mode-hook
;; (lambda () (flymake-mode t)))
;;
;; Make sure env can find node in your $PATH
(require 'flymake)
(setq flymake-log-level 3)
(defun flymake-jscheckstyle-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "jscheckstyle" (list "--emacs" "--violations" local-file))))
;; needs debugging
(setq flymake-allowed-file-name-masks
(cons '(".+\\.js$"
flymake-jscheckstyle-init
flymake-simple-cleanup
flymake-get-real-file-name)
flymake-allowed-file-name-masks))
;; using this in lieu of the above
;;(eval-after-load "flymake"
;; '(progn
;; (add-to-list 'flymake-allowed-file-name-masks
;; '("\\.js\\'" flymake-jscheckstyle-init))))
(setq flymake-err-line-patterns
(cons '("^.+, line=\\([[:digit:]]+\\), column=\\([[:digit:]]+\\), \\(.+\\)$" nil 1 2 3)
flymake-err-line-patterns))
(add-hook 'find-file-hook 'flymake-find-file-hook)
(provide 'flymake-jscheckstyle)