Skip to content

Commit 2d3b20f

Browse files
committed
test(spec): mask comments through the shared js-comment-mask module in the absence walk
Claude-Session: https://claude.ai/code/session_01WGufzgjTaf6BB6T3vxdisU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6c320a3 commit 2d3b20f

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

‎packages/spec/src/system/auth-revoke-sessions-on-password-reset-retirement.test.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { fileURLToPath } from 'node:url';
3131

3232
import { describe, expect, it } from 'vitest';
3333

34+
import { maskComments } from '../../../../scripts/js-comment-mask.mjs';
35+
3436
import { ALL_CONVERSIONS } from '../conversions/registry';
3537
import { MIGRATIONS_BY_MAJOR, RETIRED_KEYS_BY_MAJOR } from '../migrations/registry';
3638
import {
@@ -144,7 +146,7 @@ describe('revokeSessionsOnPasswordReset retirement — ADR-0087 registration', (
144146
// The key name is unique to this setting (better-auth's option of the same
145147
// name aside — see the exclusions), so the matcher is the key in KEY POSITION
146148
// (`revokeSessionsOnPasswordReset:` or its quoted JSON form), with comment
147-
// contents masked in code; the tombstone declaration itself
149+
// contents masked in code (`scripts/js-comment-mask.mjs`); the tombstone declaration itself
148150
// (`: retiredKey(`) is never an offence. Excluded, each for its reason:
149151
// - this file, which writes the key to prove the refusal;
150152
// - plugin-auth's `password-reset-ends-sessions.test.ts`, which writes it as
@@ -180,12 +182,6 @@ describe('tree-scoped absence: nothing inside the declared radius still writes e
180182

181183
const IN_KEY_POSITION = /(^|[\s{,(])["']?revokeSessionsOnPasswordReset["']?\s*:(?!\s*retiredKey\()/g;
182184

183-
/** Code with `//` and block-comment CONTENTS blanked, offsets kept. */
184-
const maskComments = (src: string): string =>
185-
src
186-
.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' '))
187-
.replace(/(^|[^:'"`\\])\/\/[^\n]*/g, (m, lead: string) => lead + ' '.repeat(m.length - lead.length));
188-
189185
const walk = (dir: string, out: string[]) => {
190186
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
191187
if (ent.isDirectory()) {

0 commit comments

Comments
 (0)