Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created October 18, 2016 15:30
Show Gist options
  • Save aaronjensen/dbc6eb6fa01daf62fcdc1947347fe2eb to your computer and use it in GitHub Desktop.
Save aaronjensen/dbc6eb6fa01daf62fcdc1947347fe2eb to your computer and use it in GitHub Desktop.
(defun eslint-fix ()
(interactive)
(let ((current-point (point)))
(unless (eq 0
(shell-command-on-region
;; Region
(point-min)
(point-max)
;; Command
(concat
"eslint_d"
" --stdin"
" --fix-to-stdout"
" --stdin-filename " buffer-file-name)
;; Output to current buffer
(current-buffer)
;; Replace buffer
t
;; Error buffer name
"*eslint-fix error*"
;; Display error buffer
t))
(undo))
;; Refresh syntax highlighting
(font-lock-fontify-buffer)
(goto-char current-point)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment