@@ -2412,6 +2412,29 @@ function buildFixtureTree() {
24122412 "it('y', async () => boot({ dir: '.' }));\n" ,
24132413 } ) ;
24142414
2415+ // (26) THE `codeOnly` PROJECTION ITSELF, PINNED (#16299). A `}` sitting
2416+ // inside a template literal — content `maskCommentsAndLiterals` blanks and a
2417+ // scanner that merely strips comments does not. Read literally, that stray
2418+ // `}` closes the `it()` callback's REAL opening brace early, right there
2419+ // inside the template, before the dynamic `import()` two lines down — so an
2420+ // under-masked `codeOnly` reports zero function-body ranges reaching the
2421+ // import and the violation goes SILENT, the same failure mode fixture (25)
2422+ // pins for the brace scanner's backward walk. Correctly masked, the
2423+ // template's interior is blanked (delimiters survive, content does not), the
2424+ // callback's true closing brace is what pairs with its opener, and the
2425+ // import is reported CLOCKED like any other. This is the shape #16299 named:
2426+ // the module-scope-vs-CLOCKED verdict hinges on a brace living inside a
2427+ // string or template, which is the exact content `codeOnly` exists to erase.
2428+ fixture ( root , 'packages/clocked-literal-brace' , {
2429+ 'package.json' : ARTIFACT_MANIFEST ( '@fx/clocked-literal-brace' ) ,
2430+ 'src/thing.test.ts' :
2431+ "import { it } from 'vitest';\n" +
2432+ "it('y', async () => {\n" +
2433+ ' const label = `already closed }`;\n' +
2434+ " await import('@fx/core');\n" +
2435+ '});\n' ,
2436+ } ) ;
2437+
24152438 return root ;
24162439}
24172440
@@ -2443,7 +2466,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
24432466 'the canary (#8020)' : 14 ,
24442467 'the cross-boundary walk (#8351)' : 7 ,
24452468 'the latent half (#9674)' : 8 ,
2446- 'the clocked-window rule (#10126)' : 10 ,
2469+ 'the clocked-window rule (#10126)' : 12 ,
24472470 'the import clause is bounded to ONE statement (#12555)' : 11 ,
24482471 'the declared population must stay READABLE by the dispatch deriver' : 11 ,
24492472 'the declaration must still BE the workspace (#11510)' : 22 ,
@@ -2818,6 +2841,22 @@ function selfTest() {
28182841 'a helper whose multi-line signature ends `}): Promise< { … } > {` was read as not a function body — a SILENT exemption' ,
28192842 ) ;
28202843
2844+ // …and the `codeOnly` projection itself (#16299): a `}` sitting inside a
2845+ // template literal, positioned to close the real callback's brace EARLY if
2846+ // read as code rather than masked as content. Under-masking here does not
2847+ // fabricate a finding — it does the opposite, and silently: the dynamic
2848+ // import falls outside every reported range and never reaches `clocked` at
2849+ // all. `commentsOnly` (which still feeds the import regex) is unaffected —
2850+ // only `codeOnly`'s brace count decides this verdict.
2851+ expect (
2852+ clockedIn ( 'packages/clocked-literal-brace/src/thing.test.ts:4' ) . length === 1 ,
2853+ 'a `}` inside a template literal closed the real function body early — the dynamic import went unreported' ,
2854+ ) ;
2855+ expect (
2856+ clockedIn ( 'packages/clocked-literal-brace/src/thing.test.ts:4' ) . every ( ( f ) => f . includes ( "import('@fx/core')" ) ) ,
2857+ 'the clocked-window finding for the literal-brace fixture lost or renamed its specifier' ,
2858+ ) ;
2859+
28212860 // ── the import clause is bounded to ONE statement (#12555) ────────────
28222861 //
28232862 // All three rows of the card's table, pinned as a set comparison so the two
0 commit comments