Created
February 7, 2018 13:22
-
-
Save thomas-louvigne/b36bc7818261a06718781fc5880dc0f8 to your computer and use it in GitHub Desktop.
Application de eslint-fix a chaque save avec web-mode
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 eslint-fix () | |
"Format the current file with ESLint." | |
(interactive) | |
(let* ((root (locate-dominating-file | |
(or (buffer-file-name) default-directory) | |
"node_modules")) | |
(eslint (and root | |
(expand-file-name "node_modules/.bin/eslint" | |
root)))) | |
(progn (call-process eslint nil "*ESLint Errors*" nil "--fix" buffer-file-name) | |
(revert-buffer t t t)) | |
)) | |
;; Hook pour passer le linter a chaque save | |
(eval-after-load 'web-mode | |
'(add-hook 'web-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment