1 import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '../ts-estree';
\r
2 import { ParserOptions } from './ParserOptions';
\r
3 import { RuleModule } from './Rule';
\r
4 interface ValidTestCase<TOptions extends Readonly<unknown[]>> {
\r
6 * Code for the test case.
\r
8 readonly code: string;
\r
10 * Environments for the test case.
\r
12 readonly env?: Readonly<Record<string, boolean>>;
\r
14 * The fake filename for the test case. Useful for rules that make assertion about filenames.
\r
16 readonly filename?: string;
\r
18 * The additional global variables.
\r
20 readonly globals?: Record<string, 'readonly' | 'writable' | 'off'>;
\r
22 * Options for the test case.
\r
24 readonly options?: Readonly<TOptions>;
\r
26 * The absolute path for the parser.
\r
28 readonly parser?: string;
\r
30 * Options for the parser.
\r
32 readonly parserOptions?: Readonly<ParserOptions>;
\r
34 * Settings for the test case.
\r
36 readonly settings?: Readonly<Record<string, unknown>>;
\r
38 interface SuggestionOutput<TMessageIds extends string> {
\r
40 * Reported message ID.
\r
42 readonly messageId: TMessageIds;
\r
44 * The data used to fill the message template.
\r
46 readonly data?: Readonly<Record<string, unknown>>;
\r
48 * NOTE: Suggestions will be applied as a stand-alone change, without triggering multi-pass fixes.
\r
49 * Each individual error has its own suggestion, so you have to show the correct, _isolated_ output for each suggestion.
\r
51 readonly output: string;
\r
53 interface InvalidTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>> extends ValidTestCase<TOptions> {
\r
57 readonly errors: TestCaseError<TMessageIds>[];
\r
59 * The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested.
\r
61 readonly output?: string | null;
\r
63 interface TestCaseError<TMessageIds extends string> {
\r
65 * The 1-based column number of the reported start location.
\r
67 readonly column?: number;
\r
69 * The data used to fill the message template.
\r
71 readonly data?: Readonly<Record<string, unknown>>;
\r
73 * The 1-based column number of the reported end location.
\r
75 readonly endColumn?: number;
\r
77 * The 1-based line number of the reported end location.
\r
79 readonly endLine?: number;
\r
81 * The 1-based line number of the reported start location.
\r
83 readonly line?: number;
\r
85 * Reported message ID.
\r
87 readonly messageId: TMessageIds;
\r
89 * Reported suggestions.
\r
91 readonly suggestions?: SuggestionOutput<TMessageIds>[] | null;
\r
93 * The type of the reported AST node.
\r
95 readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES;
\r
97 interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {
\r
98 readonly valid: (ValidTestCase<TOptions> | string)[];
\r
99 readonly invalid: InvalidTestCase<TMessageIds, TOptions>[];
\r
101 interface RuleTesterConfig {
\r
102 readonly parser: string;
\r
103 readonly parserOptions?: Readonly<ParserOptions>;
\r
105 declare class RuleTesterBase {
\r
107 * Creates a new instance of RuleTester.
\r
108 * @param testerConfig extra configuration for the tester
\r
110 constructor(testerConfig?: RuleTesterConfig);
\r
112 * Adds a new rule test to execute.
\r
113 * @param ruleName The name of the rule to run.
\r
114 * @param rule The rule to test.
\r
115 * @param test The collection of tests to run.
\r
117 run<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(ruleName: string, rule: RuleModule<TMessageIds, TOptions>, tests: RunTests<TMessageIds, TOptions>): void;
\r
119 * If you supply a value to this property, the rule tester will call this instead of using the version defined on
\r
120 * the global namespace.
\r
121 * @param text a string describing the rule
\r
122 * @param callback the test callback
\r
124 static describe?: (text: string, callback: () => void) => void;
\r
126 * If you supply a value to this property, the rule tester will call this instead of using the version defined on
\r
127 * the global namespace.
\r
128 * @param text a string describing the test case
\r
129 * @param callback the test callback
\r
131 static it?: (text: string, callback: () => void) => void;
\r
133 declare const RuleTester_base: typeof RuleTesterBase;
\r
134 declare class RuleTester extends RuleTester_base {
\r
136 export { InvalidTestCase, SuggestionOutput, RuleTester, RuleTesterConfig, RunTests, TestCaseError, ValidTestCase, };
\r
137 //# sourceMappingURL=RuleTester.d.ts.map
\r