Skip to content

Instantly share code, notes, and snippets.

@ustun
Created January 12, 2016 23:59
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ustun/73321bfcb01a8657e5b8 to your computer and use it in GitHub Desktop.
Save ustun/73321bfcb01a8657e5b8 to your computer and use it in GitHub Desktop.
run eslint --fix on emacs file save
;;; runs eslint --fix on the current file after save
;;; alpha quality -- use at your own risk
(defun eslint-fix-file ()
(interactive)
(message "eslint --fixing the file" (buffer-file-name))
(shell-command (concat "eslint --fix " (buffer-file-name))))
(defun eslint-fix-file-and-revert ()
(interactive)
(eslint-fix-file)
(revert-buffer t t))
(add-hook 'js2-mode-hook
(lambda ()
(add-hook 'after-save-hook #'eslint-fix-file-and-revert)))
@ustun
Copy link
Author

ustun commented Apr 3, 2020

@dil-bfleischman
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment