Skip to content

Instantly share code, notes, and snippets.

@thomas-louvigne
Created February 7, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomas-louvigne/b36bc7818261a06718781fc5880dc0f8 to your computer and use it in GitHub Desktop.
Save thomas-louvigne/b36bc7818261a06718781fc5880dc0f8 to your computer and use it in GitHub Desktop.
Application de eslint-fix a chaque save avec web-mode
(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