feat(fmt): support formatting cjs, cts, mjs, and mts files (#14837)

This commit is contained in:
David Sherret 2022-06-09 19:55:04 -04:00 committed by GitHub
parent cf866c5ad3
commit 3dd981e199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -185,8 +185,8 @@ itest!(fmt_stdin {
itest!(fmt_stdin_markdown {
args: "fmt --ext=md -",
input: Some("# Hello Markdown\n```ts\nconsole.log( \"text\")\n```\n"),
output_str: Some("# Hello Markdown\n\n```ts\nconsole.log(\"text\");\n```\n"),
input: Some("# Hello Markdown\n```ts\nconsole.log( \"text\")\n```\n\n```cts\nconsole.log( 5 )\n```"),
output_str: Some("# Hello Markdown\n\n```ts\nconsole.log(\"text\");\n```\n\n```cts\nconsole.log(5);\n```\n"),
});
itest!(fmt_stdin_json {

View file

@ -194,6 +194,10 @@ fn format_markdown(
| "tsx"
| "js"
| "jsx"
| "cjs"
| "cts"
| "mjs"
| "mts"
| "javascript"
| "typescript"
| "json"
@ -707,7 +711,10 @@ fn is_supported_ext_fmt(path: &Path) -> bool {
| "tsx"
| "js"
| "jsx"
| "cjs"
| "cts"
| "mjs"
| "mts"
| "json"
| "jsonc"
| "md"