import type { AST_NODE_TYPES, AST_TOKEN_TYPES } from '../ts-estree'; import type { ClassicConfig } from './Config'; import type { Linter } from './Linter'; import type { ParserOptions } from './ParserOptions'; import type { ReportDescriptorMessageData, RuleCreateFunction, RuleModule, SharedConfigurationSettings } from './Rule'; interface ValidTestCase> { /** * Name for the test case. * @since 8.1.0 */ readonly name?: string; /** * Code for the test case. */ readonly code: string; /** * Environments for the test case. */ readonly env?: Readonly; /** * The fake filename for the test case. Useful for rules that make assertion about filenames. */ readonly filename?: string; /** * The additional global variables. */ readonly globals?: Readonly; /** * Options for the test case. */ readonly options?: Readonly; /** * The absolute path for the parser. */ readonly parser?: string; /** * Options for the parser. */ readonly parserOptions?: Readonly; /** * Settings for the test case. */ readonly settings?: Readonly; /** * Run this case exclusively for debugging in supported test frameworks. * @since 7.29.0 */ readonly only?: boolean; } interface SuggestionOutput { /** * Reported message ID. */ readonly messageId: TMessageIds; /** * The data used to fill the message template. */ readonly data?: ReportDescriptorMessageData; /** * NOTE: Suggestions will be applied as a stand-alone change, without triggering multi-pass fixes. * Each individual error has its own suggestion, so you have to show the correct, _isolated_ output for each suggestion. */ readonly output: string; } interface InvalidTestCase> extends ValidTestCase { /** * Expected errors. */ readonly errors: readonly TestCaseError[]; /** * The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested. */ readonly output?: string | null; } interface TestCaseError { /** * The 1-based column number of the reported start location. */ readonly column?: number; /** * The data used to fill the message template. */ readonly data?: ReportDescriptorMessageData; /** * The 1-based column number of the reported end location. */ readonly endColumn?: number; /** * The 1-based line number of the reported end location. */ readonly endLine?: number; /** * The 1-based line number of the reported start location. */ readonly line?: number; /** * Reported message ID. */ readonly messageId: TMessageIds; /** * Reported suggestions. */ readonly suggestions?: readonly SuggestionOutput[] | null; /** * The type of the reported AST node. */ readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES; } /** * @param text a string describing the rule * @param callback the test callback */ type RuleTesterTestFrameworkFunction = (text: string, callback: () => void) => void; interface RunTests> { readonly valid: readonly (ValidTestCase | string)[]; readonly invalid: readonly InvalidTestCase[]; } interface RuleTesterConfig extends ClassicConfig.Config { readonly parser: string; readonly parserOptions?: Readonly; } declare class RuleTesterBase { /** * Creates a new instance of RuleTester. * @param testerConfig extra configuration for the tester */ constructor(testerConfig?: RuleTesterConfig); /** * Adds a new rule test to execute. * @param ruleName The name of the rule to run. * @param rule The rule to test. * @param test The collection of tests to run. */ run>(ruleName: string, rule: RuleModule, tests: RunTests): void; /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. */ static get describe(): RuleTesterTestFrameworkFunction; static set describe(value: RuleTesterTestFrameworkFunction | undefined); /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. */ static get it(): RuleTesterTestFrameworkFunction; static set it(value: RuleTesterTestFrameworkFunction | undefined); /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. */ static get itOnly(): RuleTesterTestFrameworkFunction; static set itOnly(value: RuleTesterTestFrameworkFunction | undefined); /** * Define a rule for one particular run of tests. */ defineRule>(name: string, rule: RuleCreateFunction | RuleModule): void; } declare const RuleTester_base: typeof RuleTesterBase; declare class RuleTester extends RuleTester_base { } export { InvalidTestCase, SuggestionOutput, RuleTester, RuleTesterConfig, RuleTesterTestFrameworkFunction, RunTests, TestCaseError, ValidTestCase, }; //# sourceMappingURL=RuleTester.d.ts.map