Make react layer respect js fmt on save
The react layer relies on the javascript layer and uses multiple values from it including definition of a formatter. However, the react layer does not respect the javascript layer setting for formatting a file on save. This patch configures the react layer to add a before save hook that calls the javascript layer formatting function when the 'javascript-fmt-on-save variable is enabled.
This commit is contained in:
parent
6e1ba5d1ad
commit
59c95e7da2
|
@ -2441,6 +2441,8 @@ Other:
|
|||
- Configure =emmet-mode= to expand classes using =className= instead of =class=
|
||||
(thanks to Sylvain Benner)
|
||||
- Open =.jsx= files with =rjsx-mode= (thanks to Thomas de Beauchêne)
|
||||
- Made =react= layer respect =javascript= layers variable
|
||||
=javascript-fmt-on-save= (thanks to Tommy Groshong)
|
||||
- Key bindings:
|
||||
- Added =import-js= support with key bindings:
|
||||
- ~SPC m i i~ to mport the module for the variable under the cursor
|
||||
|
|
|
@ -81,3 +81,7 @@ If optional argument P is present, test this instead of point."
|
|||
|
||||
(defun spacemacs//react-setup-yasnippet ()
|
||||
(yas-activate-extra-mode 'js-mode))
|
||||
|
||||
;; Format
|
||||
(defun spacemacs/react-fmt-before-save-hook ()
|
||||
(add-hook 'before-save-hook 'spacemacs/javascript-format t t))
|
||||
|
|
|
@ -72,6 +72,9 @@
|
|||
(add-hook 'rjsx-mode-local-vars-hook #'spacemacs//react-setup-backend)
|
||||
;; set next-error-function to nil because we use flycheck
|
||||
(add-hook 'rjsx-mode-local-vars-hook #'spacemacs//react-setup-next-error-fn)
|
||||
;; setup fmt on save
|
||||
(when javascript-fmt-on-save
|
||||
(add-hook 'rjsx-mode-local-vars-hook 'spacemacs/react-fmt-before-save-hook))
|
||||
|
||||
:config
|
||||
;; declare prefix
|
||||
|
|
Loading…
Reference in a new issue