Skip to content

Commit

Permalink
feat(parser/js): remove assert syntax (#4360)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Oct 22, 2024
1 parent 6de9422 commit 2481b08
Show file tree
Hide file tree
Showing 47 changed files with 2,492 additions and 1,165 deletions.
15 changes: 15 additions & 0 deletions .changeset/removed_support_for_assert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
cli: major
---

# Removed support for `assert` syntax

Biome now longer supports the `assert` syntax, use the new `with` syntax instead

```diff
-import {test} from "foo.json" assert { for: "for" }
-export * from "mod" assert { type: "json" }
+import {test} from "foo.json" with { for: "for" }
+export * from "mod" with { type: "json" }
```

4 changes: 2 additions & 2 deletions crates/biome_js_factory/src/generated/node_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/biome_js_factory/src/generated/syntax_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/biome_js_formatter/src/js/module/import_assertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ impl FormatNodeRule<JsImportAssertion> for FormatJsImportAssertion {
l_curly_token,
assertions,
r_curly_token,
assertion_kind,
with_token,
} = node.as_fields();
if assertions.is_empty() {
let has_dangling = f.comments().has_dangling_comments(node.syntax());
write!(
f,
[
format_removed(&assertion_kind?),
format_removed(&with_token?),
format_removed(&l_curly_token?),
has_dangling.then_some(space()),
format_dangling_comments(node.syntax()).with_soft_block_indent(),
Expand All @@ -33,7 +33,7 @@ impl FormatNodeRule<JsImportAssertion> for FormatJsImportAssertion {
f,
[
space(),
assertion_kind.format(),
with_token.format(),
space(),
l_curly_token.format(),
group(&soft_block_indent_with_maybe_space(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export {a,
b as c
} from "fancy" assert { type: "json"}
} from "fancy" with { type: "json"}


export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_
} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"}
} from "fancy" with { type: "json", "type2": "json", type23: "json", "type24": "json"}


export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export {
// comment
export {
// comment
loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"
export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ info: js/module/export/bracket-spacing/export_bracket_spacing.js
```js
export {a,
b as c
} from "fancy" assert { type: "json"}
} from "fancy" with { type: "json"}


export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_
} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"}
} from "fancy" with { type: "json", "type2": "json", type23: "json", "type24": "json"}


export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export {
// comment
export {
// comment
loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"

```


Expand All @@ -51,12 +52,12 @@ Attribute Position: Auto
-----

```js
export { a, b as c } from "fancy" assert { type: "json" };
export { a, b as c } from "fancy" with { type: "json" };

export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_,
} from "fancy" assert {
} from "fancy" with {
type: "json",
type2: "json",
type23: "json",
Expand Down Expand Up @@ -101,12 +102,12 @@ Attribute Position: Auto
-----

```js
export {a, b as c} from "fancy" assert {type: "json"};
export {a, b as c} from "fancy" with {type: "json"};

export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_,
} from "fancy" assert {
} from "fancy" with {
type: "json",
type2: "json",
type23: "json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from "hey"

export * as something_bad_will_happen from "something_bad_might_not_happen"

export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"}
export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3"}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export * from "hey"

export * as something_bad_will_happen from "something_bad_might_not_happen"

export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"}
export * as something_bad_will_happen from "something_bad_might_not_happen" with { "type": "json", "type2": "json3"}

```


Expand Down Expand Up @@ -40,13 +41,13 @@ export * from "hey";

export * as something_bad_will_happen from "something_bad_might_not_happen";

export * as something_bad_will_happen from "something_bad_might_not_happen" assert {
export * as something_bad_will_happen from "something_bad_might_not_happen" with {
type: "json",
type2: "json3",
};
```

# Lines exceeding max width of 80 characters
```
5: export * as something_bad_will_happen from "something_bad_might_not_happen" assert {
5: export * as something_bad_will_happen from "something_bad_might_not_happen" with {
```
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export {a,
b as c
} from "fancy" assert { type: "json"}
} from "fancy" with { type: "json"}


export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_
} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"}
} from "fancy" with { type: "json", "type2": "json", type23: "json", "type24": "json"}


export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export {
// comment
export {
// comment
loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"
export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ info: js/module/export/named_from_clause.js
```js
export {a,
b as c
} from "fancy" assert { type: "json"}
} from "fancy" with { type: "json"}


export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_
} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"}
} from "fancy" with { type: "json", "type2": "json", type23: "json", "type24": "json"}


export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export {
// comment
export {
// comment
loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"

export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"

```


Expand All @@ -51,12 +52,12 @@ Attribute Position: Auto
-----

```js
export { a, b as c } from "fancy" assert { type: "json" };
export { a, b as c } from "fancy" with { type: "json" };

export {
lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem,
lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_,
} from "fancy" assert {
} from "fancy" with {
type: "json",
type2: "json",
type23: "json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_";
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"}
import "short" assert {
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with { type : "json"}
import "short" with {

type : "json"
}

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
"type": /****/ "json"
}

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
"type": /****/ "json",
"type2" /****/ : "json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ info: js/module/import/bare_import.js

```js
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_";
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"}
import "short" assert {
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with { type : "json"}
import "short" with {

type : "json"
}

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
"type": /****/ "json"
}

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
"type": /****/ "json",
"type2" /****/ : "json",
Expand Down Expand Up @@ -56,17 +56,17 @@ Attribute Position: Auto

```js
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_";
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert {
import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with {
type: "json",
};
import "short" assert { type: "json" };
import "short" with { type: "json" };

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
type: /****/ "json",
};

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
type: /****/ "json",
type2: /****/ "json",
Expand All @@ -81,6 +81,6 @@ import "very_long_import_very_long_import_very" assert {
# Lines exceeding max width of 80 characters
```
1: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_";
2: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert {
2: import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" with {
20: typetypetypetypetypetypetypetypetypetypetype: /****/ "typetypetypetypetypetypetypetypetypetypetypetypetypetype",
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {

import TheDefault, { named} from 'foo';

import { named} from 'foo' assert {
import { named} from 'foo' with {

type : "json"
};

import "very_long_import_very_long_import_very" assert {
import "very_long_import_very_long_import_very" with {
// something good is here
"type": /****/ "json"
}
Expand All @@ -27,4 +27,4 @@ import {foo as bar } from "foo";
// Multiple named imports
import { foo as baz, aaa} from "foo";

import(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, {assert: {type:'json'}})
import(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, {assert: {type:'json'}})
Loading

0 comments on commit 2481b08

Please sign in to comment.