-
-
Notifications
You must be signed in to change notification settings - Fork 60
feat: add typescript import identifiers example #729
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
Conversation
WalkthroughA new documentation file, Changes
Sequence Diagram(s)Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 (
|
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 (3)
website/catalog/typescript/find-import-identifiers.md (3)
5-13
: Description Section & Bullet List Markdown FormattingThe description is well written and lists the various import scenarios clearly. However, in the "Default & Regular Imports" bullet (line 10), it appears that the inline code formatting may be off—a closing backtick is missing after the import statement. Correcting this will ensure consistent markdown rendering.
15-231
: Comprehensive YAML Rules for Import ExtractionThe YAML section is very thorough and clearly documents rules for different import types (alias, default, regular, dynamic, namespace, and side-effect imports). One minor suggestion: in the REGULAR IMPORTS section (e.g., around lines 67–74), the comment states "ensure it has an 'alias' field" while the actual rule checks the
name
field against$ORIGINAL
. To avoid confusion, consider updating the comment to clarify that it is capturing the original identifier (or, if intended otherwise, adjust the rule accordingly).
232-296
: Thorough Example Code SnippetThe TypeScript code snippet effectively demonstrates a wide range of import scenarios, which will greatly help users understand how the rules apply. One minor enhancement: for the dynamic import examples (e.g., line 286), it might be helpful to add a brief note (or inline comment) clarifying that destructuring from an
import()
call typically requires awaiting the promise, even if this is just for illustrative purposes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
website/catalog/typescript/find-import-identifiers.md
(1 hunks)
🔇 Additional comments (2)
website/catalog/typescript/find-import-identifiers.md (2)
1-3
: Great Introduction and Informative Playground LinkThe document opens with a clear, descriptive title and a useful playground link. Please verify that the base64 query parameters in the URL correctly encode the intended configuration and render as expected on the playground.
298-301
: Contributor Acknowledgment is ClearThe acknowledgment section properly credits the contributor with a direct link to their GitHub profile. This section is clear and serves its purpose.
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.
Thanks!
Hi, I'm glad that GitLab is considering ast-grep as a tool to parse code.
To my best knowledge, ast-grep should be at least as good as tree-sitter's query. ast-grep also supports advanced rule like recursive utility which is not possible in tree-sitter query.
Unfortunately, AST handling isn't always easy, especially when you are building a generic tool. Global utility rule can help you organize the rule a little bit. |
Thank you, @HerringtonDarkholme and other contributors, for this awesome project!
I'm currently learning
ast-grep
. We're looking to use this at GitLab for our AST Code Parser project.I wanted to see if I could replicate all the logic built here for our JS import parser in the Language Server. We built this parser to extract imports for AI Code Suggestions (you can read more at this epic).
I decided to contribute back as soon as I got something working. If y'all think there's a more straightforward way to achieve the same metadata extraction, by all means, please suggest changes!
Thank you!
Summary by CodeRabbit