Skip to content

Commit

Permalink
fix(biome_js_parser): get accessors argument can contain a trailing c…
Browse files Browse the repository at this point in the history
…omma
  • Loading branch information
fireairforce committed Oct 17, 2024
1 parent fa93a14 commit 1ede5d3
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 151 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ New entries must be placed in a section entitled `Unreleased`.
Read
our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog).

## Unreleased

### Analyzer

### CLI

### Configuration

### Editors

### Formatter

### JavaScript APIs

### Linter

### Parser

#### Bug fixes

- Fix [#4317](https://github.com/biomejs/biome/issues/4317), get accessors parameter can contain a trailing comma, the following example can be parsed correctly:

```js
export class DummyClass {
set input(
value: string,
) {}
}
```

Contributed by @fireairforce.


## v1.9.4 (2024-10-17)

### Analyzer
Expand Down
51 changes: 39 additions & 12 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.

9 changes: 8 additions & 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.

7 changes: 7 additions & 0 deletions crates/biome_js_parser/src/syntax/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ fn parse_object_member(p: &mut JsParser) -> ParsedSyntax {
// let a = {
// set foo(value) {
// },
// set a(value,) {
// },
// set "bar"(value) {
// },
// set ["a" + "b"](value) {
Expand Down Expand Up @@ -331,6 +333,11 @@ fn parse_setter_object_member(p: &mut JsParser) -> ParsedSyntax {
TypeContext::default(),
)
.or_add_diagnostic(p, js_parse_error::expected_parameter);

if p.at(T![,]) {
p.bump_any();
}

p.expect(T![')']);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ JsModule {
},
l_paren_token: L_PAREN@18..19 "(" [] [],
parameter: missing (required),
comma_token: missing (optional),
r_paren_token: R_PAREN@19..21 ")" [] [Whitespace(" ")],
body: JsFunctionBody {
l_curly_token: L_CURLY@21..22 "{" [] [],
Expand Down Expand Up @@ -79,8 +80,9 @@ JsModule {
0: IDENT@15..18 "foo" [] []
2: L_PAREN@18..19 "(" [] []
3: (empty)
4: R_PAREN@19..21 ")" [] [Whitespace(" ")]
5: JS_FUNCTION_BODY@21..39
4: (empty)
5: R_PAREN@19..21 ")" [] [Whitespace(" ")]
6: JS_FUNCTION_BODY@21..39
0: L_CURLY@21..22 "{" [] []
1: JS_DIRECTIVE_LIST@22..22
2: JS_STATEMENT_LIST@22..36
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ JsModule {
},
],
},
comma_token: missing (optional),
r_paren_token: R_PAREN@197..199 ")" [] [Whitespace(" ")],
body: JsFunctionBody {
l_curly_token: L_CURLY@199..200 "{" [] [],
Expand Down Expand Up @@ -362,6 +363,7 @@ JsModule {
},
],
},
comma_token: missing (optional),
r_paren_token: R_PAREN@225..227 ")" [] [Whitespace(" ")],
body: JsFunctionBody {
l_curly_token: L_CURLY@227..228 "{" [] [],
Expand Down Expand Up @@ -405,6 +407,7 @@ JsModule {
},
],
},
comma_token: missing (optional),
r_paren_token: R_PAREN@250..252 ")" [] [Whitespace(" ")],
body: JsFunctionBody {
l_curly_token: L_CURLY@252..253 "{" [] [],
Expand Down Expand Up @@ -629,8 +632,9 @@ JsModule {
0: IDENT@192..196 "dec" [] [Whitespace(" ")]
1: JS_IDENTIFIER_BINDING@196..197
0: IDENT@196..197 "x" [] []
4: R_PAREN@197..199 ")" [] [Whitespace(" ")]
5: JS_FUNCTION_BODY@199..201
4: (empty)
5: R_PAREN@197..199 ")" [] [Whitespace(" ")]
6: JS_FUNCTION_BODY@199..201
0: L_CURLY@199..200 "{" [] []
1: JS_DIRECTIVE_LIST@200..200
2: JS_STATEMENT_LIST@200..200
Expand Down Expand Up @@ -661,8 +665,9 @@ JsModule {
2: R_PAREN@222..224 ")" [] [Whitespace(" ")]
1: JS_IDENTIFIER_BINDING@224..225
0: IDENT@224..225 "x" [] []
4: R_PAREN@225..227 ")" [] [Whitespace(" ")]
5: JS_FUNCTION_BODY@227..229
4: (empty)
5: R_PAREN@225..227 ")" [] [Whitespace(" ")]
6: JS_FUNCTION_BODY@227..229
0: L_CURLY@227..228 "{" [] []
1: JS_DIRECTIVE_LIST@228..228
2: JS_STATEMENT_LIST@228..228
Expand All @@ -689,8 +694,9 @@ JsModule {
2: R_PAREN@247..249 ")" [] [Whitespace(" ")]
1: JS_IDENTIFIER_BINDING@249..250
0: IDENT@249..250 "x" [] []
4: R_PAREN@250..252 ")" [] [Whitespace(" ")]
5: JS_FUNCTION_BODY@252..254
4: (empty)
5: R_PAREN@250..252 ")" [] [Whitespace(" ")]
6: JS_FUNCTION_BODY@252..254
0: L_CURLY@252..253 "{" [] []
1: JS_DIRECTIVE_LIST@253..253
2: JS_STATEMENT_LIST@253..253
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ JsModule {
type_annotation: missing (optional),
initializer: missing (optional),
},
comma_token: missing (optional),
r_paren_token: R_PAREN@99..101 ")" [] [Whitespace(" ")],
body: JsFunctionBody {
l_curly_token: L_CURLY@101..102 "{" [] [],
Expand Down Expand Up @@ -191,6 +192,7 @@ JsModule {
type_annotation: missing (optional),
initializer: missing (optional),
},
comma_token: missing (optional),
r_paren_token: R_PAREN@249..251 ")" [] [Whitespace(" ")],
body: JsFunctionBody {
l_curly_token: L_CURLY@251..252 "{" [] [],
Expand Down Expand Up @@ -312,8 +314,9 @@ JsModule {
2: (empty)
3: (empty)
4: (empty)
4: R_PAREN@99..101 ")" [] [Whitespace(" ")]
5: JS_FUNCTION_BODY@101..126
4: (empty)
5: R_PAREN@99..101 ")" [] [Whitespace(" ")]
6: JS_FUNCTION_BODY@101..126
0: L_CURLY@101..102 "{" [] []
1: JS_DIRECTIVE_LIST@102..102
2: JS_STATEMENT_LIST@102..122
Expand Down Expand Up @@ -399,8 +402,9 @@ JsModule {
2: (empty)
3: (empty)
4: (empty)
4: R_PAREN@249..251 ")" [] [Whitespace(" ")]
5: JS_FUNCTION_BODY@251..276
4: (empty)
5: R_PAREN@249..251 ")" [] [Whitespace(" ")]
6: JS_FUNCTION_BODY@251..276
0: L_CURLY@251..252 "{" [] []
1: JS_DIRECTIVE_LIST@252..252
2: JS_STATEMENT_LIST@252..272
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
let a = {
set foo(value) {
},
set a(value,) {
},
set "bar"(value) {
},
set ["a" + "b"](value) {
Expand Down
Loading

0 comments on commit 1ede5d3

Please sign in to comment.