Pages

Wednesday, October 5, 2011

Javascript utilities

Playing with javascript lately I came across a super utility called jshint : and Dale Harvey has produced a super jshint-mode! For a javascript nOOb like me it's invaluable when combined with jslint (jshint can replace it, but you might like to turn it off at times then manually invoke jslint instead).

See : jshint and Javascript Lint

My javascript set up:-


(require 'js-beautify)

(add-to-list 'load-path "~/.emacs.d/jquery-doc")
(require 'jquery-doc)
(add-hook 'js2-mode-hook 'jquery-doc-setup)
(require 'flymake-jshint)
(add-hook 'js2-mode-hook
(lambda () (flymake-mode t)))

(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))

;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-hook 'js2-mode-hook '(lambda () (js-beautify)(define-key js2-mode-map (kbd "M-t") (lambda()(interactive)(js-beautify)))(define-key js2-mode-map [(shift f10)] (lambda()(interactive)(jslint-thisfile)))))

;; javascript lint
(defun jslint-thisfile ()
(interactive)
(compile (format "jsl -process %s" (buffer-file-name))))
(defun jslint-thisfile-test ()
(interactive)
(compile (format "jsl -process %s" (buffer-file-name))))

(provide 'rgr-javascript)

2 comments:

  1. All about the JavaScript was really interesting to know about.Ur blog made it quite interesting.Thank you !

    ReplyDelete
  2. All about the JavaScript was really interesting to know about.Ur blog made it quite interesting.Thank you !
    web design company

    ReplyDelete