import type { TSESLint } from '@typescript-eslint/utils'; /** * When leveraging the convertAnnotatedSourceToFailureCase() utility, the * following characters are eligible to be used in the source code of expected * failure cases within ESLint unit tests in order to provide an easy way to * annotate where one or more ESLint errors are expected to occur within that * source. * * See the convertAnnotatedSourceToFailureCase() utility itself for more details. */ export declare const SPECIAL_UNDERLINE_CHARS: readonly ["~", "^", "#", "%", "¶", "*", "¨", "@"]; declare type MultipleErrorOptions = BaseErrorOptions & { readonly messages: readonly (Message & { readonly char: typeof SPECIAL_UNDERLINE_CHARS[number]; })[]; }; declare type BaseErrorOptions = { readonly description: string; readonly annotatedSource: string; readonly options?: readonly unknown[]; readonly annotatedOutput?: string; readonly filename?: string; }; declare type Message = { readonly messageId: TMessageIds; readonly data?: Record; readonly suggestions?: TSESLint.SuggestionOutput[]; }; declare type SingleErrorOptions = BaseErrorOptions & Message; /** * convertAnnotatedSourceToFailureCase() provides an ergonomic way to easily write * expected failure cases for ESLint rules by allowing you to directly annotate the * source code for the case with one or more of the values in `SPECIAL_UNDERLINE_CHARS`. * * This not only makes the unit tests easier to write because of the time saved in figuring * out location data in terms of lines and columns, but also far easier to read, which is * arguably much more important. * * Here is a real-world example of using the utility: * * ```ts * convertAnnotatedSourceToFailureCase({ * description: 'should fail when Pipe has no prefix ng', * annotatedSource: ` * @Pipe({ * name: 'foo-bar' * ~~~~~~~~~ * }) * class Test {} * `, * messageId: 'pipePrefix, * options: [{ prefixes: ['ng'] }], * data: { prefixes: '"ng"' }, * }), * ``` * * NOTE: The description is purely for documentation purposes. It is not used in the test. */ export declare function convertAnnotatedSourceToFailureCase(errorOptions: SingleErrorOptions): TSESLint.InvalidTestCase; export declare function convertAnnotatedSourceToFailureCase(errorOptions: MultipleErrorOptions): TSESLint.InvalidTestCase; export {};