From dd97e10aa0614d9c4ca29cb68422ae6af2ab89a1 Mon Sep 17 00:00:00 2001 From: Brandon Orther Date: Sat, 30 Sep 2017 02:14:17 -0700 Subject: [PATCH] Remove flycheck js2 errors if eslint available. Flycheck has it's own trailing command and semicolon warning that was conflicting with the eslint settings. Now it disables those warnings if eslint.js is setup for flycheck. --- modules/lang/javascript/config.el | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/lang/javascript/config.el b/modules/lang/javascript/config.el index 97265c0cb..8e3ae1499 100644 --- a/modules/lang/javascript/config.el +++ b/modules/lang/javascript/config.el @@ -6,8 +6,7 @@ :config (setq js2-skip-preprocessor-directives t js2-highlight-external-variables nil - js2-mode-show-parse-errors nil - js2-strict-trailing-comma-warning nil) + js2-mode-show-parse-errors nil) (add-hook! 'js2-mode-hook #'(flycheck-mode highlight-indentation-mode rainbow-delimiters-mode)) @@ -20,14 +19,16 @@ (set! :editorconfig :add '(js2-mode js2-basic-offset js-switch-indent-offset)) ;; Favor local eslint over global, if available - (defun +javascript|init-flycheck-elint () + (defun +javascript|init-flycheck-eslint () (when (derived-mode-p 'js-mode) (when-let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" (doom-project-root))) (exists-p (file-exists-p eslint)) (executable-p (file-executable-p eslint))) - (setq-local flycheck-javascript-eslint-executable eslint)))) - (add-hook 'flycheck-mode-hook #'+javascript|init-flycheck-elint) + (setq-local flycheck-javascript-eslint-executable eslint) + (setq-local js2-strict-trailing-comma-warning nil) + (setq-local js2-strict-missing-semi-warning nil)))) + (add-hook 'flycheck-mode-hook #'+javascript|init-flycheck-eslint) (sp-with-modes '(js2-mode rjsx-mode) (sp-local-pair "/* " " */" :post-handlers '(("| " "SPC")))) @@ -98,6 +99,11 @@ :config (set! :company-backend 'js2-mode '(company-tern))) +(def-package! company-flow + :when (featurep! :completion company) + :after company + :config + (set! :company-backend 'js2-mode '(company-flow))) (def-package! rjsx-mode :commands rjsx-mode @@ -137,8 +143,10 @@ :init (map! :map* (json-mode js2-mode-map) :n "gQ" #'web-beautify-js)) + (def-package! eslintd-fix - :commands (eslintd-fix-mode eslintd-fix) + :commands + (eslintd-fix-mode eslintd-fix) :init (defun +javascript|init-eslintd-fix () (when (bound-and-true-p +javascript-eslintd-fix-mode) @@ -199,6 +207,9 @@ :modes (html-mode css-mode web-mode js2-mode markdown-mode) :files "package.json") +(def-project-mode! +javascript-eslintd-fix-mode + :modes (+javascript-npm-mode)) + (def-project-mode! +javascript-lb6-mode :modes (web-mode js2-mode nxml-mode markdown-mode) :match "\\.lb\\(action\\|ext\\)/"