@willbooster/tree-sitter-javascript 5.0.2 → 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
@@ -119,6 +119,7 @@ module.exports = grammar({
119
119
 
120
120
  reserved: {
121
121
  global: () => RESERVED_WORDS,
122
+ lexical: ($) => [...RESERVED_WORDS, 'let', $._escaped_let],
122
123
  properties: () => [],
123
124
  },
124
125
 
@@ -351,10 +352,19 @@ module.exports = grammar({
351
352
 
352
353
  variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), $._semicolon),
353
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
+
354
360
  _let: () => token(prec(-1, /let/)),
355
361
 
356
362
  lexical_declaration: ($) =>
357
- 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
+ ),
358
368
 
359
369
  using_declaration: ($) =>
360
370
  seq(
@@ -365,7 +375,8 @@ module.exports = grammar({
365
375
  $._semicolon
366
376
  ),
367
377
 
368
- _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),
369
380
 
370
381
  variable_declarator: ($) =>
371
382
  seq(
@@ -373,6 +384,12 @@ module.exports = grammar({
373
384
  optional(choice($._initializer, sym('_line_break_after_binding')))
374
385
  ),
375
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
+
376
393
  statement_block: ($) => prec.right(seq('{', repeat($._statement), '}')),
377
394
 
378
395
  else_clause: ($) => seq('else', $._single_statement),
@@ -422,7 +439,12 @@ module.exports = grammar({
422
439
  // ECMAScript inserts no semicolon inside a for header, so these declarations end only with `;`. Accepting an
423
440
  // automatic semicolon there made `for (let x\n of y)` ambiguous until `of`, and an incremental reparse could
424
441
  // reuse a declaration built when that ambiguity was resolved differently.
425
- 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
+ ),
426
448
 
427
449
  for_variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), ';'),
428
450
 
@@ -452,7 +474,10 @@ module.exports = grammar({
452
474
  ),
453
475
  seq(
454
476
  field('kind', choice('let', 'const')),
455
- field('left', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern))
477
+ field(
478
+ 'left',
479
+ choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)
480
+ )
456
481
  )
457
482
  ),
458
483
  field('operator', choice('in', 'of'))
@@ -465,7 +490,7 @@ module.exports = grammar({
465
490
  ),
466
491
  seq(field('kind', seq(alias(sym('_await_keyword'), 'await'), 'using')), sym('_resource_binding_start'))
467
492
  ),
468
- field('left', choice($.identifier, alias('of', $.identifier))),
493
+ field('left', choice(reserved('lexical', $.identifier), alias('of', $.identifier))),
469
494
  field('operator', 'of')
470
495
  )
471
496
  ),
@@ -1449,6 +1474,7 @@ module.exports = grammar({
1449
1474
  alias(
1450
1475
  choice(
1451
1476
  $.identifier,
1477
+ $._escaped_let,
1452
1478
  ...CONTEXTUAL_KEYWORDS.map((word) => (word === 'await' ? sym('_await_keyword') : word))
1453
1479
  ),
1454
1480
  sym('property_identifier')
@@ -1474,9 +1500,10 @@ module.exports = grammar({
1474
1500
 
1475
1501
  computed_property_name: ($) => seq('[', $.expression, ']'),
1476
1502
 
1477
- _reserved_identifier: () =>
1503
+ _reserved_identifier: ($) =>
1478
1504
  choice(
1479
1505
  ...MEMBER_MODIFIERS,
1506
+ $._escaped_let,
1480
1507
  ...CONTEXTUAL_KEYWORDS.map((word) => (word === 'await' ? sym('_await_keyword') : word))
1481
1508
  ),
1482
1509
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "5.0.2",
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.2",
27
+ "version": "5.0.3",
28
28
  "license": "MIT",
29
29
  "description": "JavaScript grammar for tree-sitter",
30
30
  "authors": [