@willbooster/tree-sitter-javascript 5.0.2 → 6.0.0

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.41.8-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-javascript.svg)](https://crates.io/crates/willbooster-tree-sitter-javascript)
10
10
 
11
11
  JavaScript and JSX grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
package/grammar.js CHANGED
@@ -119,12 +119,14 @@ 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
 
125
126
  supertypes: ($) => [
126
127
  $.statement,
127
128
  $.declaration,
129
+ $._decorated_export_declaration,
128
130
  $.expression,
129
131
  $.primary_expression,
130
132
  $.pattern,
@@ -222,6 +224,7 @@ module.exports = grammar({
222
224
 
223
225
  export_statement: ($) =>
224
226
  choice(
227
+ field('declaration', alias($._decorated_export_declaration, $.declaration)),
225
228
  seq(
226
229
  'export',
227
230
  choice(
@@ -235,7 +238,6 @@ module.exports = grammar({
235
238
  $._semicolon
236
239
  ),
237
240
  seq(
238
- repeat(field('decorator', $.decorator)),
239
241
  'export',
240
242
  choice(
241
243
  field('declaration', $.declaration),
@@ -245,6 +247,23 @@ module.exports = grammar({
245
247
  )
246
248
  ),
247
249
 
250
+ _decorated_export_declaration: ($) => alias($._decorated_export_class, $.class_declaration),
251
+
252
+ _decorated_export_class: ($) =>
253
+ prec(
254
+ 'declaration',
255
+ seq(
256
+ repeat1(field('decorator', $.decorator)),
257
+ 'export',
258
+ choice(
259
+ seq('class', field('name', $.identifier)),
260
+ seq('default', 'class', field('name', optional($.identifier)))
261
+ ),
262
+ optional($.class_heritage),
263
+ field('body', $.class_body)
264
+ )
265
+ ),
266
+
248
267
  namespace_export: ($) => seq('*', 'as', $._module_export_name),
249
268
 
250
269
  export_clause: ($) => seq('{', commaSep($.export_specifier), optional(','), '}'),
@@ -351,10 +370,19 @@ module.exports = grammar({
351
370
 
352
371
  variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), $._semicolon),
353
372
 
373
+ _escaped_let: () =>
374
+ token(
375
+ /(?:\\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\}))/
376
+ ),
377
+
354
378
  _let: () => token(prec(-1, /let/)),
355
379
 
356
380
  lexical_declaration: ($) =>
357
- seq(field('kind', choice('let', alias($._let, 'let'), 'const')), commaSep1($.variable_declarator), $._semicolon),
381
+ seq(
382
+ field('kind', choice('let', alias($._let, 'let'), 'const')),
383
+ commaSep1(alias($._lexical_variable_declarator, $.variable_declarator)),
384
+ $._semicolon
385
+ ),
358
386
 
359
387
  using_declaration: ($) =>
360
388
  seq(
@@ -365,7 +393,8 @@ module.exports = grammar({
365
393
  $._semicolon
366
394
  ),
367
395
 
368
- _using_declarator: ($) => seq(field('name', choice($.identifier, alias('of', $.identifier))), $._initializer),
396
+ _using_declarator: ($) =>
397
+ seq(field('name', choice(reserved('lexical', $.identifier), alias('of', $.identifier))), $._initializer),
369
398
 
370
399
  variable_declarator: ($) =>
371
400
  seq(
@@ -373,6 +402,12 @@ module.exports = grammar({
373
402
  optional(choice($._initializer, sym('_line_break_after_binding')))
374
403
  ),
375
404
 
405
+ _lexical_variable_declarator: ($) =>
406
+ seq(
407
+ field('name', choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)),
408
+ optional(choice($._initializer, sym('_line_break_after_binding')))
409
+ ),
410
+
376
411
  statement_block: ($) => prec.right(seq('{', repeat($._statement), '}')),
377
412
 
378
413
  else_clause: ($) => seq('else', $._single_statement),
@@ -422,7 +457,12 @@ module.exports = grammar({
422
457
  // ECMAScript inserts no semicolon inside a for header, so these declarations end only with `;`. Accepting an
423
458
  // automatic semicolon there made `for (let x\n of y)` ambiguous until `of`, and an incremental reparse could
424
459
  // reuse a declaration built when that ambiguity was resolved differently.
425
- for_lexical_declaration: ($) => seq(field('kind', choice('let', 'const')), commaSep1($.variable_declarator), ';'),
460
+ for_lexical_declaration: ($) =>
461
+ seq(
462
+ field('kind', choice('let', 'const')),
463
+ commaSep1(alias($._lexical_variable_declarator, $.variable_declarator)),
464
+ ';'
465
+ ),
426
466
 
427
467
  for_variable_declaration: ($) => seq('var', commaSep1($.variable_declarator), ';'),
428
468
 
@@ -452,7 +492,10 @@ module.exports = grammar({
452
492
  ),
453
493
  seq(
454
494
  field('kind', choice('let', 'const')),
455
- field('left', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern))
495
+ field(
496
+ 'left',
497
+ choice(reserved('lexical', $.identifier), alias('of', $.identifier), $._destructuring_pattern)
498
+ )
456
499
  )
457
500
  ),
458
501
  field('operator', choice('in', 'of'))
@@ -465,7 +508,7 @@ module.exports = grammar({
465
508
  ),
466
509
  seq(field('kind', seq(alias(sym('_await_keyword'), 'await'), 'using')), sym('_resource_binding_start'))
467
510
  ),
468
- field('left', choice($.identifier, alias('of', $.identifier))),
511
+ field('left', choice(reserved('lexical', $.identifier), alias('of', $.identifier))),
469
512
  field('operator', 'of')
470
513
  )
471
514
  ),
@@ -1449,6 +1492,7 @@ module.exports = grammar({
1449
1492
  alias(
1450
1493
  choice(
1451
1494
  $.identifier,
1495
+ $._escaped_let,
1452
1496
  ...CONTEXTUAL_KEYWORDS.map((word) => (word === 'await' ? sym('_await_keyword') : word))
1453
1497
  ),
1454
1498
  sym('property_identifier')
@@ -1474,9 +1518,10 @@ module.exports = grammar({
1474
1518
 
1475
1519
  computed_property_name: ($) => seq('[', $.expression, ']'),
1476
1520
 
1477
- _reserved_identifier: () =>
1521
+ _reserved_identifier: ($) =>
1478
1522
  choice(
1479
1523
  ...MEMBER_MODIFIERS,
1524
+ $._escaped_let,
1480
1525
  ...CONTEXTUAL_KEYWORDS.map((word) => (word === 'await' ? sym('_await_keyword') : word))
1481
1526
  ),
1482
1527
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "5.0.2",
3
+ "version": "6.0.0",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -46,20 +46,19 @@
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.27",
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
- "typescript": "7.0.2",
60
- "vite": "8.3.2",
59
+ "vite": "8.3.4",
61
60
  "vitest": "5.0.3",
62
- "wrangler": "4.147.0"
61
+ "wrangler": "4.149.0"
63
62
  },
64
63
  "peerDependencies": {
65
64
  "@willbooster/web-tree-sitter": "^2.0.0"
@@ -1146,16 +1146,6 @@
1146
1146
  }
1147
1147
  ]
1148
1148
  },
1149
- "decorator": {
1150
- "multiple": true,
1151
- "required": false,
1152
- "types": [
1153
- {
1154
- "type": "decorator",
1155
- "named": true
1156
- }
1157
- ]
1158
- },
1159
1149
  "source": {
1160
1150
  "multiple": false,
1161
1151
  "required": false,
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": "6.0.0",
28
28
  "license": "MIT",
29
29
  "description": "JavaScript grammar for tree-sitter",
30
30
  "authors": [