Skip to content

Instantly share code, notes, and snippets.

@hgiasac
Last active April 23, 2018 12:34
Show Gist options
  • Save hgiasac/b8e4f50ea9dc504e3e52163e58872a4e to your computer and use it in GitHub Desktop.
Save hgiasac/b8e4f50ea9dc504e3e52163e58872a4e to your computer and use it in GitHub Desktop.
Emacs TSLint fix file hook
(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