@willbooster/tree-sitter-javascript 5.0.1 → 5.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/grammar.js CHANGED
@@ -108,6 +108,7 @@ module.exports = grammar({
108
108
  sym('_resource_binding_continuation'),
109
109
  sym('_plain_resource_for_of_context'),
110
110
  sym('_export_default'),
111
+ sym('_export_default_declaration'),
111
112
  sym('_default_declaration_start'),
112
113
  sym('_regex_flags_start'),
113
114
  sym('_argumentless_new_end'),
@@ -118,6 +119,7 @@ module.exports = grammar({
118
119
 
119
120
  reserved: {
120
121
  global: () => RESERVED_WORDS,
122
+ lexical: ($) => [...RESERVED_WORDS, 'let', $._escaped_let],
121
123
  properties: () => [],
122
124
  },
123
125
 
@@ -238,10 +240,8 @@ module.exports = grammar({
238
240
  'export',
239
241
  choice(
240
242
  field('declaration', $.declaration),
241
- seq(
242
- alias(sym('_export_default'), 'default'),
243
- choice(field('declaration', $.declaration), seq(field('value', $.expression), $._semicolon))
244
- )
243
+ seq(alias(sym('_export_default_declaration'), 'default'), field('declaration', $.declaration)),
244
+ seq(alias(sym('_export_default'), 'default'), field('value', $.expression), $._semicolon)
245
245
  )
246
246
  )
247
247
  ),
@@ -352,10 +352,19 @@ module.exports = grammar({
352
352
 
353
353
  variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), $._semicolon),
354
354
 
355
+ _escaped_let: () =>
356
+ token(
357
+ /(?:\\u(?:006[cC]|\{0*6[cC]\}))(?:e|\\u(?:0065|\{0*65\}))(?:t|\\u(?:0074|\{0*74\}))|l(?:\\u(?:0065|\{0*65\}))(?:t|\\u(?:0074|\{0*74\}))|le(?:\\u(?:0074|\{0*74\}))/
358
+ ),
359
+
355
360
  _let: () => token(prec(-1, /let/)),
356
361
 
357
362
  lexical_declaration: ($) =>
358
- seq(field('kind', choice('let', alias($._let, 'let'), 'const')), commaSep1($.variable_declarator), $._semicolon),
363
+ seq(
364
+ field('kind', choice('let', alias($._let, 'let'), 'const')),
365
+ commaSep1(alias($._lexical_variable_declarator, $.variable_declarator)),
366
+ $._semicolon
367
+ ),
359
368
 
360
369
  using_declaration: ($) =>
361
370
  seq(
@@ -366,7 +375,8 @@ module.exports = grammar({
366
375
  $._semicolon
367
376
  ),
368
377
 
369
- _using_declarator: ($) => seq(field('name', choice($.identifier, alias('of', $.identifier))), $._initializer),
378
+ _using_declarator: ($) =>
379
+ seq(field('name', choice(reserved('lexical', $.identifier), alias('of', $.identifier))), $._initializer),
370
380
 
371
381
  variable_declarator: ($) =>
372
382
  seq(
@@ -374,6 +384,12 @@ module.exports = grammar({
374
384
  optional(choice($._initializer, sym('_line_break_after_binding')))
375
385
  ),
376
386
 
387
+ _lexical_variable_declarator: ($) =>
388
+ seq(
389
+ field('name', choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)),
390
+ optional(choice($._initializer, sym('_line_break_after_binding')))
391
+ ),
392
+
377
393
  statement_block: ($) => prec.right(seq('{', repeat($._statement), '}')),
378
394
 
379
395
  else_clause: ($) => seq('else', $._single_statement),
@@ -423,7 +439,12 @@ module.exports = grammar({
423
439
  // ECMAScript inserts no semicolon inside a for header, so these declarations end only with `;`. Accepting an
424
440
  // automatic semicolon there made `for (let x\n of y)` ambiguous until `of`, and an incremental reparse could
425
441
  // reuse a declaration built when that ambiguity was resolved differently.
426
- for_lexical_declaration: ($) => seq(field('kind', choice('let', 'const')), commaSep1($.variable_declarator), ';'),
442
+ for_lexical_declaration: ($) =>
443
+ seq(
444
+ field('kind', choice('let', 'const')),
445
+ commaSep1(alias($._lexical_variable_declarator, $.variable_declarator)),
446
+ ';'
447
+ ),
427
448
 
428
449
  for_variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), ';'),
429
450
 
@@ -453,7 +474,10 @@ module.exports = grammar({
453
474
  ),
454
475
  seq(
455
476
  field('kind', choice('let', 'const')),
456
- field('left', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern))
477
+ field(
478
+ 'left',
479
+ choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)
480
+ )
457
481
  )
458
482
  ),
459
483
  field('operator', choice('in', 'of'))
@@ -466,7 +490,7 @@ module.exports = grammar({
466
490
  ),
467
491
  seq(field('kind', seq(alias(sym('_await_keyword'), 'await'), 'using')), sym('_resource_binding_start'))
468
492
  ),
469
- field('left', choice($.identifier, alias('of', $.identifier))),
493
+ field('left', choice(reserved('lexical', $.identifier), alias('of', $.identifier))),
470
494
  field('operator', 'of')
471
495
  )
472
496
  ),
@@ -1450,6 +1474,7 @@ module.exports = grammar({
1450
1474
  alias(
1451
1475
  choice(
1452
1476
  $.identifier,
1477
+ $._escaped_let,
1453
1478
  ...CONTEXTUAL_KEYWORDS.map((word) => (word === 'await' ? sym('_await_keyword') : word))
1454
1479
  ),
1455
1480
  sym('property_identifier')
@@ -1475,9 +1500,10 @@ module.exports = grammar({
1475
1500
 
1476
1501
  computed_property_name: ($) => seq('[', $.expression, ']'),
1477
1502
 
1478
- _reserved_identifier: () =>
1503
+ _reserved_identifier: ($) =>
1479
1504
  choice(
1480
1505
  ...MEMBER_MODIFIERS,
1506
+ $._escaped_let,
1481
1507
  ...CONTEXTUAL_KEYWORDS.map((word) => (word === 'await' ? sym('_await_keyword') : word))
1482
1508
  ),
1483
1509
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -46,20 +46,20 @@
46
46
  "@vitest/browser-playwright": "5.0.3",
47
47
  "@willbooster/oxfmt-config": "1.2.2",
48
48
  "@willbooster/oxlint-config": "1.4.8",
49
- "@willbooster/wb": "22.24.0",
50
- "@willbooster/web-tree-sitter": "2.0.1",
51
- "conventional-changelog-conventionalcommits": "10.4.0",
52
- "lefthook": "2.1.16",
53
- "oxfmt": "0.71.0",
54
- "oxlint": "1.86.0",
55
- "oxlint-tsgolint": "7.0.2003",
56
- "playwright": "1.63.0",
49
+ "@willbooster/wb": "22.26.1",
50
+ "@willbooster/web-tree-sitter": "2.0.24",
51
+ "conventional-changelog-conventionalcommits": "10.4.1",
52
+ "lefthook": "2.2.1",
53
+ "oxfmt": "0.72.0",
54
+ "oxlint": "1.87.0",
55
+ "oxlint-tsgolint": "7.0.2004",
56
+ "playwright": "1.64.0",
57
57
  "semantic-release": "25.0.9",
58
58
  "sort-package-json": "4.0.0",
59
59
  "typescript": "7.0.2",
60
- "vite": "8.3.2",
60
+ "vite": "8.3.4",
61
61
  "vitest": "5.0.3",
62
- "wrangler": "4.147.0"
62
+ "wrangler": "4.149.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@willbooster/web-tree-sitter": "^2.0.0"
Binary file
package/tree-sitter.json CHANGED
@@ -24,7 +24,7 @@
24
24
  }
25
25
  ],
26
26
  "metadata": {
27
- "version": "5.0.1",
27
+ "version": "5.0.3",
28
28
  "license": "MIT",
29
29
  "description": "JavaScript grammar for tree-sitter",
30
30
  "authors": [