Skip to content

Conversation

@jsantell
Copy link
Collaborator

@jsantell jsantell commented Oct 10, 2025

Summary by cubic

Detect the reserved __ctHelpers only when used as an identifier, instead of using a raw string check. This removes false positives from comments and similar names.

  • Bug Fixes
    • Parse the TypeScript AST and throw only on Identifier("__ctHelpers").
    • Allow occurrences in comments and substrings (e.g., __ctHelpers123).
    • Added tests for both error and allowed cases.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files


// Throws if `__ctHelpers` was found as an Identifier
// in the source code.
function checkCTHelperVar(source: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, it's very cool that this is actually faster than the string check - i for sure would not have guessed that!

);
}
}
return ts.visitEachChild(node, visitor, undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

claude suggests that you could consider using ts.forEachChild(node, visitor) just to avoid having the potentially confusing undefined third parameter for the TransformationContext. i think it's probably good to have it this way because we use visitEachChild elsewhere and it keeps us consistent, but, just mentioning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think forEachChild works as well, changing the return value to ts.Node | undefined, though the iteration logic seems different, but looking more into it (tests pass with it however)

@jsantell jsantell merged commit e9d67a9 into main Oct 10, 2025
9 checks passed
@jsantell jsantell deleted the smarter-cthelpers-check branch October 10, 2025 22:02
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.

3 participants