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.
This commit is contained in:
parent
3938a58bbb
commit
dd97e10aa0
1 changed files with 17 additions and 6 deletions
|
@ -6,8 +6,7 @@
|
||||||
:config
|
:config
|
||||||
(setq js2-skip-preprocessor-directives t
|
(setq js2-skip-preprocessor-directives t
|
||||||
js2-highlight-external-variables nil
|
js2-highlight-external-variables nil
|
||||||
js2-mode-show-parse-errors nil
|
js2-mode-show-parse-errors nil)
|
||||||
js2-strict-trailing-comma-warning nil)
|
|
||||||
|
|
||||||
(add-hook! 'js2-mode-hook
|
(add-hook! 'js2-mode-hook
|
||||||
#'(flycheck-mode highlight-indentation-mode rainbow-delimiters-mode))
|
#'(flycheck-mode highlight-indentation-mode rainbow-delimiters-mode))
|
||||||
|
@ -20,14 +19,16 @@
|
||||||
(set! :editorconfig :add '(js2-mode js2-basic-offset js-switch-indent-offset))
|
(set! :editorconfig :add '(js2-mode js2-basic-offset js-switch-indent-offset))
|
||||||
|
|
||||||
;; Favor local eslint over global, if available
|
;; Favor local eslint over global, if available
|
||||||
(defun +javascript|init-flycheck-elint ()
|
(defun +javascript|init-flycheck-eslint ()
|
||||||
(when (derived-mode-p 'js-mode)
|
(when (derived-mode-p 'js-mode)
|
||||||
(when-let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js"
|
(when-let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js"
|
||||||
(doom-project-root)))
|
(doom-project-root)))
|
||||||
(exists-p (file-exists-p eslint))
|
(exists-p (file-exists-p eslint))
|
||||||
(executable-p (file-executable-p eslint)))
|
(executable-p (file-executable-p eslint)))
|
||||||
(setq-local flycheck-javascript-eslint-executable eslint))))
|
(setq-local flycheck-javascript-eslint-executable eslint)
|
||||||
(add-hook 'flycheck-mode-hook #'+javascript|init-flycheck-elint)
|
(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-with-modes '(js2-mode rjsx-mode)
|
||||||
(sp-local-pair "/* " " */" :post-handlers '(("| " "SPC"))))
|
(sp-local-pair "/* " " */" :post-handlers '(("| " "SPC"))))
|
||||||
|
@ -98,6 +99,11 @@
|
||||||
:config
|
:config
|
||||||
(set! :company-backend 'js2-mode '(company-tern)))
|
(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
|
(def-package! rjsx-mode
|
||||||
:commands rjsx-mode
|
:commands rjsx-mode
|
||||||
|
@ -137,8 +143,10 @@
|
||||||
:init
|
:init
|
||||||
(map! :map* (json-mode js2-mode-map) :n "gQ" #'web-beautify-js))
|
(map! :map* (json-mode js2-mode-map) :n "gQ" #'web-beautify-js))
|
||||||
|
|
||||||
|
|
||||||
(def-package! eslintd-fix
|
(def-package! eslintd-fix
|
||||||
:commands (eslintd-fix-mode eslintd-fix)
|
:commands
|
||||||
|
(eslintd-fix-mode eslintd-fix)
|
||||||
:init
|
:init
|
||||||
(defun +javascript|init-eslintd-fix ()
|
(defun +javascript|init-eslintd-fix ()
|
||||||
(when (bound-and-true-p +javascript-eslintd-fix-mode)
|
(when (bound-and-true-p +javascript-eslintd-fix-mode)
|
||||||
|
@ -199,6 +207,9 @@
|
||||||
:modes (html-mode css-mode web-mode js2-mode markdown-mode)
|
:modes (html-mode css-mode web-mode js2-mode markdown-mode)
|
||||||
:files "package.json")
|
:files "package.json")
|
||||||
|
|
||||||
|
(def-project-mode! +javascript-eslintd-fix-mode
|
||||||
|
:modes (+javascript-npm-mode))
|
||||||
|
|
||||||
(def-project-mode! +javascript-lb6-mode
|
(def-project-mode! +javascript-lb6-mode
|
||||||
:modes (web-mode js2-mode nxml-mode markdown-mode)
|
:modes (web-mode js2-mode nxml-mode markdown-mode)
|
||||||
:match "\\.lb\\(action\\|ext\\)/"
|
:match "\\.lb\\(action\\|ext\\)/"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue