Skip to content

Move the custom rule stub into a template file, and test that it loads in Oxlint - #542

Merged
adelrodriguez merged 1 commit into
mainfrom
rules/stub-template
Oct 20, 2026
Merged

adelrodriguez merged 1 commit into
mainfrom
rules/stub-template

Conversation

@adelrodriguez

@adelrodriguez adelrodriguez commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Stack

  1. Stop writing the rules folder AGENTS.md, and point to the skill for authoring guidance #541 Stop writing the rules folder AGENTS.md, and point to the skill for authoring guidance
  2. Move the custom rule stub into a template file, and test that it loads in Oxlint #542 Move the custom rule stub into a template file, and test that it loads in Oxlint ← this PR

The rule stub that adamantite rule add writes was a template literal in toCustomRuleStub. Its backticks were escaped, and it was hard to read as the file that the user gets. Now the stub lives in src/lib/workspace/custom-rules/stub.ts.template, and a build-time macro inlines it into the bundle, as the Doctor repair prompt does (#538). toCustomRuleStub fills the one slot, {{name}}.

src/lib/workspace/custom-rules/
  stub.ts.template   the stub, with a {{name}} slot
  stub.macro.ts      inlines the template at build time
  index.ts           toCustomRuleStub fills {{name}}

The template is not a .ts file, so the type check and the lint do not read it. Its adamantite/rules import resolves to the dist types, so a .ts template would fail the type check on a clean checkout. To make up for this, a new test in src/__tests__/presets/custom.test.ts loads the real stub in an Oxlint run and asserts that it reports. Before this PR, only a test that compared toCustomRuleStub with itself covered the stub.

Evidence

  • The built CLI's adamantite rule add no-window writes a file that is byte-identical to the stub from main (cmp). The skill's sources list now includes the template.
  • New test "load and run the stub that rule add writes" passes: Oxlint reports project(no-debugger-here):error.
  • On the stack: pnpm run test (620 tests), fix, format, check, analyze, and build pass. dist/index.js contains the template text.

No changeset: the stub does not change.

Merge danger

  • Door: two-way.
  • Blast radius: small. Only the rule add stub. A broken template fails the new Oxlint test.

Made with Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code


Note

Low Risk
Scoped to the rule add stub path and build-time inlining; behavior is intended to stay byte-identical, with a new Oxlint test as the guardrail.

Overview
Moves the adamantite rule add stub out of an inline template literal in toCustomRuleStub into stub.ts.template, with {{name}} as the only substitution slot. A build-time macro (stub.macro.ts) inlines that file into the bundle so the CLI does not read the template from disk at runtime—same approach as Doctor repair prompts.

toCustomRuleStub now does stubTemplate.replaceAll("{{name}}", name). The Adamantite skill sources list includes the new template.

Adds an integration test that writes the real stub (via toCustomRuleStub) into .adamantite/rules and asserts Oxlint reports project(no-debugger-here):error, so the generated file is exercised end-to-end instead of only being compared to itself.

Reviewed by Cursor Bugbot for commit b55cb0d. Configure here.

@adelrodriguez
adelrodriguez changed the base branch from main to rules/remove-agents-md October 20, 2026 23:15

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No new issues found.

Reviewed changes Reviewed the custom rule template, its build-time macro, and the new Oxlint test.

  • Stub template: The rule moves from a template literal to a separate file. The macro embeds it during the build, and toCustomRuleStub fills the rule name without changing the generated content.
  • Oxlint test: The new test loads the generated stub through custom() and checks that it reports a debugger statement.
  • Verification: pnpm run test passed with 602 tests passed and one Bun test skipped. pnpm run build:verify, pnpm run check, and pnpm run analyze passed. The built CLI also wrote the expected rule with the supplied name.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@adelrodriguez
adelrodriguez added this pull request to stack #537 October 20, 2026 23:21
Base automatically changed from rules/remove-agents-md to main October 20, 2026 23:48
The stub that `adamantite rule add` writes lives in
custom-rules/stub.ts.template, and a build-time macro inlines it into the
bundle, as the Doctor repair prompt does. The template is not a `.ts` file,
because its `adamantite/rules` import resolves only after a build. A new
Oxlint test loads and runs the stub, so a broken stub fails the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adelrodriguez

Copy link
Copy Markdown
Owner Author

@codex review

@adelrodriguez

Copy link
Copy Markdown
Owner Author

@cursor review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T23:51:43.310697Z b55cb0d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b55cb0d. Configure here.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: b55cb0d9fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@adelrodriguez
adelrodriguez merged commit d484a4b into main Oct 20, 2026
13 checks passed
@adelrodriguez
adelrodriguez deleted the rules/stub-template branch October 20, 2026 23:52
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.

1 participant