@willbooster/tree-sitter-javascript 1.0.16 → 1.0.18

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,14 +5,15 @@
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.26.0-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.28.6-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
12
12
  [tree-sitter/tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript). We are grateful
13
13
  to its authors and contributors. This is not an official release of that project.
14
14
 
15
- This fork fixes parsing bugs and raises conformance with [ECMAScript (ECMA-262)](https://tc39.es/ecma262/) and [JSX](https://facebook.github.io/jsx/).
15
+ This fork fixes parsing bugs and raises conformance with [ECMAScript (ECMA-262)](https://tc39.es/ecma262/) and
16
+ [JSX](https://facebook.github.io/jsx/).
16
17
 
17
18
  ## Usage
18
19
 
@@ -56,8 +57,9 @@ const parser = new Parser();
56
57
  parser.setLanguage(await Language.load(javascript));
57
58
  ```
58
59
 
59
- The package also ships the node types in `src/node-types.json`, and `grammar.js` and the queries in `queries/` for
60
- grammars that extend this one (e.g. `require('@willbooster/tree-sitter-javascript/grammar')`).
60
+ The package also ships the node types in `src/node-types.json`, the highlight, injection, locals, and tags queries in
61
+ `queries/` that `tree-sitter.json` lists, and `grammar.js` for grammars that extend this one (e.g.
62
+ `require('@willbooster/tree-sitter-javascript/grammar')`). The crate ships `tree-sitter.json` and `queries/` too.
61
63
 
62
64
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-javascript) and on
63
65
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
@@ -89,22 +91,32 @@ cargo test
89
91
  `bun run test` runs:
90
92
 
91
93
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
92
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `tree-sitter fuzz` edits each corpus case at random,
93
- reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`, `TREE_SITTER_ITERATIONS`, and
94
- `TREE_SITTER_EDITS` run other or more edits;
94
+ - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
95
+ edits each corpus case at random, reparses it, undoes the edits, and reparses again, on the WillBooster/tree-sitter
96
+ runtime version locked in `Cargo.lock` (the first run downloads that CLI from its GitHub Release, or builds it with
97
+ `cargo` when the download fails or the release has no binary that runs here). `TREE_SITTER_SEED`,
98
+ `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
95
99
  - a check that the real-world JavaScript files in `examples/`, the checked-in ones and those of the cloned repository,
96
- fail to parse exactly as listed in `script/known-failures.txt`. The first run clones the repository. The example repository is pinned to a commit in
97
- `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites
98
- it; review its diff before committing;
99
- - a performance check (`test/unit/performance.test.ts`) that recovering from an error on each of 10,000 lines takes
100
- linear time, since consumers parse files while they are being edited. It loads the Wasm build through
101
- @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating the parser;
100
+ fail to parse exactly as listed in `script/known-failures.txt`. The first run clones the repository. The example
101
+ repository is pinned to a commit in `script/parse-examples`. After a grammar change or a moved pin alters that list,
102
+ `script/parse-examples` rewrites it; review its diff before committing;
103
+ - a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes linear time
104
+ (ten times the lines take about ten times the CPU time), since consumers parse files while they are being edited.
105
+ It loads the Wasm build through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating
106
+ the parser;
102
107
  - checks that the Wasm build parses in Chromium (`test/unit/browser/`) and in Cloudflare Workers with and without
103
108
  Node.js compatibility (`test/unit/workers.test.ts`). Run `bun run test/ci-setup` once before the first
104
- run to install Chromium and, on Linux, the system libraries it needs.
109
+ run to install Chromium and, on Linux, the system libraries it needs;
110
+ - a check that `package.json` and `Cargo.lock` lock the same WillBooster/tree-sitter runtime version
111
+ (`test/unit/runtimeVersion.test.ts`);
112
+ - a check that the queries `tree-sitter.json` lists compile against the Wasm build and are in both the npm package and
113
+ the crate (`test/unit/queries.test.ts`).
105
114
 
106
- CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the parser with libFuzzer and sanitizers
107
- (`.github/workflows/robustness.yml`).
115
+ The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` instead of the CLI's cache shared
116
+ by every checkout; `script/fuzz-corpus` builds a per-run parser in `.tmp/fuzz` and deletes it afterwards.
117
+
118
+ CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the
119
+ parser with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
108
120
 
109
121
  ### References
110
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -46,12 +46,12 @@
46
46
  "@willbooster/oxfmt-config": "1.2.2",
47
47
  "@willbooster/oxlint-config": "1.4.8",
48
48
  "@willbooster/wb": "22.13.1",
49
- "@willbooster/web-tree-sitter": "1.0.7",
49
+ "@willbooster/web-tree-sitter": "1.0.12",
50
50
  "conventional-changelog-conventionalcommits": "10.4.0",
51
51
  "lefthook": "2.1.14",
52
52
  "oxfmt": "0.70.0",
53
53
  "oxlint": "1.85.0",
54
- "oxlint-tsgolint": "7.0.2002",
54
+ "oxlint-tsgolint": "7.0.2003",
55
55
  "playwright": "1.63.0",
56
56
  "semantic-release": "25.0.9",
57
57
  "sort-package-json": "4.0.0",
Binary file
package/tree-sitter.json CHANGED
@@ -12,11 +12,19 @@
12
12
  "cjs",
13
13
  "jsx"
14
14
  ],
15
+ "highlights": [
16
+ "queries/highlights.scm",
17
+ "queries/highlights-jsx.scm",
18
+ "queries/highlights-params.scm"
19
+ ],
20
+ "injections": "queries/injections.scm",
21
+ "locals": "queries/locals.scm",
22
+ "tags": "queries/tags.scm",
15
23
  "injection-regex": "^(js|javascript)$"
16
24
  }
17
25
  ],
18
26
  "metadata": {
19
- "version": "1.0.16",
27
+ "version": "1.0.18",
20
28
  "license": "MIT",
21
29
  "description": "JavaScript grammar for tree-sitter",
22
30
  "authors": [