[#21] Make Prettier respect .prettierignore

This commit is contained in:
Radon Rosborough 2020-10-17 08:29:21 -07:00
parent 38488e0ef9
commit 3be4b486dc
2 changed files with 21 additions and 13 deletions

View file

@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog]. The format is based on [Keep a Changelog].
## Unreleased
### Bugs fixed
* Prettier now respects `.prettierignore` ([#21]).
[#21]: https://github.com/raxod502/apheleia/issues/21
## 1.1.1 (released 2020-07-16) ## 1.1.1 (released 2020-07-16)
### Formatters ### Formatters
* New: [OCamlFormat](https://github.com/ocaml-ppx/ocamlformat) for * New: [OCamlFormat](https://github.com/ocaml-ppx/ocamlformat) for

View file

@ -415,7 +415,7 @@ modified from what is written to disk, then don't do anything."
(setcar command binary))))) (setcar command binary)))))
(when (memq 'file command) (when (memq 'file command)
(setq command (mapcar (lambda (arg) (setq command (mapcar (lambda (arg)
(if (eq arg 'file) (if (memq arg '(file filepath))
(prog1 buffer-file-name (prog1 buffer-file-name
(when (buffer-modified-p) (when (buffer-modified-p)
(cl-return))) (cl-return)))
@ -453,7 +453,7 @@ modified from what is written to disk, then don't do anything."
(defcustom apheleia-formatters (defcustom apheleia-formatters
'((black . ("black" "-")) '((black . ("black" "-"))
(brittany . ("brittany" file)) (brittany . ("brittany" file))
(prettier . (npx "prettier" file)) (prettier . (npx "prettier" "--stdin-filepath" filepath))
(gofmt . ("gofmt")) (gofmt . ("gofmt"))
(ocamlformat . ("ocamlformat" file)) (ocamlformat . ("ocamlformat" file))
(terraform . ("terraform" "fmt" "-"))) (terraform . ("terraform" "fmt" "-")))
@ -568,17 +568,19 @@ In Lisp code, COMMAND is similar to what you pass to
current buffer are passed to the command on stdin, and the output current buffer are passed to the command on stdin, and the output
is read from stdout. However, if you use the symbol `file' as one is read from stdout. However, if you use the symbol `file' as one
of the elements of COMMAND, then the filename of the current of the elements of COMMAND, then the filename of the current
buffer is substituted for it. If you instead use the symbol buffer is substituted for it. (Use `filepath' instead of `file'
`input' as one of the elements of COMMAND, then the contents of if you need the filename of the current buffer, but you still
the current buffer are written to a temporary file and its name want its contents to be passed on stdin.) If you instead use the
is substituted for `input'. Also, if you use the symbol `output' symbol `input' as one of the elements of COMMAND, then the
as one of the elements of COMMAND, then it is substituted with contents of the current buffer are written to a temporary file
the name of a temporary file. In that case, it is expected that and its name is substituted for `input'. Also, if you use the
the command writes to that file, and the file is then read into symbol `output' as one of the elements of COMMAND, then it is
an Emacs buffer. Finally, if you use the symbol `npx' as one of substituted with the name of a temporary file. In that case, it
the elements of COMMAND, then the first string element of COMMAND is expected that the command writes to that file, and the file is
is resolved inside node_modules/.bin if such a directory exists then read into an Emacs buffer. Finally, if you use the symbol
anywhere above the current `default-directory'. `npx' as one of the elements of COMMAND, then the first string
element of COMMAND is resolved inside node_modules/.bin if such a
directory exists anywhere above the current `default-directory'.
In any case, after the formatter finishes running, the diff In any case, after the formatter finishes running, the diff
utility is invoked to determine what changes it made. That diff utility is invoked to determine what changes it made. That diff