tree-sitter-javascript

JavaScript and JSX grammar for the tree-sitter incremental parsing library

Library
Cargo
v0.25.0
494 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
56 /100 Fair
Development Activity 44
Maintenance 20
Community 80
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 85
Code Quality 82
Innovation 75
Learning Curve 65

tree-sitter-javascript is the official JavaScript grammar for tree-sitter, the incremental parsing library used by editors, linters, and code-intelligence tools to build and update syntax trees in real time as code is edited. The grammar aims for close conformance to the ECMAScript specification while adding JSX syntax support, and ships pre-generated parser tables (parser.c) plus hand-written scanner logic (scanner.c) for the constructs regular grammars can’t express cleanly, like automatic semicolon insertion and template literals.

As a Rust crate it exposes a LANGUAGE constant that plugs directly into a tree_sitter::Parser, along with bundled syntax-highlighting, local-variable, and symbol-tagging queries (.scm files) that consuming tools use for editor features like highlighting, code folding, and “go to definition”. The same grammar is also published for Node.js, Python, Go, and Swift, making it the shared JS/JSX parsing foundation across many tree-sitter-based tools (Neovim, Helix, GitHub’s code navigation, and others).

What You Get

  • A LANGUAGE constant (Rust) or equivalent binding (Node, Python, Go, Swift) that plugs directly into a tree_sitter::Parser
  • Pre-generated parser.c/grammar.json/node-types.json so consumers don’t need the tree-sitter CLI to use the grammar
  • A hand-written C scanner (scanner.c) handling context-sensitive lexing tree-sitter’s declarative grammar can’t express alone (ASI, template strings, JSX text)
  • Bundled .scm query files for syntax highlighting, JSX highlighting, local-variable resolution, and symbol tagging
  • Multi-language bindings published to crates.io, npm, PyPI, Go modules, and Swift Package Manager from a single grammar source

Common Use Cases

  • Building editor syntax highlighting and code folding for JavaScript/JSX files (used by Neovim, Helix, and other tree-sitter-based editors)
  • Powering static analysis, linting, or code-navigation tools that need a real syntax tree rather than regex-based parsing
  • Embedding incremental JS/JSX parsing in a Rust, Node.js, Python, or Go application via the corresponding language binding
  • Extracting local-variable and symbol information from JavaScript source for “go to definition” or refactoring tooling

Under The Hood

Architecture - The grammar itself is authored in grammar.js as a declarative DSL (rules, precedences, conflicts, external tokens) which the tree-sitter CLI compiles ahead of time into the checked-in src/parser.c, src/grammar.json, and src/node-types.json — so consuming crates never need to run code generation themselves. Context-sensitive lexing that the declarative grammar can’t express (automatic semicolon insertion, template literal interpolation boundaries, JSX text vs. tag detection) is handled by a hand-written external scanner in src/scanner.c, referenced from grammar.js’s externals array. The queries/ directory (highlights.scm, highlights-jsx.scm, locals.scm, tags.scm, injections.scm) provides tree-sitter-query-language rules that map syntax nodes to highlight scopes, variable-scoping information, and taggable symbols — the layer most editor integrations actually consume.

Tech Stack - The grammar source is JavaScript (grammar.js), compiled to C for the actual parser tables; the Rust binding (bindings/rust/lib.rs) is a thin extern "C" wrapper depending only on the lightweight tree-sitter-language crate, with cc as a build-dependency to compile parser.c/scanner.c. Equivalent thin bindings exist for Node.js (binding.gyp), Python (setup.py/pyproject.toml), Go (go.mod), and Swift (Package.swift), all wrapping the same generated C sources.

Code Quality - test/ contains corpus-based parse tests (input source plus expected S-expression trees), which is the standard tree-sitter testing convention and gives good coverage of grammar edge cases across ECMAScript features and JSX. CI (.github/workflows/ci.yml) runs across the multi-language binding matrix. The Rust binding includes an inline doc-test demonstrating a minimal parse, and a #[test] fn test_can_load_grammar() smoke test verifying the compiled language loads correctly.

API Design - Consumers only need one call — parser.set_language(&tree_sitter_javascript::LANGUAGE.into()) — to get a working parser; the crate’s real surface area is the constants it exports (LANGUAGE, NODE_TYPES, HIGHLIGHT_QUERY, LOCALS_QUERY, TAGS_QUERY) rather than functions to call, which keeps integration boilerplate minimal for editor and tooling authors.

Used by 9 apps in this directory

TypeScript
72%
MIT

Claude Context

AI Code Assistants · Mcp

12,573

An MCP server and VS Code extension by Zilliz that turns your entire codebase into semantically searchable context for Claude Code, Cursor, and Gemini CLI, using vector embeddings and Merkle-tree change detection.

View details
46
Repo Health
71
Technical
71
Dependency
Built with
TypeScript 72%
Python 13%
JavaScript 11%
Updated 2 months ago
TypeScript
46%
Apache 2.0

claude-mem

AI Agents · AI Development · AI Memory

94,808

Give your AI coding agents persistent memory — claude-mem captures everything that happens during sessions, compresses it with AI, and surfaces the right context in every future session automatically.

View details
86
Repo Health
82
Technical
77
Dependency
Built with
TypeScript 46%
JavaScript 40%
Python 12%
Updated 6 days ago
Rust
52%
Apache 2.0

cocoindex

AI Development · Data Engineering

11,607

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 52%
Python 48%
Updated 5 days ago
C
83%
MIT

codegraph

AI Code Assistants · Developer Tools

72,201

A pre-indexed code knowledge graph that cuts AI tool calls by 58% and token costs by 16% — auto-syncing, 100% local, works with Claude Code, Cursor, Codex, and more.

View details
84
Repo Health
85
Technical
70
Dependency
Built with
C 83%
TypeScript 14%
Updated 6 days ago
Rust
88%
GPL 2.0

Fresh

Code Editors · Developer Tools

9,052

A zero-configuration terminal text editor with familiar keybindings, full mouse support, LSP-powered IDE features, and a built-in orchestrator for running multiple coding agents in parallel worktrees.

View details
86
Repo Health
88
Technical
71
Dependency
Built with
Rust 88%
Updated 6 days ago
TypeScript
91%
Other

GitNexus

AI Code Assistants · Developer Tools · Mcp

47,620

Index any codebase into an interactive knowledge graph and give your AI agents deep architectural context via MCP — with zero servers required.

View details
88
Repo Health
86
Technical
73
Dependency
Built with
TypeScript 91%
Updated 5 days ago
Python
100%
MIT

Graphify

AI Agents

121,917

A YC-backed, open-source knowledge graph skill for AI coding assistants — type /graphify and it maps your entire project (code, docs, PDFs, images, videos) into a queryable graph instead of grepping through files.

View details
83
Repo Health
73
Technical
72
Dependency
Built with
Python 100%
Updated 6 days ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 5 days ago
Rust
90%
MIT

Zeron

AI Code Assistants · Developer Tools

2,254

A native, Rust-built control plane that runs and steers Claude Code, Codex, Cursor, Devin, and other coding agents from any device, locally by default with optional CRDT-synced multi-device control.

View details
78
Repo Health
82
Technical
78
Dependency
Built with
Rust 90%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers