Skip to content

Conversation

camc314
Copy link
Contributor

@camc314 camc314 commented Sep 18, 2025

Add Rule Generator Tool

This PR adds a TypeScript-based rule generator tool to help create new type-aware ESLint rules for TSGolint. The tool:

  • Downloads test files from typescript-eslint repository
  • Parses test cases to extract valid/invalid examples
  • Generates Go rule implementation stubs and test files
  • Verifies that rules require type checking (since TSGolint focuses on type-aware rules)

The PR also:

  • Adds a new new-rule command to the justfile for easy rule generation
  • Adds TypeScript type checking for the rulegen tool in CI
  • Includes necessary dependencies and configuration files

Example usage: just new-rule await-thenable

part of #250

Copy link
Contributor Author

camc314 commented Sep 18, 2025


How to use the Graphite Merge Queue

Add the label 0-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camc314 camc314 force-pushed the c/09-18-feat_initialize_rule_generation_tool branch 5 times, most recently from 77e4b0e to 67cb6f4 Compare September 19, 2025 08:53
@camc314 camc314 force-pushed the c/09-18-feat_initialize_rule_generation_tool branch from 67cb6f4 to 4df3778 Compare September 19, 2025 08:54
@camc314 camc314 marked this pull request as ready for review September 19, 2025 08:54
@camc314 camc314 requested a review from Boshen September 19, 2025 08:55
return str.charAt(0).toUpperCase() + str.slice(1);
}

function extractOptionsFromAST(node: any): any {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be useful: I ported rule tests by patching @typescript-eslint/rule-tester. I never published this script because it's quite messy. AST-based conversion is unreliable, since some tests don't strictly follow the same AST shape. A better approach is to generate tests by introspecting the runtime values of the valid and invalid cases in JS RuleTester. A similar idea was used on the experimental-eslint-compat branch to convert ESLint core tests to Go: https://github.com/typescript-eslint/tsgolint/blob/009732a96109384fae40cc2cadc48c8f562b489b/tools/gen-eslint-core-rule-tests.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 didn't even realize that script exists.

@camc314 camc314 marked this pull request as draft September 19, 2025 08:59
@Boshen Boshen removed their assignment Oct 7, 2025
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