prettier / prettier-emacs

Minor mode to format JS code on file save
http://jlongster.com/A-Prettier-Formatter
372 stars 53 forks source link

Prettier with spacemacs and js files. #46

Open cinjon opened 5 years ago

cinjon commented 5 years ago

Hi, I am trying to use prettier with spacemacs and .js files that have jsx blocks in them. Notably, if I change the extension to .jsx, then it is applying Prettier (and is notifying me as such with the "Prettier" tag on the bottom of the screen). However, it is not applying to jsx blocks in .js files. How do I fix this? In my user-config, I have this:

(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'js2-jsx-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
(add-hook 'react-mode-hook 'prettier-js-mode)
(push '("\\.js\\'" . react-mode) auto-mode-alist)