-
Notifications
You must be signed in to change notification settings - Fork 6
✨ JSON #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ JSON #54
Conversation
WalkthroughThis pull request introduces the Changes
Suggested Reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
45affb7
to
341d8ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/json/index.d.ts (1)
1-7
: Consider adding JSDoc comments to improve documentation.The
LanguageRegistration
type is well-structured with the appropriate properties. Consider adding JSDoc comments to document each field's purpose for better developer experience.+/** + * Registration metadata for a language in ast-grep. + */ type LanguageRegistration = { + /** Path to the language library */ libraryPath: string + /** Array of file extensions supported by this language */ extensions: string[] + /** Optional symbol representing the language */ languageSymbol?: string + /** Character used for meta variables */ metaVarChar?: string + /** Character used for expando variables */ expandoChar?: string }packages/json/nursery.js (1)
5-16
: Expand test coverage for more comprehensive validation.While the basic test setup is functional, it only tests a simple case with one assertion. Consider expanding the test suite to cover:
- Different JSON structures (arrays, nested objects)
- Various value types (strings, numbers, booleans, null)
- Edge cases (empty objects, arrays)
This would provide greater confidence in the JSON parser's functionality.
testRunner: parse => { const sg = parse('{"abc": 123}') const root = sg.root() const node = root.find('{ $$$ }') assert.equal(node.kind(), 'object') + + // Test JSON array + const sgArray = parse('[1, 2, 3]') + const arrayRoot = sgArray.root() + const arrayNode = arrayRoot.find('[ $$$ ]') + assert.equal(arrayNode.kind(), 'array') + + // Test nested structures + const sgNested = parse('{"nested": {"value": true, "array": [1, null]}}') + const nestedRoot = sgNested.root() + assert.equal(nestedRoot.find('{ "nested": $$$ }').kind(), 'object') + assert.equal(nestedRoot.find('true').kind(), 'true') + assert.equal(nestedRoot.find('null').kind(), 'null') },packages/json/package.json (1)
1-48
: Metadata Completeness: Populate 'description' and 'author' Fields
The package metadata is mostly complete; however, the"description"
and"author"
fields are currently empty. Populating these fields with relevant information will improve package discoverability and maintainability.packages/json/index.js (1)
1-3
: Correct Usage of Node.js Path Module
The use ofnode:path
andpath.join(__dirname, 'parser.so')
is correct for constructing the path toparser.so
. Ensure that the shared library is built and present when the module is loaded.packages/json/README.md (1)
1-3
: Clarify README Title for Consistency
The current title "ast-grep napi language for json" could be more descriptive. Consider updating it to explicitly reference JSON support (e.g., "@ast-grep/lang-json: JSON Language Module") to align with the package name.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
.changeset/smart-moose-sniff.md
(1 hunks)packages/json/README.md
(1 hunks)packages/json/index.d.ts
(1 hunks)packages/json/index.js
(1 hunks)packages/json/nursery.js
(1 hunks)packages/json/package.json
(1 hunks)packages/json/postinstall.js
(1 hunks)
🔇 Additional comments (7)
.changeset/smart-moose-sniff.md (1)
1-6
: LGTM! Changeset entry is properly structured.The changeset correctly identifies the package name and version bump type (patch) for the new
@ast-grep/lang-json
package.packages/json/postinstall.js (1)
1-5
: LGTM! Post-installation script is properly configured.The script correctly imports and calls the
postinstall
function from@ast-grep/setup-lang
with the current directory.packages/json/index.d.ts (1)
9-10
: LGTM! Proper export of the registration constant.The
registration
constant is correctly declared and exported.packages/json/nursery.js (1)
1-4
: LGTM! Necessary dependencies are properly imported.The required modules for testing are correctly imported.
packages/json/index.js (1)
4-9
: Module Export for JSON Parsing Configuration
The exported object correctly defines the properties (libraryPath
,extensions
,languageSymbol
, andexpandoChar
) required for JSON parsing. The implementation is clear and straightforward.packages/json/README.md (2)
3-12
: Clear Installation Instructions
The installation section clearly outlines the commands needed for a pnpm project, including the optional installation of@tree-sitter/cli
. This provides users with straightforward guidance on setting up the package.
14-25
: Well-Documented Usage Example
The usage section provides a concise and comprehensive example showing how to import and register the JSON language dynamically using@ast-grep/napi
. This will help users quickly understand how to integrate the package.
oops, we are still having conflicts |
I suspect we're going to continue having these until the last one :P |
Summary by CodeRabbit
New Features
@ast-grep/lang-json
for JSON parsing.Documentation
Tests