@eslint-react/shared 1.37.4-beta.0 → 1.38.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,4 @@
1
1
  import { _ } from '@eslint-react/eff';
2
- import * as tseslint from '@typescript-eslint/utils/ts-eslint';
3
- import { ReportDescriptor } from '@typescript-eslint/utils/ts-eslint';
4
- import { ESLintUtils } from '@typescript-eslint/utils';
5
2
 
6
3
  /**
7
4
  * The NPM scope for this project.
@@ -15,83 +12,14 @@ declare const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
15
12
  * The URL to the project's website.
16
13
  */
17
14
  declare const WEBSITE_URL = "https://eslint-react.xyz";
18
- /**
19
- * Regular expression for matching a PascalCase string.
20
- */
21
- declare const RE_PASCAL_CASE: RegExp;
22
- /**
23
- * Regular expression for matching a camelCase string.
24
- */
25
- declare const RE_CAMEL_CASE: RegExp;
26
- /**
27
- * Regular expression for matching a kebab-case string.
28
- */
29
- declare const RE_KEBAB_CASE: RegExp;
30
- /**
31
- * Regular expression for matching a snake_case string.
32
- */
33
- declare const RE_SNAKE_CASE: RegExp;
34
- /**
35
- * Regular expression for matching a CONSTANT_CASE string.
36
- */
37
- declare const RE_CONSTANT_CASE: RegExp;
38
- declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
39
- declare const REACT_BUILD_IN_HOOKS: readonly ["use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useFormStatus", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
40
-
41
- /**
42
- * Rule severity.
43
- * @since 0.0.1
44
- */
45
- type RuleSeverity = "error" | "off" | "warn";
46
- /**
47
- * Rule declaration.
48
- * @internal
49
- * @since 0.0.1
50
- */
51
- type RuleDeclaration = [RuleSeverity, Record<string, unknown>?] | RuleSeverity;
52
- /**
53
- * Rule config preset.
54
- * @since 0.0.1
55
- */
56
- type RulePreset = Record<string, RuleDeclaration>;
57
- /**
58
- * Rule context.
59
- * @since 0.0.1
60
- */
61
- type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
62
- /**
63
- * Rule namespace.
64
- * @since 0.0.1
65
- */
66
- type RuleNamespace = "x" | "dom" | "web-api" | "hooks-extra" | "naming-convention" | "debug";
67
- /**
68
- * Rule feature.
69
- * @since 1.20.0
70
- */
71
- type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC";
72
- /**
73
- * Rule status.
74
- * @since 1.36.0
75
- */
76
- type RuleStatus = "stable" | "experimental" | "deprecated" | "removed";
77
15
 
78
16
  /**
79
- * Creates a report function that can conditionally report a descriptor.
80
- * @param context - The context of the rule
81
- * @returns A function that takes a descriptor and reports it if it's not null or undefined
82
- */
83
- declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
84
-
85
- /**
86
- * Get the ESLint rule creator for a plugin.
17
+ * Get the URL for the documentation of a rule in a plugin.
87
18
  * @internal
88
19
  * @param pluginName The name of the plugin.
89
- * @returns The ESLint rule creator.
20
+ * @returns The URL for the documentation of a rule.
90
21
  */
91
- declare const createRuleForPlugin: (pluginName: string) => <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
92
-
93
- declare function isInEditorEnv(): boolean;
94
- declare function isInGitHooksOrLintStaged(): boolean;
22
+ declare const getDocsUrl: (pluginName: string) => (ruleName: string) => string;
95
23
 
96
24
  declare const getId: () => string;
97
25
 
@@ -2166,11 +2094,520 @@ declare global {
2166
2094
  }
2167
2095
  }
2168
2096
 
2097
+ /**
2098
+ Extract all required keys from the given type.
2099
+
2100
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
2101
+
2102
+ @example
2103
+ ```
2104
+ import type {RequiredKeysOf} from 'type-fest';
2105
+
2106
+ declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
2107
+
2108
+ interface User {
2109
+ name: string;
2110
+ surname: string;
2111
+
2112
+ luckyNumber?: number;
2113
+ }
2114
+
2115
+ const validator1 = createValidation<User>('name', value => value.length < 25);
2116
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
2117
+ ```
2118
+
2119
+ @category Utilities
2120
+ */
2121
+ type RequiredKeysOf<BaseType extends object> = Exclude<{
2122
+ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
2123
+ ? Key
2124
+ : never
2125
+ }[keyof BaseType], undefined>;
2126
+
2127
+ /**
2128
+ Returns a boolean for whether the given type is `never`.
2129
+
2130
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
2131
+ @link https://stackoverflow.com/a/53984913/10292952
2132
+ @link https://www.zhenghao.io/posts/ts-never
2133
+
2134
+ Useful in type utilities, such as checking if something does not occur.
2135
+
2136
+ @example
2137
+ ```
2138
+ import type {IsNever, And} from 'type-fest';
2139
+
2140
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
2141
+ type AreStringsEqual<A extends string, B extends string> =
2142
+ And<
2143
+ IsNever<Exclude<A, B>> extends true ? true : false,
2144
+ IsNever<Exclude<B, A>> extends true ? true : false
2145
+ >;
2146
+
2147
+ type EndIfEqual<I extends string, O extends string> =
2148
+ AreStringsEqual<I, O> extends true
2149
+ ? never
2150
+ : void;
2151
+
2152
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
2153
+ if (input === output) {
2154
+ process.exit(0);
2155
+ }
2156
+ }
2157
+
2158
+ endIfEqual('abc', 'abc');
2159
+ //=> never
2160
+
2161
+ endIfEqual('abc', '123');
2162
+ //=> void
2163
+ ```
2164
+
2165
+ @category Type Guard
2166
+ @category Utilities
2167
+ */
2168
+ type IsNever<T> = [T] extends [never] ? true : false;
2169
+
2170
+ /**
2171
+ An if-else-like type that resolves depending on whether the given type is `never`.
2172
+
2173
+ @see {@link IsNever}
2174
+
2175
+ @example
2176
+ ```
2177
+ import type {IfNever} from 'type-fest';
2178
+
2179
+ type ShouldBeTrue = IfNever<never>;
2180
+ //=> true
2181
+
2182
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
2183
+ //=> 'bar'
2184
+ ```
2185
+
2186
+ @category Type Guard
2187
+ @category Utilities
2188
+ */
2189
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
2190
+ IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
2191
+ );
2192
+
2193
+ // Can eventually be replaced with the built-in once this library supports
2194
+ // TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
2195
+ type NoInfer<T> = T extends infer U ? U : never;
2196
+
2197
+ /**
2198
+ Returns a boolean for whether the given type is `any`.
2199
+
2200
+ @link https://stackoverflow.com/a/49928360/1490091
2201
+
2202
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
2203
+
2204
+ @example
2205
+ ```
2206
+ import type {IsAny} from 'type-fest';
2207
+
2208
+ const typedObject = {a: 1, b: 2} as const;
2209
+ const anyObject: any = {a: 1, b: 2};
2210
+
2211
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
2212
+ return obj[key];
2213
+ }
2214
+
2215
+ const typedA = get(typedObject, 'a');
2216
+ //=> 1
2217
+
2218
+ const anyA = get(anyObject, 'a');
2219
+ //=> any
2220
+ ```
2221
+
2222
+ @category Type Guard
2223
+ @category Utilities
2224
+ */
2225
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
2226
+
2227
+ /**
2228
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
2229
+
2230
+ @example
2231
+ ```
2232
+ import type {Simplify} from 'type-fest';
2233
+
2234
+ type PositionProps = {
2235
+ top: number;
2236
+ left: number;
2237
+ };
2238
+
2239
+ type SizeProps = {
2240
+ width: number;
2241
+ height: number;
2242
+ };
2243
+
2244
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
2245
+ type Props = Simplify<PositionProps & SizeProps>;
2246
+ ```
2247
+
2248
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
2249
+
2250
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
2251
+
2252
+ @example
2253
+ ```
2254
+ import type {Simplify} from 'type-fest';
2255
+
2256
+ interface SomeInterface {
2257
+ foo: number;
2258
+ bar?: string;
2259
+ baz: number | undefined;
2260
+ }
2261
+
2262
+ type SomeType = {
2263
+ foo: number;
2264
+ bar?: string;
2265
+ baz: number | undefined;
2266
+ };
2267
+
2268
+ const literal = {foo: 123, bar: 'hello', baz: 456};
2269
+ const someType: SomeType = literal;
2270
+ const someInterface: SomeInterface = literal;
2271
+
2272
+ function fn(object: Record<string, unknown>): void {}
2273
+
2274
+ fn(literal); // Good: literal object type is sealed
2275
+ fn(someType); // Good: type is sealed
2276
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
2277
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
2278
+ ```
2279
+
2280
+ @link https://github.com/microsoft/TypeScript/issues/15300
2281
+ @see SimplifyDeep
2282
+ @category Object
2283
+ */
2284
+ type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
2285
+
2286
+ /**
2287
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
2288
+
2289
+ This is the counterpart of `PickIndexSignature`.
2290
+
2291
+ Use-cases:
2292
+ - Remove overly permissive signatures from third-party types.
2293
+
2294
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
2295
+
2296
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
2297
+
2298
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
2299
+
2300
+ ```
2301
+ const indexed: Record<string, unknown> = {}; // Allowed
2302
+
2303
+ const keyed: Record<'foo', unknown> = {}; // Error
2304
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
2305
+ ```
2306
+
2307
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
2308
+
2309
+ ```
2310
+ type Indexed = {} extends Record<string, unknown>
2311
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
2312
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
2313
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
2314
+
2315
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
2316
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
2317
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
2318
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
2319
+ ```
2320
+
2321
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
2322
+
2323
+ ```
2324
+ import type {OmitIndexSignature} from 'type-fest';
2325
+
2326
+ type OmitIndexSignature<ObjectType> = {
2327
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
2328
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
2329
+ };
2330
+ ```
2331
+
2332
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
2333
+
2334
+ ```
2335
+ import type {OmitIndexSignature} from 'type-fest';
2336
+
2337
+ type OmitIndexSignature<ObjectType> = {
2338
+ [KeyType in keyof ObjectType
2339
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
2340
+ as {} extends Record<KeyType, unknown>
2341
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
2342
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
2343
+ ]: ObjectType[KeyType];
2344
+ };
2345
+ ```
2346
+
2347
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
2348
+
2349
+ @example
2350
+ ```
2351
+ import type {OmitIndexSignature} from 'type-fest';
2352
+
2353
+ interface Example {
2354
+ // These index signatures will be removed.
2355
+ [x: string]: any
2356
+ [x: number]: any
2357
+ [x: symbol]: any
2358
+ [x: `head-${string}`]: string
2359
+ [x: `${string}-tail`]: string
2360
+ [x: `head-${string}-tail`]: string
2361
+ [x: `${bigint}`]: string
2362
+ [x: `embedded-${number}`]: string
2363
+
2364
+ // These explicitly defined keys will remain.
2365
+ foo: 'bar';
2366
+ qux?: 'baz';
2367
+ }
2368
+
2369
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
2370
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
2371
+ ```
2372
+
2373
+ @see PickIndexSignature
2374
+ @category Object
2375
+ */
2376
+ type OmitIndexSignature<ObjectType> = {
2377
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
2378
+ ? never
2379
+ : KeyType]: ObjectType[KeyType];
2380
+ };
2381
+
2382
+ /**
2383
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
2384
+
2385
+ This is the counterpart of `OmitIndexSignature`.
2386
+
2387
+ @example
2388
+ ```
2389
+ import type {PickIndexSignature} from 'type-fest';
2390
+
2391
+ declare const symbolKey: unique symbol;
2392
+
2393
+ type Example = {
2394
+ // These index signatures will remain.
2395
+ [x: string]: unknown;
2396
+ [x: number]: unknown;
2397
+ [x: symbol]: unknown;
2398
+ [x: `head-${string}`]: string;
2399
+ [x: `${string}-tail`]: string;
2400
+ [x: `head-${string}-tail`]: string;
2401
+ [x: `${bigint}`]: string;
2402
+ [x: `embedded-${number}`]: string;
2403
+
2404
+ // These explicitly defined keys will be removed.
2405
+ ['kebab-case-key']: string;
2406
+ [symbolKey]: string;
2407
+ foo: 'bar';
2408
+ qux?: 'baz';
2409
+ };
2410
+
2411
+ type ExampleIndexSignature = PickIndexSignature<Example>;
2412
+ // {
2413
+ // [x: string]: unknown;
2414
+ // [x: number]: unknown;
2415
+ // [x: symbol]: unknown;
2416
+ // [x: `head-${string}`]: string;
2417
+ // [x: `${string}-tail`]: string;
2418
+ // [x: `head-${string}-tail`]: string;
2419
+ // [x: `${bigint}`]: string;
2420
+ // [x: `embedded-${number}`]: string;
2421
+ // }
2422
+ ```
2423
+
2424
+ @see OmitIndexSignature
2425
+ @category Object
2426
+ */
2427
+ type PickIndexSignature<ObjectType> = {
2428
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
2429
+ ? KeyType
2430
+ : never]: ObjectType[KeyType];
2431
+ };
2432
+
2433
+ // Merges two objects without worrying about index signatures.
2434
+ type SimpleMerge<Destination, Source> = {
2435
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
2436
+ } & Source;
2437
+
2438
+ /**
2439
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
2440
+
2441
+ @example
2442
+ ```
2443
+ import type {Merge} from 'type-fest';
2444
+
2445
+ interface Foo {
2446
+ [x: string]: unknown;
2447
+ [x: number]: unknown;
2448
+ foo: string;
2449
+ bar: symbol;
2450
+ }
2451
+
2452
+ type Bar = {
2453
+ [x: number]: number;
2454
+ [x: symbol]: unknown;
2455
+ bar: Date;
2456
+ baz: boolean;
2457
+ };
2458
+
2459
+ export type FooBar = Merge<Foo, Bar>;
2460
+ // => {
2461
+ // [x: string]: unknown;
2462
+ // [x: number]: number;
2463
+ // [x: symbol]: unknown;
2464
+ // foo: string;
2465
+ // bar: Date;
2466
+ // baz: boolean;
2467
+ // }
2468
+ ```
2469
+
2470
+ @category Object
2471
+ */
2472
+ type Merge<Destination, Source> =
2473
+ Simplify<
2474
+ SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
2475
+ & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
2476
+ >;
2477
+
2478
+ /**
2479
+ An if-else-like type that resolves depending on whether the given type is `any`.
2480
+
2481
+ @see {@link IsAny}
2482
+
2483
+ @example
2484
+ ```
2485
+ import type {IfAny} from 'type-fest';
2486
+
2487
+ type ShouldBeTrue = IfAny<any>;
2488
+ //=> true
2489
+
2490
+ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
2491
+ //=> 'bar'
2492
+ ```
2493
+
2494
+ @category Type Guard
2495
+ @category Utilities
2496
+ */
2497
+ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
2498
+ IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
2499
+ );
2500
+
2501
+ /**
2502
+ Extract all optional keys from the given type.
2503
+
2504
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
2505
+
2506
+ @example
2507
+ ```
2508
+ import type {OptionalKeysOf, Except} from 'type-fest';
2509
+
2510
+ interface User {
2511
+ name: string;
2512
+ surname: string;
2513
+
2514
+ luckyNumber?: number;
2515
+ }
2516
+
2517
+ const REMOVE_FIELD = Symbol('remove field symbol');
2518
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
2519
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
2520
+ };
2521
+
2522
+ const update1: UpdateOperation<User> = {
2523
+ name: 'Alice'
2524
+ };
2525
+
2526
+ const update2: UpdateOperation<User> = {
2527
+ name: 'Bob',
2528
+ luckyNumber: REMOVE_FIELD
2529
+ };
2530
+ ```
2531
+
2532
+ @category Utilities
2533
+ */
2534
+ type OptionalKeysOf<BaseType extends object> = Exclude<{
2535
+ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
2536
+ ? never
2537
+ : Key
2538
+ }[keyof BaseType], undefined>;
2539
+
2169
2540
  /**
2170
2541
  Matches any primitive, `void`, `Date`, or `RegExp` value.
2171
2542
  */
2172
2543
  type BuiltIns = Primitive | void | Date | RegExp;
2173
2544
 
2545
+ /**
2546
+ Merges user specified options with default options.
2547
+
2548
+ @example
2549
+ ```
2550
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2551
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
2552
+ type SpecifiedOptions = {leavesOnly: true};
2553
+
2554
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2555
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
2556
+ ```
2557
+
2558
+ @example
2559
+ ```
2560
+ // Complains if default values are not provided for optional options
2561
+
2562
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2563
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
2564
+ type SpecifiedOptions = {};
2565
+
2566
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2567
+ // ~~~~~~~~~~~~~~~~~~~
2568
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
2569
+ ```
2570
+
2571
+ @example
2572
+ ```
2573
+ // Complains if an option's default type does not conform to the expected type
2574
+
2575
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2576
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
2577
+ type SpecifiedOptions = {};
2578
+
2579
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2580
+ // ~~~~~~~~~~~~~~~~~~~
2581
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
2582
+ ```
2583
+
2584
+ @example
2585
+ ```
2586
+ // Complains if an option's specified type does not conform to the expected type
2587
+
2588
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2589
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
2590
+ type SpecifiedOptions = {leavesOnly: 'yes'};
2591
+
2592
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2593
+ // ~~~~~~~~~~~~~~~~
2594
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
2595
+ ```
2596
+ */
2597
+ type ApplyDefaultOptions<
2598
+ Options extends object,
2599
+ Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
2600
+ SpecifiedOptions extends Options,
2601
+ > =
2602
+ IfAny<SpecifiedOptions, Defaults,
2603
+ IfNever<SpecifiedOptions, Defaults,
2604
+ Simplify<Merge<Defaults, {
2605
+ [Key in keyof SpecifiedOptions
2606
+ as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
2607
+ ]: SpecifiedOptions[Key]
2608
+ }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
2609
+ >>;
2610
+
2174
2611
  /**
2175
2612
  @see {@link PartialDeep}
2176
2613
  */
@@ -2209,6 +2646,11 @@ type PartialDeepOptions = {
2209
2646
  readonly allowUndefinedInNonTupleArrays?: boolean;
2210
2647
  };
2211
2648
 
2649
+ type DefaultPartialDeepOptions = {
2650
+ recurseIntoArrays: false;
2651
+ allowUndefinedInNonTupleArrays: true;
2652
+ };
2653
+
2212
2654
  /**
2213
2655
  Create a type from another type with all keys and nested keys set to optional.
2214
2656
 
@@ -2258,7 +2700,10 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
2258
2700
  @category Set
2259
2701
  @category Map
2260
2702
  */
2261
- type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
2703
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> =
2704
+ _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
2705
+
2706
+ type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
2262
2707
  ? T
2263
2708
  : T extends Map<infer KeyType, infer ValueType>
2264
2709
  ? PartialMapDeep<KeyType, ValueType, Options>
@@ -2273,8 +2718,8 @@ type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIn
2273
2718
  ? Options['recurseIntoArrays'] extends true
2274
2719
  ? ItemType[] extends T // Test for arrays (non-tuples) specifically
2275
2720
  ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
2276
- ? ReadonlyArray<PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2277
- : Array<PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2721
+ ? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2722
+ : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2278
2723
  : PartialObjectDeep<T, Options> // Tuples behave properly
2279
2724
  : T // If they don't opt into array testing, just use the original type
2280
2725
  : PartialObjectDeep<T, Options>
@@ -2283,28 +2728,28 @@ type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIn
2283
2728
  /**
2284
2729
  Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
2285
2730
  */
2286
- type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
2731
+ type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
2287
2732
 
2288
2733
  /**
2289
2734
  Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
2290
2735
  */
2291
- type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
2736
+ type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
2292
2737
 
2293
2738
  /**
2294
2739
  Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
2295
2740
  */
2296
- type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
2741
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
2297
2742
 
2298
2743
  /**
2299
2744
  Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
2300
2745
  */
2301
- type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
2746
+ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
2302
2747
 
2303
2748
  /**
2304
2749
  Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
2305
2750
  */
2306
- type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
2307
- [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
2751
+ type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = {
2752
+ [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
2308
2753
  };
2309
2754
 
2310
2755
  interface CustomComponentNormalized {
@@ -2366,4 +2811,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
2366
2811
  }
2367
2812
  }
2368
2813
 
2369
- export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, type RuleContext, type RuleDeclaration, type RuleFeature, type RuleNamespace, type RulePreset, type RuleSeverity, type RuleStatus, WEBSITE_URL, createReport, createRuleForPlugin, decodeSettings, defineSettings, getId, getReactVersion, getSettingsFromContext, isInEditorEnv, isInGitHooksOrLintStaged, toNormalizedSettings, unsafeDecodeSettings };
2814
+ export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, toNormalizedSettings, unsafeDecodeSettings };