Skip to content

Commit

Permalink
Fix ruling for S131
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiez authored and kebetsi committed Jan 13, 2025
1 parent d734c96 commit f2b1514
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/jsts/src/rules/S131/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ export const rule: Rule.RuleModule = {
...decoratedSwitchExhaustivenessRule.meta?.messages,
},
schema: switchExhaustivenessRule.meta!.schema,
defaultOptions: [
{
considerDefaultExhaustiveForUnions: true,
},
],
}),
create(context: Rule.RuleContext) {
return mergeRules(
Expand Down
12 changes: 12 additions & 0 deletions packages/jsts/src/rules/S131/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ describe('S131', () => {
case 'bar':
break;
}
`,
},
{
code: `
type T = 'foo' | 'bar';
const x = 'foo' as T;
switch (x) {
case 'foo':
break;
default:
break;
}
`,
},
{
Expand Down

0 comments on commit f2b1514

Please sign in to comment.