@willbooster/tree-sitter-javascript 1.0.31 → 2.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/grammar.js CHANGED
@@ -104,6 +104,8 @@ module.exports = grammar({
104
104
  $._resource_binding_start,
105
105
  $._resource_binding_continuation,
106
106
  $._plain_resource_for_of_context,
107
+ $._export_default,
108
+ $._default_declaration_start,
107
109
  ],
108
110
 
109
111
  extras: ($) => [$.comment, $.html_comment, /[\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B]/u],
@@ -222,7 +224,10 @@ module.exports = grammar({
222
224
  'export',
223
225
  choice(
224
226
  field('declaration', $.declaration),
225
- seq('default', choice(field('declaration', $.declaration), seq(field('value', $.expression), $._semicolon)))
227
+ seq(
228
+ alias($._export_default, 'default'),
229
+ choice(field('declaration', $.declaration), seq(field('value', $.expression), $._semicolon))
230
+ )
226
231
  )
227
232
  )
228
233
  ),
@@ -742,9 +747,15 @@ module.exports = grammar({
742
747
  prec(
743
748
  'declaration',
744
749
  seq(
745
- repeat(field('decorator', $.decorator)),
746
- 'class',
747
- field('name', $.identifier),
750
+ choice(
751
+ seq(
752
+ $._default_declaration_start,
753
+ repeat(field('decorator', $.decorator)),
754
+ 'class',
755
+ field('name', optional($.identifier))
756
+ ),
757
+ seq(repeat(field('decorator', $.decorator)), 'class', field('name', $.identifier))
758
+ ),
748
759
  optional($.class_heritage),
749
760
  field('body', $.class_body)
750
761
  )
@@ -768,9 +779,10 @@ module.exports = grammar({
768
779
  prec.right(
769
780
  'declaration',
770
781
  seq(
771
- optional('async'),
772
- 'function',
773
- field('name', $.identifier),
782
+ choice(
783
+ seq($._default_declaration_start, optional('async'), 'function', field('name', optional($.identifier))),
784
+ seq(optional('async'), 'function', field('name', $.identifier))
785
+ ),
774
786
  $._call_signature,
775
787
  field('body', $.statement_block)
776
788
  )
@@ -793,10 +805,16 @@ module.exports = grammar({
793
805
  prec.right(
794
806
  'declaration',
795
807
  seq(
796
- optional('async'),
797
- 'function',
798
- '*',
799
- field('name', $.identifier),
808
+ choice(
809
+ seq(
810
+ $._default_declaration_start,
811
+ optional('async'),
812
+ 'function',
813
+ '*',
814
+ field('name', optional($.identifier))
815
+ ),
816
+ seq(optional('async'), 'function', '*', field('name', $.identifier))
817
+ ),
800
818
  $._call_signature,
801
819
  field('body', $.statement_block)
802
820
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "1.0.31",
3
+ "version": "2.0.0",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -923,7 +923,7 @@
923
923
  },
924
924
  "name": {
925
925
  "multiple": false,
926
- "required": true,
926
+ "required": false,
927
927
  "types": [
928
928
  {
929
929
  "type": "identifier",
@@ -1514,7 +1514,7 @@
1514
1514
  },
1515
1515
  "name": {
1516
1516
  "multiple": false,
1517
- "required": true,
1517
+ "required": false,
1518
1518
  "types": [
1519
1519
  {
1520
1520
  "type": "identifier",
@@ -1622,7 +1622,7 @@
1622
1622
  },
1623
1623
  "name": {
1624
1624
  "multiple": false,
1625
- "required": true,
1625
+ "required": false,
1626
1626
  "types": [
1627
1627
  {
1628
1628
  "type": "identifier",
Binary file
package/tree-sitter.json CHANGED
@@ -24,7 +24,7 @@
24
24
  }
25
25
  ],
26
26
  "metadata": {
27
- "version": "1.0.31",
27
+ "version": "2.0.0",
28
28
  "license": "MIT",
29
29
  "description": "JavaScript grammar for tree-sitter",
30
30
  "authors": [