Skip to content

feat: add js, ts, jsx, tsx support - #4

Open
ShaunSHamilton wants to merge 11 commits into
helsing-ai:mainfrom
ShaunSHamilton:feat_js-ts-support
Open

feat: add js, ts, jsx, tsx support#4
ShaunSHamilton wants to merge 11 commits into
helsing-ai:mainfrom
ShaunSHamilton:feat_js-ts-support

Conversation

@ShaunSHamilton

@ShaunSHamilton ShaunSHamilton commented Aug 11, 2026

Copy link
Copy Markdown

Main Notes

  • tree_sitter_typescript dependency added
  • LANGUAGE_TYPESCRIPT is used to parse JS and TS, because TS is superset of JS
    • this just has the perk of fewer deps
    • same for LANGUAGE_TSX
  • library allows a single yadr to be comprised over adjacent comments. The parsing logic made sense until jsx entered the picture with {/* Comment */} EDIT: Decided to remove support for multi-expression yadr for jsx.
  • I removed some hard-coded comments in the cli test file

@jonhoo jonhoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's make a simplifying assumption here ^

Comment thread tests/fixtures/clean/banner.jsx Outdated

@jonhoo jonhoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a more thorough review this time :)

Comment thread tests/fixtures/clean/cache.js Outdated
Comment on lines +4 to +5
// and the TypeScript fixture, both of the comment forms their closely
// -related grammars share are exercised.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the hard line-wrap here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the rest of the code, I thought there was a 100 char line length limit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the line above is not wrapped and is longer?

Comment thread tests/fixtures/clean/client.ts Outdated
Comment on lines +2 to +3
// The statement is written as a JSDoc block, which is the shape TypeScript code bases reach for
// and the one no other fixture in this tree covers.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't panel.tsx exercise this exact same thing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Right. I added TS before deciding to add the other languages

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what I mean is that we probably don't need both of those tests then — one would be sufficient.

Comment thread tests/fixtures/clean/banner.jsx Outdated
return (
<aside role="status">
{/*
* YADR: 2024-09-05 Render the banner as a sibling of the page content

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of inventing new YADRs for each fixture, we should just make all the fixtures (going forward — no need to change the old ones) use placeholders for each parameter position. So, for example, <use case/user story u>, or maybe even just <u>.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5

Comment thread src/lib.rs Outdated
Comment on lines +524 to +532
// a block never spans two matches, so `last_line` is only ever compared against comments
// from the same one. A `(comment)+` pattern groups comments that are *siblings*, which
// for a run of `//` or `#` lines is the whole run.
//
// JSX is the exception, and the reason a Y-Statement written in markup has to sit in a
// single `{/* ... */}`. Each container wraps its comment in a `jsx_expression` of its own,
// making a run of them only-children rather than siblings, so tree-sitter reports one
// match each and they are never grouped. Therefore, spreading a statement over a run of
// containers is rejected rather than read.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't particularly useful, and can be cut.

Comment thread tests/cli.rs Outdated
Comment on lines +145 to +152
/// `banner.jsx` writes its statement inside JSX markup, in a single `{/* ... */}` container, which
/// is the only comment syntax available in a children position and the only shape a statement in
/// markup may take. Nothing else in the tree covers a statement that is not at the top level of a
/// file.
///
/// Asserting on the reflowed prose rather than on the title is what makes this worth having: a
/// title survives almost any mishandling of the container, whereas the paragraphs only come out
/// whole if the `*` on each line came off and the `{` and `}` around the comment stayed out.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments on all these test cases (here and on instas.rs) are too much. Most probably don't need a comment at all, or could get away with a single line (or maybe sentence).

Comment thread tests/language.rs Outdated
/// `ALL` is what `FromStr` searches and what the unknown-language error lists, so a variant left
/// out of it is unusable from the command line however well it parses.
#[test]
fn all_lists_every_supported_language() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test isn't useful, since it'd just be yet another place where we'd need to remember to add a language.

Comment thread tests/language.rs Outdated
}

#[test]
fn typescript_is_selected_for_ts_files() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a test that doesn't belong in this file (or anywhere).

Comment thread README.md Outdated
Comment on lines +114 to +129
Spreading one statement over a run of shorter containers is unsupported:

```jsx
{
/* YADR: YYYY-MM-DD some title */
}
{
/* */
}
{
/* In the context of ... */
}
```

Everywhere else, a run of adjacent comments is read as one block. Each `{/* ... */}` is a JSX expression of its own rather than a plain comment, and how such containers are laid out across lines is decided by whatever formats the file. Grouping them by line would let a reformat quietly change what a statement says, so a statement in markup is kept to one container instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part can be cut.

Comment thread README.md Outdated
Comment on lines +303 to +306
- Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license
([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated and shouldn't be in this PR.

Comment thread README.md Outdated
Comment on lines +250 to +251
content or decision's validity, simply make the necessary corrections without
updating the date or maintaining a changelog.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change these in this PR.

@jonhoo

jonhoo commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Also, this reads a lot like you're using an LLM to assist you in the work. That's totally fine, but I'd then prefer a Co-Authored-By line on the commits (like most agents automatically include) so that we maintain the transparency on what is written by agents :)

@ShaunSHamilton

Copy link
Copy Markdown
Author

I used an LLM for the tests and readme. So, let me know if you would prefer me to rebase with two commits (one with Co-authored-by: Claude).

@jonhoo

jonhoo commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

I used an LLM for the tests and readme. So, let me know if you would prefer me to rebase with two commits (one with Co-authored-by: Claude).

No, I think it's fine to just include it with upcoming commits that have that property :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants