It should run under deno. It should be as little code as possible. It should probably try to look like prettier. It should not require any special permissions.
I'd like to have a blessed formatting system for Deno. EG deno fmt myfile.ts
Probably we wouldn't ship the formatter inside the Deno executable, but instead just load a URL.
The formatter does not need to support options. The point of code formatting is to remove configuration. However it does need to meet these constraints:
import * as ts from "typescript";
^--- this is available inside of deno today, and it's all that should be needed.
TypeScript has a full set of formatting APIs built into it, see: https://github.com/Microsoft/TypeScript/blob/master/src/services/formatting/formatting.ts
They should be exposed through the language services APIs in some fashion. As for TypeScript and JavaScript documents, it is the default formatter of VSCode. I couldn't quite figure it out, but the formatting options should be capable of meeting the requirements above, though the formatting wouldn't be as "intelligent" as Prettier.
@kitsonk I don't believe the public api supports specifying the max line length (see here and EditorSettings a few lines above---used via getFormattingEditsForDocument on LanguageService), but I may be mistaken. Perhaps there's something internal in typescript that supports that functionality that could be exposed?
What if we can do like go fmt?
all community use a same code style. That should be great!
It is now available from deno_std
Also deno --fmt blah.js
It doesn't seem to support .prettierrc though...
@JLarky from the original post:
The formatter does not need to support options. The point of code formatting is to remove configuration.
I think that's on purpose. It's probably going to be more like gofmt where all Deno code will have the same formatting rather than letting people customize their Prettier config. Might be wrong though.
Edit: Didn't see comment above mine.
@JLarky from the original post:
The formatter does not need to support options. The point of code formatting is to remove configuration.
As if he can't be OP and be wrong at the same time
I think that's on purpose. It's probably going to be more like
gofmtwhere all Deno code will have the same formatting rather than letting people customize their Prettier config. Might be wrong though.
I see. Still kind of awkward to setup separate prettier infrastructure just if you want to use prettierrc or prettierignore. But given the history that prettier didn't have that options in first version I guess it makes sense that people are so stubborn on zero config solutions
The intent of the feature was to have a consistent formatter built into Deno, not to support prettier in Deno. It just happened that the default configuration for prettier was sufficient for our needs.
@JLarky This could be supported in deno_std, even if not with deno fmt.
Most helpful comment
@JLarky from the original post: