Lint rule B7 judges a test by its file name, so the build renames tests to please it #278

Closed
opened 2026-10-28 14:07:29 -04:00 by cmoriarty · 2 comments
Owner

What happens

Lint rule B7 ("the test file imports the module under test") guesses the module from the test file's name. In run 133 the build wrote test/pixel-font.test.js, importing ../helloworld.js, and B7 flagged it. The agent renamed the file twice (helloworld-font, then helloworld.digits), still flagged, then folded the tests into test/helloworld.test.js. That cost 2 turns, and the tests now live in a file chosen to please the lint. B7 doesn't block a step, but the apply brief says to fix what ban-check reports.

Fix

B7 accepts a test that imports any of the repository's own source modules (a relative import of a non-test file), not just one named like the test. Or the brief names the blocking rules (B1, B2, B6) and calls the rest advice.

Done when

A test named for its feature that imports the real module passes ban-check with no B7 finding.

**What happens** Lint rule B7 ("the test file imports the module under test") guesses the module from the test file's *name*. In run 133 the build wrote `test/pixel-font.test.js`, importing `../helloworld.js`, and B7 flagged it. The agent renamed the file twice (`helloworld-font`, then `helloworld.digits`), still flagged, then folded the tests into `test/helloworld.test.js`. That cost 2 turns, and the tests now live in a file chosen to please the lint. B7 doesn't block a step, but the apply brief says to fix what `ban-check` reports. **Fix** B7 accepts a test that imports any of the repository's own source modules (a relative import of a non-test file), not just one named like the test. Or the brief names the blocking rules (B1, B2, B6) and calls the rest advice. **Done when** A test named for its feature that imports the real module passes `ban-check` with no B7 finding.
Author
Owner

Not done yet: B7 doesn't see a dynamic import. The fix in PR #284 (B7 asks for some of the project's own code) is live, and run 136's apply acted on no B7 finding. But its agent.write-spec-tests spent minutes on one: "B7 wants a static relative import; my await import() isn't seen. I'll move the DOM stub into a helper module imported statically."

_IMPORT_RE matches import(...) only at the start of a line, so const app = await import('../app.js') counts as no import. The agent's restructure would still be flagged under the new rule, since its only seen import would be a helper.

Fix: read import('…') anywhere on a line (and await import). Done when a test whose only import of the code is const app = await import('../app.js') has no B7 finding.

**Not done yet: B7 doesn't see a dynamic import.** The fix in PR #284 (B7 asks for some of the project's own code) is live, and run 136's apply acted on no B7 finding. But its `agent.write-spec-tests` spent minutes on one: "B7 wants a static relative import; my `await import()` isn't seen. I'll move the DOM stub into a helper module imported statically." `_IMPORT_RE` matches `import(...)` only at the start of a line, so `const app = await import('../app.js')` counts as no import. The agent's restructure would still be flagged under the new rule, since its only *seen* import would be a helper. Fix: read `import('…')` anywhere on a line (and `await import`). Done when a test whose only import of the code is `const app = await import('../app.js')` has no B7 finding.
Author
Owner

Closing in favour of #294: B7 is removed rather than fixed. It misfired in runs 133, 134 and 136 and only ever advised.

Closing in favour of #294: B7 is removed rather than fixed. It misfired in runs 133, 134 and 136 and only ever advised.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#278
No description provided.