From 928759bb7a2f91dbf76a55bedc44e25638cd2419 Mon Sep 17 00:00:00 2001 From: mattkae Date: Thu, 28 Jul 2022 08:23:24 -0400 Subject: A handful of useful fixes --- lisp/js-mode-custom.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lisp/js-mode-custom.el') 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 -- cgit v1.2.1