Skip to content

⬅️ Back to Table of Contents

📄 no-unnecessary-condition.test.ts

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 7
📊 Variables & Constants 3

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts

📦 Imports

Name Source
InvalidTestCase @typescript-eslint/rule-tester
noFormat @typescript-eslint/rule-tester
RuleTester @typescript-eslint/rule-tester
MessageId ../../src/rules/no-unnecessary-condition
Options ../../src/rules/no-unnecessary-condition
rule ../../src/rules/no-unnecessary-condition
getFixturesRootDir ../RuleTester

Variables & Constants

Name Type Kind Value Exported
ruleTester any const `new RuleTester({
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: rootPath,
},
},
})`
optionsWithExactOptionalPropertyTypes { project: string; tsconfigRootDir: string; } const `{
project: './tsconfig.exactOptionalPropertyTypes.json',
tsconfigRootDir: rootPath,
}`
optionsWithNoUncheckedIndexedAccess { project: string; projectService: boolean; tsconfigRootDir: string; } const `{
project: './tsconfig.noUncheckedIndexedAccess.json',
projectService: false,
tsconfigRootDir: getFixturesRootDir(),
}`

Functions

necessaryConditionTest(condition: string): string

Code
(condition: string): string => `
declare const b1: ${condition};
declare const b2: boolean;
const t1 = b1 && b2;
`
  • Parameters:
  • condition: string
  • Return Type: string

unnecessaryConditionTest(condition: string, messageId: MessageId): InvalidTestCase<MessageId, Options>

Code
(
  condition: string,
  messageId: MessageId,
): InvalidTestCase<MessageId, Options> => ({
  code: necessaryConditionTest(condition),
  errors: [{ column: 12, line: 4, messageId }],
})
  • Parameters:
  • condition: string
  • messageId: MessageId
  • Return Type: InvalidTestCase<MessageId, Options>