Skip to content

Commit

Permalink
fix: add 'assertType' to 'expect-expect' allowed assertions (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickm95 authored Sep 13, 2024
1 parent 016b071 commit fa377d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
const unchecked: TSESTree.CallExpression[] = []
const settings = parsePluginSettings(context.settings)

if (settings.typecheck) assertFunctionNames.push('expectTypeOf')
if (settings.typecheck) assertFunctionNames.push('expectTypeOf', 'assertType')

function checkCallExpression(nodes: TSESTree.Node[]) {
for (const node of nodes) {
Expand Down
15 changes: 14 additions & 1 deletion tests/expect-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const it = base.extend<{
},
{
code: `
it("should fail without 'typecheck' enabled", () => {
it("should fail 'expectTypeOf' without 'typecheck' enabled", () => {
expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>()
});
`,
Expand All @@ -198,6 +198,19 @@ const it = base.extend<{
}
]
},
{
code: `
it("should fail 'assertType' without 'typecheck' enabled", () => {
assertType<string>('a')
});
`,
errors: [
{
messageId: 'noAssertions',
type: AST_NODE_TYPES.Identifier
}
]
},
{
code: `
import { it } from 'vitest';
Expand Down

0 comments on commit fa377d7

Please sign in to comment.