Last active
August 29, 2015 14:17
-
-
Save localredhead/b3a074b4aaf0d6050e88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g jsxhint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-derived-mode jsx2-mode js2-mode "jsx2" "JSX mode based on js2") | |
(add-to-list 'auto-mode-alist '("\\.jsx$" . jsx2-mode)) | |
(require 'flycheck) | |
(flycheck-define-checker jsxhint-checker | |
"A JSX syntax and style checker based on JSXHint." | |
:command ("jsxhint" (config-file "--config=" jshint-configuration-path) source) | |
:error-patterns ((error line-start (1+ nonl) ": line " line ", col " column ", " (message) line-end)) | |
:modes (jsx-mode jsx2-mode)) | |
(defun find-jshintrc () | |
(expand-file-name ".jshintrc" | |
(locate-dominating-file | |
(or (buffer-file-name) default-directory) ".jshintrc"))) | |
(defun setup-jsxhint () | |
(setq-local jshint-configuration-path (find-jshintrc)) | |
(flycheck-select-checker 'jsxhint-checker) | |
(flycheck-mode)) | |
(add-hook 'jsx2-mode-hook 'setup-jsxhint) | |
(add-hook 'jsx-mode-hook 'setup-jsxhint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment