Skip to content

Add Recurse ML rules for naming and code patterns #780

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

Merged
merged 2 commits into from
Jul 18, 2025

Conversation

ab-10
Copy link
Contributor

@ab-10 ab-10 commented Jul 18, 2025

This PR adds two custom Recurse ML rules to enforce naming and usage patterns

.github/recurseml-rules/naming.mdc:

  • Use snake_case for anything that goes over HTTP in REST APIs, camelCase for JavaScript elsewhere
  • captureError's first argument should be a machine-readable ID without whitespaces (e.g., 'user-sign-up-email' not 'Email failed to send')
  • When doing OAuth flows, specify the type (inner/outer/external) in variable names, comments, and error messages

.github/recurseml-rules/code_patterns.mdc:

  • Never use void asyncFunction() or asyncFunction().catch(console.error) - use runAsynchronously(asyncFunction) instead
  • Use parseJson/stringifyJson from stack-shared/utils/json instead of JSON.parse/JSON.stringify
  • Instead of Vercel waitUntil, use runAsynchronously(promise, { promiseCallback: waitUntil })
  • Don't concatenate URLs as strings - avoid patterns like /users/${userId}
  • Replace non-null assertions with ?? throwErr("message", { extraData }) pattern

Important

Add Recurse ML rules for naming conventions and code patterns in JavaScript/TypeScript.

  • Recurse ML Configuration:
    • Adds rules: .github/recurseml-rules/ to .github/.recurseml.yaml.
  • Naming Conventions (naming.mdc):
    • Use snake_case for REST API HTTP elements, camelCase for JavaScript.
    • captureError IDs must be machine-readable without spaces.
    • Specify OAuth flow types in variable names, comments, and error messages.
  • Code Patterns (code_patterns.mdc):
    • Use runAsynchronously instead of void asyncFunction() or .catch(console.error).
    • Use parseJson/stringifyJson from stack-shared/utils/json.
    • Use runAsynchronously with promiseCallback for Vercel waitUntil.
    • Avoid URL string concatenation; use utilities.
    • Replace non-null assertions with ?? throwErr pattern.

This description was created by Ellipsis for 9dd35ab. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jul 18, 2025

@ab-10 is attempting to deploy a commit to the Stack Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

recurseml bot commented Jul 18, 2025

✨ No files to analyze in this PR.

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR introduces Recurse ML rules configuration to enforce consistent coding patterns and naming conventions across the stack-auth codebase. The changes include:

  1. Configuration in .github/.recurseml.yaml to enable custom rules
  2. New naming conventions for HTTP APIs, error IDs, and OAuth flows in naming.mdc
  3. Code pattern enforcement rules in code_patterns.mdc covering async handling, JSON operations, and error handling

The rules aim to improve code quality, security, and maintainability by standardizing common patterns and preventing anti-patterns.

PR Description Notes:

  • There is a typo 'guideleines' in naming.mdc that should be fixed
  • The rules link in the PR description appears to be malformed (points to docs.recurse.ml/gh/configs/rules)

Confidence score: 4/5

  1. Safe to merge after addressing the typo and link issues
  2. The rules being added are well-thought-out and address important safety and consistency concerns
  3. Files needing attention:
    • .github/recurseml-rules/naming.mdc: Fix typo
    • PR description: Fix malformed link

3 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile

@N2D4
Copy link
Contributor

N2D4 commented Jul 18, 2025

Thanks for your contribution! 😎

@N2D4 N2D4 merged commit bdf8c0e into stack-auth:dev Jul 18, 2025
9 of 16 checks passed
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