diff --git a/apps/oxlint/conformance/snapshot.md b/apps/oxlint/conformance/snapshot.md index 3eb306c32b1e9..4bec32176ff8d 100644 --- a/apps/oxlint/conformance/snapshot.md +++ b/apps/oxlint/conformance/snapshot.md @@ -7,8 +7,8 @@ | Status | Count | % | | ----------------- | ----- | ------ | | Total rules | 259 | 100.0% | -| Fully passing | 193 | 74.5% | -| Partially passing | 65 | 25.1% | +| Fully passing | 194 | 74.9% | +| Partially passing | 64 | 24.7% | | Fully failing | 1 | 0.4% | | Load errors | 0 | 0.0% | | No tests run | 0 | 0.0% | @@ -18,8 +18,8 @@ | Status | Count | % | | ----------- | ----- | ------ | | Total tests | 26416 | 100.0% | -| Passing | 25330 | 95.9% | -| Failing | 1086 | 4.1% | +| Passing | 25331 | 95.9% | +| Failing | 1085 | 4.1% | ## Fully Passing Rules @@ -40,6 +40,7 @@ - `default-case` (23 tests) - `default-param-last` (96 tests) - `dot-location` (78 tests) +- `dot-notation` (69 tests) - `eqeqeq` (68 tests) - `for-direction` (72 tests) - `func-name-matching` (193 tests) @@ -224,7 +225,6 @@ - `comma-dangle` - 257 / 267 (96.3%) - `computed-property-spacing` - 123 / 125 (98.4%) - `consistent-this` - 23 / 26 (88.5%) -- `dot-notation` - 68 / 69 (98.6%) - `eol-last` - 29 / 35 (82.9%) - `func-call-spacing` - 137 / 151 (90.7%) - `id-blacklist` - 120 / 131 (91.6%) @@ -2210,46 +2210,6 @@ AssertionError [ERR_ASSERTION]: Should have no errors but had 1: [ at apps/oxlint/dist/index.js -### `dot-notation` - -Pass: 68 / 69 (98.6%) -Fail: 1 / 69 (1.4%) - -#### dot-notation > invalid - -```js -let?.true -``` - -```json -{ - "output": "let?.[\"true\"]", - "options": [ - { - "allowKeywords": false - } - ], - "languageOptions": { - "ecmaVersion": 2020 - }, - "errors": [ - { - "messageId": "useBrackets", - "data": { - "key": "true" - } - } - ] -} -``` - -Error: Parsing failed - at parse (apps/oxlint/dist/index.js) - at lint (apps/oxlint/dist/index.js) - at assertInvalidTestCasePasses (apps/oxlint/dist/index.js) - at runInvalidTestCase (apps/oxlint/dist/index.js) - - ### `eol-last` Pass: 29 / 35 (82.9%) diff --git a/crates/oxc_parser/src/js/declaration.rs b/crates/oxc_parser/src/js/declaration.rs index 442e4e74bddf1..4207ff5263dda 100644 --- a/crates/oxc_parser/src/js/declaration.rs +++ b/crates/oxc_parser/src/js/declaration.rs @@ -24,8 +24,8 @@ impl<'a> ParserImpl<'a> { if peeked.is_assignment_operator() || peeked.is_binary_operator() { let expr = self.parse_assignment_expression_or_higher(); self.parse_expression_statement(span, expr) - // let.a = 1, let()[a] = 1 - } else if matches!(peeked, Kind::Dot | Kind::LParen) { + // let.a = 1, let?.a = 1, let()[a] = 1 + } else if matches!(peeked, Kind::Dot | Kind::QuestionDot | Kind::LParen) { let expr = self.parse_expr(); self.ast.statement_expression(self.end_span(span), expr) // single statement let declaration: while (0) let diff --git a/tasks/coverage/misc/fail/let-optional-chaining.js b/tasks/coverage/misc/fail/let-optional-chaining.js new file mode 100644 index 0000000000000..7a254ac55510e --- /dev/null +++ b/tasks/coverage/misc/fail/let-optional-chaining.js @@ -0,0 +1,5 @@ +// Test that `let` cannot be used as identifier with optional chaining in module +let?.x; +let?.y.z; +let?.[0]; +let?.method(); diff --git a/tasks/coverage/misc/pass/let-optional-chaining.cjs b/tasks/coverage/misc/pass/let-optional-chaining.cjs new file mode 100644 index 0000000000000..fe084578f58c3 --- /dev/null +++ b/tasks/coverage/misc/pass/let-optional-chaining.cjs @@ -0,0 +1,5 @@ +// Test that `let` can be used as identifier with optional chaining in script +let?.x; +let?.y.z; +let?.[0]; +let?.method(); diff --git a/tasks/coverage/snapshots/codegen_misc.snap b/tasks/coverage/snapshots/codegen_misc.snap index ad58b4c01b10a..8b352e1ae54e6 100644 --- a/tasks/coverage/snapshots/codegen_misc.snap +++ b/tasks/coverage/snapshots/codegen_misc.snap @@ -1,3 +1,5 @@ codegen_misc Summary: -AST Parsed : 52/52 (100.00%) -Positive Passed: 52/52 (100.00%) +AST Parsed : 53/53 (100.00%) +Positive Passed: 52/53 (98.11%) +Normal: tasks/coverage/misc/pass/let-optional-chaining.cjs + diff --git a/tasks/coverage/snapshots/formatter_misc.snap b/tasks/coverage/snapshots/formatter_misc.snap index 332be836603a7..000040962f592 100644 --- a/tasks/coverage/snapshots/formatter_misc.snap +++ b/tasks/coverage/snapshots/formatter_misc.snap @@ -1,3 +1,3 @@ formatter_misc Summary: -AST Parsed : 52/52 (100.00%) -Positive Passed: 52/52 (100.00%) +AST Parsed : 53/53 (100.00%) +Positive Passed: 53/53 (100.00%) diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 6aa46687c383b..a16f60ed234e0 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -1,7 +1,7 @@ parser_misc Summary: -AST Parsed : 52/52 (100.00%) -Positive Passed: 52/52 (100.00%) -Negative Passed: 121/121 (100.00%) +AST Parsed : 53/53 (100.00%) +Positive Passed: 53/53 (100.00%) +Negative Passed: 122/122 (100.00%) × Cannot assign to 'arguments' in strict mode ╭─[misc/fail/arguments-eval.ts:1:10] @@ -290,6 +290,37 @@ Negative Passed: 121/121 (100.00%) · ─ ╰──── + × The keyword 'let' is reserved + ╭─[misc/fail/let-optional-chaining.js:2:1] + 1 │ // Test that `let` cannot be used as identifier with optional chaining in module + 2 │ let?.x; + · ─── + 3 │ let?.y.z; + ╰──── + + × The keyword 'let' is reserved + ╭─[misc/fail/let-optional-chaining.js:3:1] + 2 │ let?.x; + 3 │ let?.y.z; + · ─── + 4 │ let?.[0]; + ╰──── + + × The keyword 'let' is reserved + ╭─[misc/fail/let-optional-chaining.js:4:1] + 3 │ let?.y.z; + 4 │ let?.[0]; + · ─── + 5 │ let?.method(); + ╰──── + + × The keyword 'let' is reserved + ╭─[misc/fail/let-optional-chaining.js:5:1] + 4 │ let?.[0]; + 5 │ let?.method(); + · ─── + ╰──── + × Expected `:` but found `EOF` ╭─[misc/fail/missing-conditional-alternative-type.ts:2:1] 1 │ type A = 1 extends 2 ? 3 diff --git a/tasks/coverage/snapshots/semantic_misc.snap b/tasks/coverage/snapshots/semantic_misc.snap index bc75641651cda..b058effdd7d45 100644 --- a/tasks/coverage/snapshots/semantic_misc.snap +++ b/tasks/coverage/snapshots/semantic_misc.snap @@ -1,6 +1,6 @@ semantic_misc Summary: -AST Parsed : 52/52 (100.00%) -Positive Passed: 33/52 (63.46%) +AST Parsed : 53/53 (100.00%) +Positive Passed: 34/53 (64.15%) semantic Error: tasks/coverage/misc/pass/declare-let-private.ts Bindings mismatch: after transform: ScopeId(0): ["private"] diff --git a/tasks/coverage/snapshots/transformer_misc.snap b/tasks/coverage/snapshots/transformer_misc.snap index 3efc821b94367..31f9b009c9e8b 100644 --- a/tasks/coverage/snapshots/transformer_misc.snap +++ b/tasks/coverage/snapshots/transformer_misc.snap @@ -1,3 +1,3 @@ transformer_misc Summary: -AST Parsed : 52/52 (100.00%) -Positive Passed: 52/52 (100.00%) +AST Parsed : 53/53 (100.00%) +Positive Passed: 53/53 (100.00%)