diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts index 842e5b715a9..75cb093e2dc 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts @@ -54,6 +54,12 @@ const t1 = (b1 && b2) ? 'yes' : 'no'`, necessaryConditionTest('any'), // any necessaryConditionTest('unknown'), // unknown + // Generic type params + ` +function test(t: T) { + return t ? 'yes' : 'no' +}`, + // Supports ignoring the RHS { code: ` @@ -94,6 +100,15 @@ const t1 = (b1 && b2) ? 'yes' : 'no'`, unnecessaryConditionTest('void', 'alwaysFalsy'), unnecessaryConditionTest('never', 'never'), + // Generic type params + { + code: ` +function test(t: T) { + return t ? 'yes' : 'no' +}`, + errors: [ruleError(3, 10, 'alwaysTruthy')], + }, + // Still errors on in the expected locations when ignoring RHS { options: [{ ignoreRhs: true }],