-
-
Save AloisJanicek/e1aec5c080da62683d17ece70b56120d to your computer and use it in GitHub Desktop.
Run `prettier-stylelint --write` on css file opened in Emacs buffer when saving it
This file contains 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
;;; runs `prettier-stylelint --write` on the current file after save | |
;;; alpha quality -- use at your own risk | |
(defun prettier-stylelint-fix-file-and-revert () | |
"Prettify current file and apply fixes only in css-mode or scss-mode" | |
(interactive) | |
(when (or (eq major-mode 'css-mode) (eq major-mode 'scss-mode)) | |
(message "prettier-stylelint fixing your file" (buffer-file-name)) ;;optional line, you can remove it | |
(shell-command (concat "prettier-stylelint --quiet --write " (buffer-file-name))) | |
(revert-buffer t t))) | |
(add-hook 'after-save-hook #'prettier-stylelint-fix-file-and-revert) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really cool.
prettier-stylelint
not only prettifies current file, but also runs stylelint's--fix
, so you end up with nice looking and fixed file with just one command.But it is slooooow. I wish there was something like eslint_d and eslintd-fix, but for stylelint.