tree-sitter-javascript
repository·master·Indexed 19 days ago
https://github.com/tree-sitter/tree-sitter-javascriptA concrete syntax tree (CST) parser grammar for JavaScript and JSX designed for the tree-sitter incremental parsing engine. It approximates the ECMAScript specification and provides Node.js bindings, including a nodeTypeInfo object for inspecting grammar node metadata.
What's inside tree-sitter-javascript
- tree-sitter-javascript provides a JavaScript and JSX grammar for the tree-sitter incremental parsing library. It aims to closely approximate the ECMAScript specification while adding support for JSX syntax. It targets the latest versions of the ECMAScript spec, though very recent features may have delayed support.
Use eslint-config-treesitter for ESLint configuration
masterTo apply the tree-sitter linting rules to your project, import
treesitterfromeslint-config-treesitterand spread it into youreslint.config.mjs(Flat Config) array. This provides a pre-configured set of rules optimized for tree-sitter based linting.import treesitter from 'eslint-config-treesitter'; export default [ ...treesitter, ];Import the tree-sitter-javascript Node.js bindings
masterTo use the JavaScript grammar in a Node.js environment, require the
tree-sitter-javascriptpackage. The package automatically handles loading the correct prebuilt binary for your platform and architecture usingnode-gyp-build.If you are using Bun, the package is designed to be statically analyzable to support
bun build --compileby locating the.nodefile at build-time.const JavaScript = require('tree-sitter-javascript');Access nodeTypeInfo for JavaScript grammar nodes
masterThe bindings export a
nodeTypeInfoobject which contains metadata about the node types defined in the JavaScript grammar. This is useful for inspecting the grammar's structure or understanding available node types programmatically.const JavaScript = require('tree-sitter-javascript'); // Access metadata about the grammar's node types const typeInfo = JavaScript.nodeTypeInfo; console.log(typeInfo);