Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 3.48 KB

AGENTS.md

File metadata and controls

65 lines (52 loc) · 3.48 KB

AGENTS.md

Generated Code

  • After changing AST declarations or their generators, regenerate the Rust AST APIs and JavaScript types/codecs with ast_tools, and review the generated diff. Edit the declarations or generators rather than generated files.
  • After adding, removing, or renaming a helper in packages/helpers/esm, manually run pnpm build:helpers to regenerate the ESM entry stub and review the generated diff. The stub must explicitly export each helper by name; do not use export * or edit generated files directly.

Testing

Adding Rust Unit Tests

  • Add tests to the existing module; group related cases by broad feature and use a coarse feature name for the test function.
  • Keep each input small; do not combine independently testable JavaScript/TypeScript statements.
  • Move repeated setup and parsing boilerplate into local helper functions so the test body only shows the input, result, and assertions.
  • Reuse named options, contexts, and language configurations across related cases.
  • Keep independent input cases and their assertions explicit rather than in a cases table. Loops are appropriate for running the same cases across configurations; reuse named options to keep the matrix clear.
  • Keep each input and result acquisition on one source line, separate cases with a blank line, and encode input line breaks as \n.
  • Assert observable behavior and structure; avoid exact diagnostic messages and verbose custom failure output unless the text itself is part of the contract.
  • Do not add unit tests for behavior already covered by conformance tests or for highly specific cases.

Adding JavaScript Unit Tests

  • Test only JS API and FFI boundaries (encoding/decoding, strings/offsets, option forwarding). Keep parser/codegen correctness tests in Rust.
  • JavaScript API tests belong to @swc-next/core, except formatter tests The browser package should only have a simple smoke test.

README Writing

  • Follow the root README: briefly describe purpose, capabilities, basic usage, essential limitations, and crate testing where relevant.
  • Write necessary document API, options, and attributes in Rust doc rather than README.
  • Document commands in the relevant component README
  • Omit development history, step-by-step contributor workflows, implementation walkthroughs, and exhaustive command lists.

Issues

  • File issues found in bulk by static analysis of source code, or by similar methods, in swc-project/swc-next-issues. Do not file them in this repository.
  • Set the Priority and Effort GitHub issue fields on each issue in swc-next-issues. Do not use labels for them. Set them with the setIssueFieldValue GraphQL mutation; get the field and option IDs from the issueFields of the swc-project organization.
  • Choose Priority by how much the bug is likely to affect real users:
    • Urgent: common code crashes, is rejected, or produces output with broken runtime behavior.
    • High: incorrect output or diagnostics for code that users commonly write.
    • Medium: incorrect behavior for less common but realistic code.
    • Low: rare or contrived input, or a problem that users are unlikely to notice.
  • Choose Effort by the estimated size of the fix: Low for a local change, Medium for a change across several functions or modules, and High for a design change or a large rewrite.

Code Review

For code reviews, use the code-review skill.