UNPKG

2.23 kBTypeScriptView Raw
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7import type {Config} from '@jest/types';
8import type {Options} from 'yargs';
9
10export declare const createDidYouMeanMessage: (
11 unrecognized: string,
12 allowedOptions: Array<string>,
13) => string;
14
15declare type DeprecatedOptionFunc = (arg: Record<string, unknown>) => string;
16
17export declare type DeprecatedOptions = Record<string, DeprecatedOptionFunc>;
18
19export declare const format: (value: unknown) => string;
20
21export declare const logValidationWarning: (
22 name: string,
23 message: string,
24 comment?: string | null,
25) => void;
26
27export declare function multipleValidOptions<T extends Array<unknown>>(
28 ...args: T
29): T[number];
30
31declare type Title = {
32 deprecation?: string;
33 error?: string;
34 warning?: string;
35};
36
37export declare const validate: (
38 config: Record<string, unknown>,
39 options: ValidationOptions,
40) => {
41 hasDeprecationWarnings: boolean;
42 isValid: boolean;
43};
44
45export declare function validateCLIOptions(
46 argv: Config.Argv,
47 options?: Record<string, Options> & {
48 deprecationEntries?: DeprecatedOptions;
49 },
50 rawArgv?: Array<string>,
51): boolean;
52
53export declare class ValidationError extends Error {
54 name: string;
55 message: string;
56 constructor(name: string, message: string, comment?: string | null);
57}
58
59declare type ValidationOptions = {
60 comment?: string;
61 condition?: (option: unknown, validOption: unknown) => boolean;
62 deprecate?: (
63 config: Record<string, unknown>,
64 option: string,
65 deprecatedOptions: DeprecatedOptions,
66 options: ValidationOptions,
67 ) => boolean;
68 deprecatedConfig?: DeprecatedOptions;
69 error?: (
70 option: string,
71 received: unknown,
72 defaultValue: unknown,
73 options: ValidationOptions,
74 path?: Array<string>,
75 ) => void;
76 exampleConfig: Record<string, unknown>;
77 recursive?: boolean;
78 recursiveDenylist?: Array<string>;
79 title?: Title;
80 unknown?: (
81 config: Record<string, unknown>,
82 exampleConfig: Record<string, unknown>,
83 option: string,
84 options: ValidationOptions,
85 path?: Array<string>,
86 ) => void;
87};
88
89export {};