From 3a3315cc7f3466ce229f6f150402d5ccf72b3d1d Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Thu, 15 Aug 2024 04:58:48 +0800 Subject: feat(fmt): support HTML, Svelte, Vue, Astro and Angular (#25019) This commit adds capability to format HTML, Svelte, Vue, Astro and Angular files. "--unstable-html" is required to format HTML files, and "--unstable-component" flag is needed to format other formats. These can also be specified in the config file. Close #25015 --- tests/specs/fmt/unstable_component/__test__.jsonc | 25 ++++++++++++++++++++++ .../fmt/unstable_component/badly_formatted.svelte | 10 +++++++++ tests/specs/fmt/unstable_html/__test__.jsonc | 25 ++++++++++++++++++++++ tests/specs/fmt/unstable_html/badly_formatted.html | 9 ++++++++ 4 files changed, 69 insertions(+) create mode 100644 tests/specs/fmt/unstable_component/__test__.jsonc create mode 100644 tests/specs/fmt/unstable_component/badly_formatted.svelte create mode 100644 tests/specs/fmt/unstable_html/__test__.jsonc create mode 100644 tests/specs/fmt/unstable_html/badly_formatted.html (limited to 'tests/specs') diff --git a/tests/specs/fmt/unstable_component/__test__.jsonc b/tests/specs/fmt/unstable_component/__test__.jsonc new file mode 100644 index 000000000..a8f8697da --- /dev/null +++ b/tests/specs/fmt/unstable_component/__test__.jsonc @@ -0,0 +1,25 @@ +{ + "tempDir": true, + "tests": { + "nothing": { + "args": "fmt", + "output": "Checked 1 file\n" + }, + "flag": { + "args": "fmt --unstable-css --unstable-component", + "output": "[WILDLINE]badly_formatted.svelte\nChecked 1 file\n" + }, + "config_file": { + "steps": [{ + "args": [ + "eval", + "Deno.writeTextFile('deno.json', '{\\n \"unstable\": [\"fmt-css\", \"fmt-component\"]\\n}\\n')" + ], + "output": "[WILDCARD]" + }, { + "args": "fmt", + "output": "[WILDLINE]badly_formatted.svelte\nChecked 2 files\n" + }] + } + } +} diff --git a/tests/specs/fmt/unstable_component/badly_formatted.svelte b/tests/specs/fmt/unstable_component/badly_formatted.svelte new file mode 100644 index 000000000..3a3cbe9b3 --- /dev/null +++ b/tests/specs/fmt/unstable_component/badly_formatted.svelte @@ -0,0 +1,10 @@ + + +
{a+b}
+ + diff --git a/tests/specs/fmt/unstable_html/__test__.jsonc b/tests/specs/fmt/unstable_html/__test__.jsonc new file mode 100644 index 000000000..2394805ad --- /dev/null +++ b/tests/specs/fmt/unstable_html/__test__.jsonc @@ -0,0 +1,25 @@ +{ + "tempDir": true, + "tests": { + "nothing": { + "args": "fmt", + "output": "Checked 1 file\n" + }, + "flag": { + "args": "fmt --unstable-css --unstable-html", + "output": "[WILDLINE]badly_formatted.html\nChecked 1 file\n" + }, + "config_file": { + "steps": [{ + "args": [ + "eval", + "Deno.writeTextFile('deno.json', '{\\n \"unstable\": [\"fmt-css\", \"fmt-html\"]\\n}\\n')" + ], + "output": "[WILDCARD]" + }, { + "args": "fmt", + "output": "[WILDLINE]badly_formatted.html\nChecked 2 files\n" + }] + } + } +} diff --git a/tests/specs/fmt/unstable_html/badly_formatted.html b/tests/specs/fmt/unstable_html/badly_formatted.html new file mode 100644 index 000000000..de7706ac7 --- /dev/null +++ b/tests/specs/fmt/unstable_html/badly_formatted.html @@ -0,0 +1,9 @@ +
content
+ + + + -- cgit v1.2.3