gofmt helped drive the demand and popularity for prettier, but people have been trying to build something like it for JS since before Go existed [0].
Prettier has succeeded largely due to a better algorithm, which actually came from the haskell community, via Wadler's paper A Prettier Printer [1] (with an implementation available at [2]).
[0] js-beautify had its first commit in 2007: https://github.com/beautify-web/js-beautify/commit/e1ddc28b2...
[1] https://homepages.inf.ed.ac.uk/wadler/papers/prettier/pretti... [PDF]