tree-sitter-javascript

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

Library
Cargo
v0.25.0
493stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
45/100Fair
Development Activity0
Maintenance20
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture85
Code Quality82
Innovation75
Learning Curve65

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 5 apps in this directory

TypeScript
72%
MIT

Claude Context

AI Code Assistants

12,498

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
49
Repo Health
71
Technical
71
Dependency
Built with
TypeScript72%
Python13%
JavaScript11%
Updated 1 months ago
JavaScript
51%
Apache 2.0

claude-mem

AI Agents · AI Development

93,347

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
JavaScript51%
TypeScript47%
Updated yesterday
Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,496

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

View details
86
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated 2 days ago
C
86%
MIT

codegraph

Developer Tools · AI Code Assistants

69,843

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
82
Repo Health
85
Technical
72
Dependency
Built with
C86%
TypeScript11%
Updated 1 weeks ago
TypeScript
92%
Other

GitNexus

Developer Tools · AI Code Assistants

47,086

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
TypeScript92%
Updated yesterday

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

Search