summaryrefslogtreecommitdiff
path: root/lisp/js-mode-custom.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/js-mode-custom.el')
-rw-r--r--lisp/js-mode-custom.el19
1 files changed, 17 insertions, 2 deletions
diff --git a/lisp/js-mode-custom.el b/lisp/js-mode-custom.el
index 7f4d396..094d613 100644
--- a/lisp/js-mode-custom.el
+++ b/lisp/js-mode-custom.el
@@ -1,12 +1,13 @@
(defun setup-js()
(setq js-indent-level 2)
- )
+ )
+(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
(require 'js2-mode)
(require 'js2-refactor)
(require 'js2-highlight-vars)
(require 'company)
-;(add-hook 'js-mode-hook 'js2-minor-mode)
+(require 'flycheck)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
(add-hook 'js2-mode-hook 'ac-js2-mode)
@@ -14,7 +15,21 @@
(add-hook 'js2-mode-hook 'js2-highlight-vars-mode)
(add-hook 'js2-mode-hook 'setup-js)
(js2r-add-keybindings-with-prefix "C-c C-r")
+(add-hook 'js2-mode-hook 'ac-js2-mode)
(add-to-list 'company-backends 'ac-js2-company)
+(defun my/use-eslint-from-node-modules ()
+ (let* ((root (locate-dominating-file
+ (or (buffer-file-name) default-directory)
+ "node_modules"))
+ (eslint (and root
+ (expand-file-name "node_modules/eslint/bin/eslint.js"
+ root))))
+ (when (and eslint (file-executable-p eslint))
+ (setq-local flycheck-javascript-eslint-executable eslint))))
+(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
+(flycheck-add-mode 'javascript-eslint 'web-mode)
+
(provide 'js-mode-custom)
+;; js-mode-custom.el ends here