summaryrefslogtreecommitdiff
path: root/lisp/web.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/web.el')
-rw-r--r--lisp/web.el44
1 files changed, 32 insertions, 12 deletions
diff --git a/lisp/web.el b/lisp/web.el
index 655dd03..a1d9598 100644
--- a/lisp/web.el
+++ b/lisp/web.el
@@ -16,24 +16,22 @@
(add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
;; JavaScript
-(require 'js2-mode)
-(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
-(push '("\\.js[x]?\\'" . js2-mode) auto-mode-alist)
-(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
+(add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
+(push '("\\.js[x]?\\'" . javascript-mode) auto-mode-alist)
(defun setup-js2-mode()
"Hooks for Javscript 2 Mode."
(setq js-indent-level 2)
(company-mode t)
- (company-quickhelp-mode t)
(smartparens-mode 1)
)
-(add-hook 'js2-mode-hook 'setup-js2-mode)
-(setq js2-highlight-level 3)
-(setq js2-idle-timer-delay 0.1)
+(add-hook 'js-mode-hook 'setup-js2-mode)
+;(setq js2-highlight-level 3)
+;(setq js2-idle-timer-delay 0)
-;; Tide for refactoring
+;; TypeScript
(defun setup-typescript()
+ "Set up tiny things for TypeScript."
(setq typescript-indent-level 2)
(company-mode t)
(company-quickhelp-mode t)
@@ -47,8 +45,30 @@
(lambda ()
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-typescript))))
-;; enable typescript-tslint checker
-(flycheck-add-mode 'typescript-tslint 'web-mode)
+
+;; Eslint through Flycheck.
+(require 'flycheck)
+(setq-default flycheck-disabled-checkers
+ (append flycheck-disabled-checkers
+ '(javascript-jshint)))
+(setq-default flycheck-disabled-checkers
+ (append flycheck-disabled-checkers
+ '(json-jsonlist)))
+(flycheck-add-mode 'javascript-eslint 'js-mode)
+(flycheck-add-mode 'typescript-tslint 'typescript-mode)
+; use local eslint from node_modules before global
+; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
+(defun my-use-eslint-from-node-modules ()
+ "Use eslint from local node_modules instead of globally."
+ (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)
;; Package management
(use-package eglot
@@ -57,7 +77,7 @@
:ensure t
:defer 3
:hook
- ((js2-mode typescript-mode) . eglot-ensure))
+ ((js-mode typescript-mode) . eglot-ensure))
:config
(cl-pushnew '((js-mode typescript-mode) . ("typescript-language-server" "--stdio"))
eglot-server-programs