Skip to content

Commit

Permalink
test(eslint-plugin): add tests for generic type params
Browse files Browse the repository at this point in the history
  • Loading branch information
Retsam committed Sep 4, 2019
1 parent 0719da8 commit 9cbe4d8
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -54,6 +54,12 @@ const t1 = (b1 && b2) ? 'yes' : 'no'`,
necessaryConditionTest('any'), // any
necessaryConditionTest('unknown'), // unknown

// Generic type params
`
function test<T extends string>(t: T) {
return t ? 'yes' : 'no'
}`,

// Supports ignoring the RHS
{
code: `
Expand Down Expand Up @@ -94,6 +100,15 @@ const t1 = (b1 && b2) ? 'yes' : 'no'`,
unnecessaryConditionTest('void', 'alwaysFalsy'),
unnecessaryConditionTest('never', 'never'),

// Generic type params
{
code: `
function test<T extends object>(t: T) {
return t ? 'yes' : 'no'
}`,
errors: [ruleError(3, 10, 'alwaysTruthy')],
},

// Still errors on in the expected locations when ignoring RHS
{
options: [{ ignoreRhs: true }],
Expand Down

0 comments on commit 9cbe4d8

Please sign in to comment.