Skip to content

Commit b8c72ac

Browse files
committed
test(lint): pin the alias branch's fix-it, not only its rule id
The sibling non-canonical branch emits the same id at the same path; the canonical replacement in the hint is what the alias branch alone adds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8
1 parent fc9dcef commit b8c72ac

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

packages/lint/src/authoring-rule-input-tier.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,14 @@ describe('security-owd-alias reaches the rule only through the unparsed doors (#
407407
const rawStack = (sharingModel: string) => ({ manifest, objects: [owdObject(sharingModel)] });
408408
const aliasFindings = (findings: readonly { rule: string; path: string }[]) =>
409409
findings.filter((f) => f.rule === SECURITY_OWD_ALIAS).map((f) => f.path);
410-
/** Every key of the rule's `OWD_ALIAS_FIX` map. */
411-
const ALIASES = ['read', 'read_write', 'full', 'public'] as const;
410+
/** Every key of the rule's `OWD_ALIAS_FIX` map, with the canonical value its fix-it names. */
411+
const ALIAS_FIX = {
412+
read: 'public_read',
413+
read_write: 'public_read_write',
414+
full: 'public_read_write',
415+
public: 'public_read_write',
416+
} as const;
417+
const ALIASES = Object.keys(ALIAS_FIX) as (keyof typeof ALIAS_FIX)[];
412418

413419
it.each(ALIASES)('CONTROL — defineStack (strict default) refuses %s at load, before any rule runs', (alias) => {
414420
const { error } = quietly(() => defineStack(rawStack(alias) as never));
@@ -434,7 +440,13 @@ describe('security-owd-alias reaches the rule only through the unparsed doors (#
434440
}) as AnyRec;
435441
expect((normalized.objects as AnyRec[])[0].sharingModel).toBe(alias);
436442
expect(notices).toEqual([]);
437-
expect(aliasFindings(runAuthoringRules('lint', { normalized }))).toEqual(['objects[0].sharingModel']);
443+
const findings = runAuthoringRules('lint', { normalized }).filter((f) => f.rule === SECURITY_OWD_ALIAS);
444+
expect(findings.map((f) => f.path)).toEqual(['objects[0].sharingModel']);
445+
// The fix-it is what this door gets that the enum's `invalid_value` does not
446+
// — and it is the ALIAS branch's own contribution: the sibling
447+
// "not canonical" branch names the same rule id at the same path but no
448+
// replacement, so this line is what tells the two apart.
449+
expect(findings[0].hint).toContain(`sharingModel: '${ALIAS_FIX[alias]}'`);
438450
});
439451

440452
it('INTAKE — defineStack(x, { strict: false }) skips the parse, so the alias reaches os lint too', () => {

0 commit comments

Comments
 (0)