From fa377d75645865690602c1facc20c236cb12424b Mon Sep 17 00:00:00 2001 From: Yannick Maes Date: Fri, 13 Sep 2024 16:32:06 +0200 Subject: [PATCH] fix: add 'assertType' to 'expect-expect' allowed assertions (#534) --- src/rules/expect-expect.ts | 2 +- tests/expect-expect.test.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/rules/expect-expect.ts b/src/rules/expect-expect.ts index 7ad7891..2ab6949 100644 --- a/src/rules/expect-expect.ts +++ b/src/rules/expect-expect.ts @@ -65,7 +65,7 @@ export default createEslintRule({ 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) { diff --git a/tests/expect-expect.test.ts b/tests/expect-expect.test.ts index ca8b8d8..fe830e7 100644 --- a/tests/expect-expect.test.ts +++ b/tests/expect-expect.test.ts @@ -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 }>() }); `, @@ -198,6 +198,19 @@ const it = base.extend<{ } ] }, + { + code: ` + it("should fail 'assertType' without 'typecheck' enabled", () => { + assertType('a') + }); + `, + errors: [ + { + messageId: 'noAssertions', + type: AST_NODE_TYPES.Identifier + } + ] + }, { code: ` import { it } from 'vitest';