My personal .emacs.d folder

flycheck.el 1.0KB

12345678910111213141516171819202122232425262728
  1. (use-package flycheck
  2. :diminish t
  3. :config
  4. (global-flycheck-mode))
  5. (defun my/use-eslint-from-node-modules ()
  6. (let ((root (locate-dominating-file
  7. (or (buffer-file-name) default-directory)
  8. (lambda (dir)
  9. (let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" dir)))
  10. (and eslint (file-executable-p eslint)))))))
  11. (when root
  12. (let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" root)))
  13. (setq-local flycheck-javascript-eslint-executable eslint)))))
  14. (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
  15. (require 'subr-x)
  16. (defun my/use-ruby-stuff-from-bundle ()
  17. (setq-local flycheck-command-wrapper-function
  18. (lambda (command)
  19. (append '("bundle" "exec") command)))
  20. (let ((rubocop (string-trim (shell-command-to-string "bundle exec which rubocop"))))
  21. (when (file-executable-p rubocop)
  22. (setq-local flycheck-ruby-rubocop-executable rubocop))))
  23. (add-hook 'ruby-mode-hook #'my/use-ruby-stuff-from-bundle)