Skip to content

Instantly share code, notes, and snippets.

@dantheobserver
Last active January 23, 2019 18:25
Show Gist options
  • Save dantheobserver/735f5e3425e3c5dbbf259d652871f645 to your computer and use it in GitHub Desktop.
Save dantheobserver/735f5e3425e3c5dbbf259d652871f645 to your computer and use it in GitHub Desktop.
;; This seems the fastest output of prettier-eslint_d I've seen, using prettier-eslint-emacs seemd
;; much slower, using the suggested cat | prettier_eslint_d --stdin with the added tee to the output file
;; is much quicker.
(defun user-prettier-eslint ()
"Format the current file with ESLint."
(interactive)
(let* ((binary (executable-find "prettier-eslint_d"))
(command (format "cat %s | %s --stdin | tee %s" buffer-file-name binary buffer-file-name)))
(progn
(shell-command command "*test-buffer*" "*prettier-eslint-errors*")
(revert-buffer t t t))))
(add-hook 'js2-mode-hook (lambda () (add-hook 'after-save-hook 'user-prettier-eslint nil t)))
(add-hook 'web-mode-hook (lambda () (add-hook 'after-save-hook 'user-prettier-eslint nil t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment