Skip to content

Commit

Permalink
test: remove old utils
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed Nov 20, 2024
1 parent 511bcfe commit 71e410b
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import type {
InvalidTestCase as TSESLintInvalidTestCase,
RunTests as TSESLintRunTests,
} from '@typescript-eslint/rule-tester'
import type { TSESTree } from '@typescript-eslint/utils'
import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'
import type { RuleTester } from 'eslint'
import semver from 'semver'
import typescriptPkg from 'typescript/package.json'

Expand Down Expand Up @@ -46,17 +44,7 @@ export function getNonDefaultParsers() {

export const TEST_FILENAME = testFilePath()

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- simplify testing
export type ValidTestCase = TSESLintValidTestCase<any> & {
errors?: readonly InvalidTestCaseError[] | number
parser?: never
parserOptions?: never
}

type InvalidTestCase = // eslint-disable-next-line @typescript-eslint/no-explicit-any -- simplify testing
TSESLintInvalidTestCase<any, any>

/** @warning DO NOT EXPORT THIS. use {@link createRuleTestCaseFunction} or {@link test} instead */
/** @warning DO NOT EXPORT THIS. Use {@link createRuleTestCaseFunctions} instead */
function createRuleTestCase<TTestCase extends TSESLintValidTestCase<unknown[]>>(
t: TTestCase,
): TTestCase {
Expand All @@ -74,23 +62,6 @@ function createRuleTestCase<TTestCase extends TSESLintValidTestCase<unknown[]>>(
}
}

export type InvalidTestCaseError =
| string
| InvalidTestCase['errors'][number]
| (RuleTester.TestCaseError & {
type?: `${TSESTree.AST_NODE_TYPES}`
})

/** @deprecated use {@link createRuleTestCaseFunctions} */
export function test<T extends ValidTestCase>(
t: T,
): T extends { errors: InvalidTestCaseError[] | number }
? InvalidTestCase
: ValidTestCase {
// @ts-expect-error simplify testing
return createRuleTestCase(t)
}

type GetRuleModuleTypes<TRule> =
TRule extends RuleModule<infer MessageIds, infer Options>
? {
Expand Down Expand Up @@ -258,6 +229,4 @@ export const SYNTAX_VALID_CASES: TSESLintRunTests<string, unknown[]>['valid'] =
}),
]

const testCompiled = process.env.TEST_COMPILED === '1'

export const srcDir = testCompiled ? 'lib' : 'src'
export const srcDir = process.env.TEST_COMPILED === '1' ? 'lib' : 'src'

0 comments on commit 71e410b

Please sign in to comment.