prettier / prettier-emacs

Minor mode to format JS code on file save

Home Page:http://jlongster.com/A-Prettier-Formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prettier not formatting typescript file

aoshi321 opened this issue · comments

Hi

I have the following setting

(add-hook 'typescript-mode-hook 'prettier-js-mode)

but on save nothing happens.

thanks

I have same issue, @aoshi321 you can fix that by adding a after-save-hook on your typescript emacs config.
Example :

(use-package typescript-mode
  :straight t
  :mode ("\\.tsx?\\'" . typescript-mode)
  :config
  (setq typescript-indent-level 2)
  (add-hook 'flycheck-mode-hook #'sopho/use-eslint-from-node-modules)
  (add-hook 'after-after-hook #'prettier-js-mode)) ; format file with prettier on save

(use-package prettier-js
  :straight t
  :commands (prettier-js-mode prettier-js)
  :hook ((typescript-mode . prettier-js-mode)))