Last active
April 23, 2018 12:34
-
-
Save hgiasac/b8e4f50ea9dc504e3e52163e58872a4e to your computer and use it in GitHub Desktop.
Emacs TSLint fix file hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun tslint-fix-file () | |
"Tslint fix file." | |
(interactive) | |
(message (concat "tslint --fixing the file " (buffer-file-name))) | |
(shell-command (concat "tslint --fix " (buffer-file-name)))) | |
(defun tslint-fix-file-and-revert () | |
"Format the current file with TSLint." | |
(interactive) | |
(when (eq major-mode 'typescript-mode) | |
(if (executable-find "tslint") | |
(tslint-fix-file) | |
(message "TSLint not found.")))) | |
;; formats the buffer after saving | |
(add-hook 'after-save-hook 'tslint-fix-file-and-revert) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment