+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/dull-drinks-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@biomejs/biome": minor
---

Updated the formatting of `.svelte` and `.vue` files. Now the indentation of the JavaScript blocks matches Prettier's:

```diff
<script>
- import Component from "./Component"
+ import Component from "./Component"
</script>
```
12 changes: 0 additions & 12 deletions crates/biome_cli/tests/cases/handle_svelte_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ const hello : string = "world";
</script>
<div></div>"#;

const SVELTE_TS_CONTEXT_MODULE_FILE_FORMATTED: &str = r#"<script context="module" lang="ts">
import Button from "./components/Button.svelte";
const hello: string = "world";
</script>
<div></div>"#;

const SVELTE_CARRIAGE_RETURN_LINE_FEED_FILE_UNFORMATTED: &str =
"<script>\r\n const a = \"b\";\r\n</script>\r\n<div></div>";

Expand Down Expand Up @@ -176,12 +170,6 @@ fn format_svelte_ts_context_module_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(
&fs,
svelte_file_path,
SVELTE_TS_CONTEXT_MODULE_FILE_FORMATTED,
);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_svelte_ts_context_module_files_write",
Expand Down
24 changes: 0 additions & 24 deletions crates/biome_cli/tests/cases/handle_vue_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,18 @@ statement ( ) ;
</script>
<template></template>"#;

const VUE_IMPLICIT_JS_FILE_FORMATTED: &str = r#"<script>
import { something } from "file.vue";
statement();
</script>
<template></template>"#;

const VUE_EXPLICIT_JS_FILE_UNFORMATTED: &str = r#"<script lang="js">
import { something } from "file.vue";
statement ( ) ;
</script>
<template></template>"#;

const VUE_EXPLICIT_JS_FILE_FORMATTED: &str = r#"<script lang="js">
import { something } from "file.vue";
statement();
</script>
<template></template>"#;

const VUE_TS_FILE_UNFORMATTED: &str = r#"<script setup lang="ts">
import { type something } from "file.vue";
const hello : string = "world";
</script>
<template></template>"#;

const VUE_TS_FILE_FORMATTED: &str = r#"<script setup lang="ts">
import { type something } from "file.vue";
const hello: string = "world";
</script>
<template></template>"#;

const VUE_JS_FILE_NOT_LINTED: &str = r#"<script setup lang="js">
a == b;
delete a.c;
Expand Down Expand Up @@ -155,8 +137,6 @@ fn format_vue_implicit_js_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(&fs, vue_file_path, VUE_IMPLICIT_JS_FILE_FORMATTED);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_vue_implicit_js_files_write",
Expand Down Expand Up @@ -215,8 +195,6 @@ fn format_vue_explicit_js_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(&fs, vue_file_path, VUE_EXPLICIT_JS_FILE_FORMATTED);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_vue_explicit_js_files_write",
Expand Down Expand Up @@ -296,8 +274,6 @@ fn format_vue_ts_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(&fs, vue_file_path, VUE_TS_FILE_FORMATTED);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_vue_ts_files_write",
Expand Down
24 changes: 0 additions & 24 deletions crates/biome_cli/tests/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,18 @@ statement ( ) ;
</script>
<div></div>"#;

const SVELTE_IMPLICIT_JS_FILE_FORMATTED: &str = r#"<script>
import { something } from "file.svelte";
statement();
</script>
<div></div>"#;

const SVELTE_EXPLICIT_JS_FILE_UNFORMATTED: &str = r#"<script lang="js">
import { something } from "file.svelte";
statement ( ) ;
</script>
<div></div>"#;

const SVELTE_EXPLICIT_JS_FILE_FORMATTED: &str = r#"<script lang="js">
import { something } from "file.svelte";
statement();
</script>
<div></div>"#;

const SVELTE_TS_FILE_UNFORMATTED: &str = r#"<script setup lang="ts">
import { type something } from "file.svelte";
const hello : string = "world";
</script>
<div></div>"#;

const SVELTE_TS_FILE_FORMATTED: &str = r#"<script setup lang="ts">
import { type something } from "file.svelte";
const hello: string = "world";
</script>
<div></div>"#;

const APPLY_TRAILING_COMMAS_BEFORE: &str = r#"
const a = [
longlonglonglongItem1longlonglonglongItem1,
Expand Down Expand Up @@ -2996,8 +2978,6 @@ fn format_svelte_implicit_js_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(&fs, svelte_file_path, SVELTE_IMPLICIT_JS_FILE_FORMATTED);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_svelte_implicit_js_files_write",
Expand Down Expand Up @@ -3056,8 +3036,6 @@ fn format_svelte_explicit_js_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(&fs, svelte_file_path, SVELTE_EXPLICIT_JS_FILE_FORMATTED);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_svelte_explicit_js_files_write",
Expand Down Expand Up @@ -3143,8 +3121,6 @@ fn format_svelte_ts_files_write() {

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_file_contents(&fs, svelte_file_path, SVELTE_TS_FILE_FORMATTED);

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"format_svelte_ts_files_write",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `file.astro`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `file.astro`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
# Input messages

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ var foo: string = "";

```block
<script context="module" lang="ts">
import Button from "./components/Button.svelte";
import { Form } from "./components/Form.svelte";
import Button from "./components/Button.svelte";
import { Form } from "./components/Form.svelte";

debugger;
statement();
var foo: string = "";
debugger;
statement();
var foo: string = "";
</script>
<div></div>
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var foo: string = "";

```block
<script context="module" lang="ts">
statement();
var _foo: string = "";
statement();
var _foo: string = "";
</script>
<div></div>
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
# Input messages

Expand All @@ -16,8 +16,8 @@ const hello : string = "world";

```block
<script context="module" lang="ts">
import Button from "./components/Button.svelte";
const hello: string = "world";
import Button from "./components/Button.svelte";
const hello: string = "world";
</script>
<div></div>
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
# Input messages

Expand All @@ -16,8 +16,8 @@ const hello : string = "world";

```block
<script context="module" lang="ts">
import Button from "./components/Button.svelte";
const hello: string = "world";
import Button from "./components/Button.svelte";
const hello: string = "world";
</script>
<div></div>
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `file.svelte`

Expand Down Expand Up @@ -31,7 +31,7 @@ file.svelte format ━━━━━━━━━━━━━━━━━━━━

1 1 │ <script>␍
2 │ - ··const·a····=·"b";␍
2 │ + const·a·=·"b";
2 │ + const·a·=·"b";
3 3 │ </script>␍
4 4 │ <div></div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `file.svelte`

Expand Down Expand Up @@ -33,8 +33,8 @@ file.svelte format ━━━━━━━━━━━━━━━━━━━━
1 1 │ <script context="module" lang="ts">
2 │ - import·····Button·····from·"./components/Button.svelte";
3 │ - const·hello··:······string······=·"world";
2 │ + import·Button·from·"./components/Button.svelte";
3 │ + const·hello:·string·=·"world";
2 │ + import·Button·from·"./components/Button.svelte";
3 │ + const·hello:·string·=·"world";
4 4 │ </script>
5 5 │ <div></div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `file.svelte`

```svelte
<script context="module" lang="ts">
import Button from "./components/Button.svelte";
const hello: string = "world";
import Button from "./components/Button.svelte";
const hello: string = "world";
</script>
<div></div>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ delete a.c;

```block
<script setup lang="ts">
import * as vueUse from "vue-use";
import { Button } from "./components/Button.vue";
import * as vueUse from "vue-use";
import { Button } from "./components/Button.vue";

delete a.c;
delete a.c;
</script>
<template></template>
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ delete a.c;

```block
<script setup lang="ts">
delete a.c;
delete a.c;
</script>
<template></template>
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
# Input messages

Expand All @@ -16,8 +16,8 @@ const hello : string = "world";

```block
<script setup lang="ts">
import { type something } from "file.vue";
const hello: string = "world";
import { type something } from "file.vue";
const hello: string = "world";
</script>
<template></template>
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
# Input messages

Expand All @@ -16,8 +16,8 @@ const hello : string = "world";

```block
<script setup lang="ts">
import { type something } from "file.vue";
const hello: string = "world";
import { type something } from "file.vue";
const hello: string = "world";
</script>
<template></template>
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
expression: redactor(content)
---
## `file.vue`

Expand Down Expand Up @@ -31,7 +31,7 @@ file.vue format ━━━━━━━━━━━━━━━━━━━━━

1 1 │ <script>␍
2 │ - ··const·a····=·"b";␍
2 │ + const·a·=·"b";
2 │ + const·a·=·"b";
3 3 │ </script>␍
4 4 │ <template></template>

Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载