prettier / prettier-emacs

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

Prettier options for Typescript #7

Closed ivikash closed 7 years ago

ivikash commented 7 years ago

Hey, I am trying to use prettier for typescript. By command line I am using --print-width 80 --single-quote --no-semi --no-bracket-spacing --write. Can you please let me know, how can I replicate this in elisp?

If I try this

  (setq prettier-js-args '(
                           "--print-width" "80"
                           "--single-quote" "true"
                           "--no-semi" "true"
                           "--no-bracket-spacing" "true"

                           ))

I receive the following error.

prettier errors:
Unable to read file: true
Error: ENOENT: no such file or directory, open 'true'
Unable to read file: true
Error: ENOENT: no such file or directory, open 'true'
ivikash commented 7 years ago
  (setq prettier-js-args '(
                           "--print-width" "80"
                           "--single-quote" "true"
                           "--no-semi"
                           "--no-bracket-spacing"
                           ))

Works!

rcoedo commented 7 years ago

You have an example of this in the README.md. You can set arguments like this:

(setq prettier-js-args '(
  "--trailing-comma" "all"
  "--bracket-spacing" "false"
))

Let me know if it is not clear enough so we can fix the readme 😃

rcoedo commented 7 years ago

Oops, looks like I was late! 😂

I'm glad that you got it working! 👍

ivikash commented 7 years ago

Thanks @rcoedo 👍