@eslint-react/shared 2.0.0-next.145 → 2.0.0-next.147
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.ts +154 -826
- package/dist/index.js +169 -219
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { unit } from
|
|
2
|
-
import { RuleContext } from
|
|
3
|
-
import { z } from
|
|
1
|
+
import { unit } from "@eslint-react/eff";
|
|
2
|
+
import { RuleContext } from "@eslint-react/kit";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
import { PartialDeep } from "type-fest";
|
|
4
5
|
|
|
6
|
+
//#region src/_id.d.ts
|
|
5
7
|
/**
|
|
6
8
|
* @internal
|
|
7
9
|
*/
|
|
8
10
|
declare const getId: () => string;
|
|
9
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/_require.d.ts
|
|
10
13
|
/**
|
|
11
14
|
* @internal
|
|
12
15
|
*/
|
|
13
16
|
declare const _require: NodeJS.Require;
|
|
14
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/constants.d.ts
|
|
15
19
|
/**
|
|
16
20
|
* The NPM scope for this project.
|
|
17
21
|
*/
|
|
@@ -24,7 +28,8 @@ declare const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
|
|
|
24
28
|
* The URL to the project's website.
|
|
25
29
|
*/
|
|
26
30
|
declare const WEBSITE_URL = "https://eslint-react.xyz";
|
|
27
|
-
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/get-doc-url.d.ts
|
|
28
33
|
/**
|
|
29
34
|
* Get the URL for the documentation of a rule in a plugin.
|
|
30
35
|
* @internal
|
|
@@ -32,702 +37,16 @@ declare const WEBSITE_URL = "https://eslint-react.xyz";
|
|
|
32
37
|
* @returns The URL for the documentation of a rule.
|
|
33
38
|
*/
|
|
34
39
|
declare const getDocsUrl: (pluginName: string) => (ruleName: string) => string;
|
|
35
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/get-react-version.d.ts
|
|
36
42
|
declare function getReactVersion(fallback: string): string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
40
|
-
|
|
41
|
-
@category Type
|
|
42
|
-
*/
|
|
43
|
-
type Primitive =
|
|
44
|
-
| null
|
|
45
|
-
| undefined
|
|
46
|
-
| string
|
|
47
|
-
| number
|
|
48
|
-
| boolean
|
|
49
|
-
| symbol
|
|
50
|
-
| bigint;
|
|
51
|
-
|
|
52
|
-
declare global {
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
54
|
-
interface SymbolConstructor {
|
|
55
|
-
readonly observable: symbol;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
Extract all optional keys from the given type.
|
|
61
|
-
|
|
62
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
63
|
-
|
|
64
|
-
@example
|
|
65
|
-
```
|
|
66
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
67
|
-
|
|
68
|
-
interface User {
|
|
69
|
-
name: string;
|
|
70
|
-
surname: string;
|
|
71
|
-
|
|
72
|
-
luckyNumber?: number;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
76
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
77
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const update1: UpdateOperation<User> = {
|
|
81
|
-
name: 'Alice'
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const update2: UpdateOperation<User> = {
|
|
85
|
-
name: 'Bob',
|
|
86
|
-
luckyNumber: REMOVE_FIELD
|
|
87
|
-
};
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
@category Utilities
|
|
91
|
-
*/
|
|
92
|
-
type OptionalKeysOf<BaseType extends object> =
|
|
93
|
-
BaseType extends unknown // For distributing `BaseType`
|
|
94
|
-
? (keyof {
|
|
95
|
-
[Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
|
|
96
|
-
}) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
|
|
97
|
-
: never; // Should never happen
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
Extract all required keys from the given type.
|
|
101
|
-
|
|
102
|
-
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...
|
|
103
|
-
|
|
104
|
-
@example
|
|
105
|
-
```
|
|
106
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
107
|
-
|
|
108
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
109
|
-
|
|
110
|
-
interface User {
|
|
111
|
-
name: string;
|
|
112
|
-
surname: string;
|
|
113
|
-
|
|
114
|
-
luckyNumber?: number;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
118
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
@category Utilities
|
|
122
|
-
*/
|
|
123
|
-
type RequiredKeysOf<BaseType extends object> =
|
|
124
|
-
BaseType extends unknown // For distributing `BaseType`
|
|
125
|
-
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
|
|
126
|
-
: never; // Should never happen
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
Returns a boolean for whether the given type is `never`.
|
|
130
|
-
|
|
131
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
132
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
133
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
134
|
-
|
|
135
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
136
|
-
|
|
137
|
-
@example
|
|
138
|
-
```
|
|
139
|
-
import type {IsNever, And} from 'type-fest';
|
|
140
|
-
|
|
141
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
142
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
143
|
-
And<
|
|
144
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
145
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
146
|
-
>;
|
|
147
|
-
|
|
148
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
149
|
-
AreStringsEqual<I, O> extends true
|
|
150
|
-
? never
|
|
151
|
-
: void;
|
|
152
|
-
|
|
153
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
154
|
-
if (input === output) {
|
|
155
|
-
process.exit(0);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
endIfEqual('abc', 'abc');
|
|
160
|
-
//=> never
|
|
161
|
-
|
|
162
|
-
endIfEqual('abc', '123');
|
|
163
|
-
//=> void
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
@category Type Guard
|
|
167
|
-
@category Utilities
|
|
168
|
-
*/
|
|
169
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
173
|
-
|
|
174
|
-
@see {@link IsNever}
|
|
175
|
-
|
|
176
|
-
@example
|
|
177
|
-
```
|
|
178
|
-
import type {IfNever} from 'type-fest';
|
|
179
|
-
|
|
180
|
-
type ShouldBeTrue = IfNever<never>;
|
|
181
|
-
//=> true
|
|
182
|
-
|
|
183
|
-
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
184
|
-
//=> 'bar'
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
@category Type Guard
|
|
188
|
-
@category Utilities
|
|
189
|
-
*/
|
|
190
|
-
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
191
|
-
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
// Can eventually be replaced with the built-in once this library supports
|
|
195
|
-
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
196
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
Returns a boolean for whether the given type is `any`.
|
|
200
|
-
|
|
201
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
202
|
-
|
|
203
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
204
|
-
|
|
205
|
-
@example
|
|
206
|
-
```
|
|
207
|
-
import type {IsAny} from 'type-fest';
|
|
208
|
-
|
|
209
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
210
|
-
const anyObject: any = {a: 1, b: 2};
|
|
211
|
-
|
|
212
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
213
|
-
return obj[key];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const typedA = get(typedObject, 'a');
|
|
217
|
-
//=> 1
|
|
218
|
-
|
|
219
|
-
const anyA = get(anyObject, 'a');
|
|
220
|
-
//=> any
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
@category Type Guard
|
|
224
|
-
@category Utilities
|
|
225
|
-
*/
|
|
226
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
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.
|
|
230
|
-
|
|
231
|
-
@example
|
|
232
|
-
```
|
|
233
|
-
import type {Simplify} from 'type-fest';
|
|
234
|
-
|
|
235
|
-
type PositionProps = {
|
|
236
|
-
top: number;
|
|
237
|
-
left: number;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
type SizeProps = {
|
|
241
|
-
width: number;
|
|
242
|
-
height: number;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
246
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
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.
|
|
250
|
-
|
|
251
|
-
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`.
|
|
252
|
-
|
|
253
|
-
@example
|
|
254
|
-
```
|
|
255
|
-
import type {Simplify} from 'type-fest';
|
|
256
|
-
|
|
257
|
-
interface SomeInterface {
|
|
258
|
-
foo: number;
|
|
259
|
-
bar?: string;
|
|
260
|
-
baz: number | undefined;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
type SomeType = {
|
|
264
|
-
foo: number;
|
|
265
|
-
bar?: string;
|
|
266
|
-
baz: number | undefined;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
270
|
-
const someType: SomeType = literal;
|
|
271
|
-
const someInterface: SomeInterface = literal;
|
|
272
|
-
|
|
273
|
-
function fn(object: Record<string, unknown>): void {}
|
|
274
|
-
|
|
275
|
-
fn(literal); // Good: literal object type is sealed
|
|
276
|
-
fn(someType); // Good: type is sealed
|
|
277
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
278
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
282
|
-
@see SimplifyDeep
|
|
283
|
-
@category Object
|
|
284
|
-
*/
|
|
285
|
-
type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
289
|
-
|
|
290
|
-
This is the counterpart of `PickIndexSignature`.
|
|
291
|
-
|
|
292
|
-
Use-cases:
|
|
293
|
-
- Remove overly permissive signatures from third-party types.
|
|
294
|
-
|
|
295
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
296
|
-
|
|
297
|
-
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>`.
|
|
298
|
-
|
|
299
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
300
|
-
|
|
301
|
-
```
|
|
302
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
303
|
-
|
|
304
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
305
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
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:
|
|
309
|
-
|
|
310
|
-
```
|
|
311
|
-
type Indexed = {} extends Record<string, unknown>
|
|
312
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
313
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
314
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
315
|
-
|
|
316
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
317
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
318
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
319
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
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`...
|
|
323
|
-
|
|
324
|
-
```
|
|
325
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
326
|
-
|
|
327
|
-
type OmitIndexSignature<ObjectType> = {
|
|
328
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
329
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
330
|
-
};
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
334
|
-
|
|
335
|
-
```
|
|
336
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
337
|
-
|
|
338
|
-
type OmitIndexSignature<ObjectType> = {
|
|
339
|
-
[KeyType in keyof ObjectType
|
|
340
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
341
|
-
as {} extends Record<KeyType, unknown>
|
|
342
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
343
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
344
|
-
]: ObjectType[KeyType];
|
|
345
|
-
};
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
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.
|
|
349
|
-
|
|
350
|
-
@example
|
|
351
|
-
```
|
|
352
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
353
|
-
|
|
354
|
-
interface Example {
|
|
355
|
-
// These index signatures will be removed.
|
|
356
|
-
[x: string]: any
|
|
357
|
-
[x: number]: any
|
|
358
|
-
[x: symbol]: any
|
|
359
|
-
[x: `head-${string}`]: string
|
|
360
|
-
[x: `${string}-tail`]: string
|
|
361
|
-
[x: `head-${string}-tail`]: string
|
|
362
|
-
[x: `${bigint}`]: string
|
|
363
|
-
[x: `embedded-${number}`]: string
|
|
364
|
-
|
|
365
|
-
// These explicitly defined keys will remain.
|
|
366
|
-
foo: 'bar';
|
|
367
|
-
qux?: 'baz';
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
371
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
@see PickIndexSignature
|
|
375
|
-
@category Object
|
|
376
|
-
*/
|
|
377
|
-
type OmitIndexSignature<ObjectType> = {
|
|
378
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
379
|
-
? never
|
|
380
|
-
: KeyType]: ObjectType[KeyType];
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
385
|
-
|
|
386
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
387
|
-
|
|
388
|
-
@example
|
|
389
|
-
```
|
|
390
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
391
|
-
|
|
392
|
-
declare const symbolKey: unique symbol;
|
|
393
|
-
|
|
394
|
-
type Example = {
|
|
395
|
-
// These index signatures will remain.
|
|
396
|
-
[x: string]: unknown;
|
|
397
|
-
[x: number]: unknown;
|
|
398
|
-
[x: symbol]: unknown;
|
|
399
|
-
[x: `head-${string}`]: string;
|
|
400
|
-
[x: `${string}-tail`]: string;
|
|
401
|
-
[x: `head-${string}-tail`]: string;
|
|
402
|
-
[x: `${bigint}`]: string;
|
|
403
|
-
[x: `embedded-${number}`]: string;
|
|
404
|
-
|
|
405
|
-
// These explicitly defined keys will be removed.
|
|
406
|
-
['kebab-case-key']: string;
|
|
407
|
-
[symbolKey]: string;
|
|
408
|
-
foo: 'bar';
|
|
409
|
-
qux?: 'baz';
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
413
|
-
// {
|
|
414
|
-
// [x: string]: unknown;
|
|
415
|
-
// [x: number]: unknown;
|
|
416
|
-
// [x: symbol]: unknown;
|
|
417
|
-
// [x: `head-${string}`]: string;
|
|
418
|
-
// [x: `${string}-tail`]: string;
|
|
419
|
-
// [x: `head-${string}-tail`]: string;
|
|
420
|
-
// [x: `${bigint}`]: string;
|
|
421
|
-
// [x: `embedded-${number}`]: string;
|
|
422
|
-
// }
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
@see OmitIndexSignature
|
|
426
|
-
@category Object
|
|
427
|
-
*/
|
|
428
|
-
type PickIndexSignature<ObjectType> = {
|
|
429
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
430
|
-
? KeyType
|
|
431
|
-
: never]: ObjectType[KeyType];
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
// Merges two objects without worrying about index signatures.
|
|
435
|
-
type SimpleMerge<Destination, Source> = {
|
|
436
|
-
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
437
|
-
} & Source;
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
441
|
-
|
|
442
|
-
@example
|
|
443
|
-
```
|
|
444
|
-
import type {Merge} from 'type-fest';
|
|
445
|
-
|
|
446
|
-
interface Foo {
|
|
447
|
-
[x: string]: unknown;
|
|
448
|
-
[x: number]: unknown;
|
|
449
|
-
foo: string;
|
|
450
|
-
bar: symbol;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
type Bar = {
|
|
454
|
-
[x: number]: number;
|
|
455
|
-
[x: symbol]: unknown;
|
|
456
|
-
bar: Date;
|
|
457
|
-
baz: boolean;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
461
|
-
// => {
|
|
462
|
-
// [x: string]: unknown;
|
|
463
|
-
// [x: number]: number;
|
|
464
|
-
// [x: symbol]: unknown;
|
|
465
|
-
// foo: string;
|
|
466
|
-
// bar: Date;
|
|
467
|
-
// baz: boolean;
|
|
468
|
-
// }
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
@category Object
|
|
472
|
-
*/
|
|
473
|
-
type Merge<Destination, Source> =
|
|
474
|
-
Simplify<
|
|
475
|
-
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
|
|
476
|
-
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
|
|
477
|
-
>;
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
481
|
-
|
|
482
|
-
@see {@link IsAny}
|
|
483
|
-
|
|
484
|
-
@example
|
|
485
|
-
```
|
|
486
|
-
import type {IfAny} from 'type-fest';
|
|
487
|
-
|
|
488
|
-
type ShouldBeTrue = IfAny<any>;
|
|
489
|
-
//=> true
|
|
490
|
-
|
|
491
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
492
|
-
//=> 'bar'
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
@category Type Guard
|
|
496
|
-
@category Utilities
|
|
497
|
-
*/
|
|
498
|
-
type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
|
|
499
|
-
IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
|
|
500
|
-
);
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
504
|
-
*/
|
|
505
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
Merges user specified options with default options.
|
|
509
|
-
|
|
510
|
-
@example
|
|
511
|
-
```
|
|
512
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
513
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
514
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
515
|
-
|
|
516
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
517
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
@example
|
|
521
|
-
```
|
|
522
|
-
// Complains if default values are not provided for optional options
|
|
523
|
-
|
|
524
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
525
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
526
|
-
type SpecifiedOptions = {};
|
|
527
|
-
|
|
528
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
529
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
530
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
@example
|
|
534
|
-
```
|
|
535
|
-
// Complains if an option's default type does not conform to the expected type
|
|
536
|
-
|
|
537
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
538
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
539
|
-
type SpecifiedOptions = {};
|
|
540
|
-
|
|
541
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
542
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
543
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
@example
|
|
547
|
-
```
|
|
548
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
549
|
-
|
|
550
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
551
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
552
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
553
|
-
|
|
554
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
555
|
-
// ~~~~~~~~~~~~~~~~
|
|
556
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
557
|
-
```
|
|
558
|
-
*/
|
|
559
|
-
type ApplyDefaultOptions<
|
|
560
|
-
Options extends object,
|
|
561
|
-
Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
|
|
562
|
-
SpecifiedOptions extends Options,
|
|
563
|
-
> =
|
|
564
|
-
IfAny<SpecifiedOptions, Defaults,
|
|
565
|
-
IfNever<SpecifiedOptions, Defaults,
|
|
566
|
-
Simplify<Merge<Defaults, {
|
|
567
|
-
[Key in keyof SpecifiedOptions
|
|
568
|
-
as Key extends OptionalKeysOf<Options>
|
|
569
|
-
? Extract<SpecifiedOptions[Key], undefined> extends never
|
|
570
|
-
? Key
|
|
571
|
-
: never
|
|
572
|
-
: Key
|
|
573
|
-
]: SpecifiedOptions[Key]
|
|
574
|
-
}> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
575
|
-
>>;
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
@see {@link PartialDeep}
|
|
579
|
-
*/
|
|
580
|
-
type PartialDeepOptions = {
|
|
581
|
-
/**
|
|
582
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
583
|
-
|
|
584
|
-
@default false
|
|
585
|
-
*/
|
|
586
|
-
readonly recurseIntoArrays?: boolean;
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
Allows `undefined` values in non-tuple arrays.
|
|
590
|
-
|
|
591
|
-
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
592
|
-
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
593
|
-
|
|
594
|
-
@default true
|
|
595
|
-
|
|
596
|
-
@example
|
|
597
|
-
You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
|
|
598
|
-
|
|
599
|
-
```
|
|
600
|
-
import type {PartialDeep} from 'type-fest';
|
|
601
|
-
|
|
602
|
-
type Settings = {
|
|
603
|
-
languages: string[];
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
|
|
607
|
-
|
|
608
|
-
partialSettings.languages = [undefined]; // Error
|
|
609
|
-
partialSettings.languages = []; // Ok
|
|
610
|
-
```
|
|
611
|
-
*/
|
|
612
|
-
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
type DefaultPartialDeepOptions = {
|
|
616
|
-
recurseIntoArrays: false;
|
|
617
|
-
allowUndefinedInNonTupleArrays: true;
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
622
|
-
|
|
623
|
-
Use-cases:
|
|
624
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
625
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
626
|
-
|
|
627
|
-
@example
|
|
628
|
-
```
|
|
629
|
-
import type {PartialDeep} from 'type-fest';
|
|
630
|
-
|
|
631
|
-
const settings: Settings = {
|
|
632
|
-
textEditor: {
|
|
633
|
-
fontSize: 14,
|
|
634
|
-
fontColor: '#000000',
|
|
635
|
-
fontWeight: 400
|
|
636
|
-
},
|
|
637
|
-
autocomplete: false,
|
|
638
|
-
autosave: true
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
|
|
642
|
-
return {...settings, ...savedSettings};
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
|
|
649
|
-
|
|
650
|
-
```
|
|
651
|
-
import type {PartialDeep} from 'type-fest';
|
|
652
|
-
|
|
653
|
-
type Settings = {
|
|
654
|
-
languages: string[];
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
658
|
-
languages: [undefined]
|
|
659
|
-
};
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
@see {@link PartialDeepOptions}
|
|
663
|
-
|
|
664
|
-
@category Object
|
|
665
|
-
@category Array
|
|
666
|
-
@category Set
|
|
667
|
-
@category Map
|
|
668
|
-
*/
|
|
669
|
-
type PartialDeep<T, Options extends PartialDeepOptions = {}> =
|
|
670
|
-
_PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
671
|
-
|
|
672
|
-
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown))
|
|
673
|
-
? T
|
|
674
|
-
: IsNever<keyof T> extends true // For functions with no properties
|
|
675
|
-
? T
|
|
676
|
-
: T extends Map<infer KeyType, infer ValueType>
|
|
677
|
-
? PartialMapDeep<KeyType, ValueType, Options>
|
|
678
|
-
: T extends Set<infer ItemType>
|
|
679
|
-
? PartialSetDeep<ItemType, Options>
|
|
680
|
-
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
681
|
-
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
|
|
682
|
-
: T extends ReadonlySet<infer ItemType>
|
|
683
|
-
? PartialReadonlySetDeep<ItemType, Options>
|
|
684
|
-
: T extends object
|
|
685
|
-
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
686
|
-
? Options['recurseIntoArrays'] extends true
|
|
687
|
-
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
688
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
689
|
-
? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
|
|
690
|
-
: Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
|
|
691
|
-
: PartialObjectDeep<T, Options> // Tuples behave properly
|
|
692
|
-
: T // If they don't opt into array testing, just use the original type
|
|
693
|
-
: PartialObjectDeep<T, Options>
|
|
694
|
-
: unknown;
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
698
|
-
*/
|
|
699
|
-
type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
703
|
-
*/
|
|
704
|
-
type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
708
|
-
*/
|
|
709
|
-
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
713
|
-
*/
|
|
714
|
-
type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
718
|
-
*/
|
|
719
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
|
|
720
|
-
(ObjectType extends (...arguments_: any) => unknown
|
|
721
|
-
? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType>
|
|
722
|
-
: {}) & ({
|
|
723
|
-
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
|
|
724
|
-
});
|
|
725
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/settings.d.ts
|
|
726
45
|
declare const CustomComponentPropSchema: z.ZodObject<{
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
as: z.ZodOptional<z.ZodString>;
|
|
48
|
+
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
731
50
|
}, z.core.$strip>;
|
|
732
51
|
/**
|
|
733
52
|
* @description
|
|
@@ -736,17 +55,47 @@ declare const CustomComponentPropSchema: z.ZodObject<{
|
|
|
736
55
|
* Which prop is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
|
|
737
56
|
*/
|
|
738
57
|
declare const CustomComponentSchema: z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
as: z.ZodOptional<z.ZodString>;
|
|
60
|
+
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
739
61
|
name: z.ZodString;
|
|
740
62
|
as: z.ZodOptional<z.ZodString>;
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
defaultValue: z.ZodOptional<z.ZodString>;
|
|
746
|
-
}, z.core.$strip>>>;
|
|
747
|
-
selector: z.ZodOptional<z.ZodString>;
|
|
63
|
+
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>>>;
|
|
66
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
748
67
|
}, z.core.$strip>;
|
|
749
68
|
declare const CustomHooksSchema: z.ZodObject<{
|
|
69
|
+
use: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
useActionState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
useCallback: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
+
useContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
useDebugValue: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
+
useDeferredValue: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
75
|
+
useEffect: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
76
|
+
useFormStatus: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
useId: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
|
+
useImperativeHandle: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
useInsertionEffect: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
|
+
useLayoutEffect: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
81
|
+
useMemo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
useOptimistic: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
useReducer: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
+
useRef: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
85
|
+
useState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
useSyncExternalStore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
useTransition: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
declare const ESLintReactSettingsSchema: z.ZodObject<{
|
|
93
|
+
importSource: z.ZodOptional<z.ZodString>;
|
|
94
|
+
polymorphicPropName: z.ZodOptional<z.ZodString>;
|
|
95
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
skipImportCheck: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
version: z.ZodOptional<z.ZodString>;
|
|
98
|
+
additionalHooks: z.ZodOptional<z.ZodObject<{
|
|
750
99
|
use: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
751
100
|
useActionState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
752
101
|
useCallback: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -766,54 +115,24 @@ declare const CustomHooksSchema: z.ZodObject<{
|
|
|
766
115
|
useState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
767
116
|
useSyncExternalStore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
768
117
|
useTransition: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
769
|
-
}, z.core.$strip
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
version: z.ZodOptional<z.ZodString>;
|
|
779
|
-
additionalHooks: z.ZodOptional<z.ZodObject<{
|
|
780
|
-
use: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
781
|
-
useActionState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
782
|
-
useCallback: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
783
|
-
useContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
784
|
-
useDebugValue: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
785
|
-
useDeferredValue: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
786
|
-
useEffect: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
787
|
-
useFormStatus: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
788
|
-
useId: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
789
|
-
useImperativeHandle: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
790
|
-
useInsertionEffect: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
791
|
-
useLayoutEffect: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
792
|
-
useMemo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
793
|
-
useOptimistic: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
794
|
-
useReducer: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
795
|
-
useRef: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
796
|
-
useState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
797
|
-
useSyncExternalStore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
798
|
-
useTransition: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
799
|
-
}, z.core.$strip>>;
|
|
800
|
-
additionalComponents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
801
|
-
name: z.ZodString;
|
|
802
|
-
as: z.ZodOptional<z.ZodString>;
|
|
803
|
-
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
804
|
-
name: z.ZodString;
|
|
805
|
-
as: z.ZodOptional<z.ZodString>;
|
|
806
|
-
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
807
|
-
defaultValue: z.ZodOptional<z.ZodString>;
|
|
808
|
-
}, z.core.$strip>>>;
|
|
809
|
-
selector: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
additionalComponents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
120
|
+
name: z.ZodString;
|
|
121
|
+
as: z.ZodOptional<z.ZodString>;
|
|
122
|
+
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
123
|
+
name: z.ZodString;
|
|
124
|
+
as: z.ZodOptional<z.ZodString>;
|
|
125
|
+
controlled: z.ZodOptional<z.ZodBoolean>;
|
|
126
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
810
127
|
}, z.core.$strip>>>;
|
|
128
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>>>;
|
|
811
130
|
}, z.core.$strip>;
|
|
812
131
|
/**
|
|
813
132
|
* @internal
|
|
814
133
|
*/
|
|
815
134
|
declare const ESLintSettingsSchema: z.ZodOptional<z.ZodObject<{
|
|
816
|
-
|
|
135
|
+
"react-x": z.ZodOptional<z.ZodUnknown>;
|
|
817
136
|
}, z.core.$strip>>;
|
|
818
137
|
type CustomComponent = z.infer<typeof CustomComponentSchema>;
|
|
819
138
|
type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
|
|
@@ -826,6 +145,19 @@ declare function isESLintReactSettings(settings: unknown): settings is ESLintRea
|
|
|
826
145
|
* The default ESLint settings for "react-x".
|
|
827
146
|
*/
|
|
828
147
|
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
148
|
+
readonly version: "detect";
|
|
149
|
+
readonly importSource: "react";
|
|
150
|
+
readonly strict: true;
|
|
151
|
+
readonly skipImportCheck: true;
|
|
152
|
+
readonly polymorphicPropName: "as";
|
|
153
|
+
readonly additionalComponents: [];
|
|
154
|
+
readonly additionalHooks: {
|
|
155
|
+
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
156
|
+
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
160
|
+
readonly "react-x": {
|
|
829
161
|
readonly version: "detect";
|
|
830
162
|
readonly importSource: "react";
|
|
831
163
|
readonly strict: true;
|
|
@@ -833,91 +165,87 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
|
833
165
|
readonly polymorphicPropName: "as";
|
|
834
166
|
readonly additionalComponents: [];
|
|
835
167
|
readonly additionalHooks: {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
};
|
|
839
|
-
};
|
|
840
|
-
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
841
|
-
readonly "react-x": {
|
|
842
|
-
readonly version: "detect";
|
|
843
|
-
readonly importSource: "react";
|
|
844
|
-
readonly strict: true;
|
|
845
|
-
readonly skipImportCheck: true;
|
|
846
|
-
readonly polymorphicPropName: "as";
|
|
847
|
-
readonly additionalComponents: [];
|
|
848
|
-
readonly additionalHooks: {
|
|
849
|
-
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
850
|
-
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
851
|
-
};
|
|
168
|
+
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
169
|
+
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
852
170
|
};
|
|
171
|
+
};
|
|
853
172
|
};
|
|
854
173
|
interface CustomComponentPropNormalized {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
174
|
+
name: string;
|
|
175
|
+
as: string;
|
|
176
|
+
defaultValue?: string | unit;
|
|
858
177
|
}
|
|
859
178
|
interface CustomComponentNormalized {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
179
|
+
name: string;
|
|
180
|
+
as: string;
|
|
181
|
+
attributes: CustomComponentPropNormalized[];
|
|
182
|
+
re: {
|
|
183
|
+
test(s: string): boolean;
|
|
184
|
+
};
|
|
866
185
|
}
|
|
867
186
|
interface ESLintReactSettingsNormalized {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
187
|
+
additionalHooks: CustomHooks;
|
|
188
|
+
components: CustomComponentNormalized[];
|
|
189
|
+
importSource: string;
|
|
190
|
+
polymorphicPropName: string | unit;
|
|
191
|
+
skipImportCheck: boolean;
|
|
192
|
+
strict: boolean;
|
|
193
|
+
version: string;
|
|
875
194
|
}
|
|
876
195
|
declare const coerceESLintSettings: (settings: unknown) => PartialDeep<ESLintSettings>;
|
|
877
196
|
declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
|
|
878
197
|
declare const coerceSettings: (settings: unknown) => PartialDeep<ESLintReactSettings>;
|
|
879
198
|
declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
|
|
880
|
-
declare const normalizeSettings: ({
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}[];
|
|
895
|
-
readonly additionalHooks: {
|
|
896
|
-
use?: string[] | undefined;
|
|
897
|
-
useActionState?: string[] | undefined;
|
|
898
|
-
useCallback?: string[] | undefined;
|
|
899
|
-
useContext?: string[] | undefined;
|
|
900
|
-
useDebugValue?: string[] | undefined;
|
|
901
|
-
useDeferredValue?: string[] | undefined;
|
|
902
|
-
useEffect?: string[] | undefined;
|
|
903
|
-
useFormStatus?: string[] | undefined;
|
|
904
|
-
useId?: string[] | undefined;
|
|
905
|
-
useImperativeHandle?: string[] | undefined;
|
|
906
|
-
useInsertionEffect?: string[] | undefined;
|
|
907
|
-
useLayoutEffect?: string[] | undefined;
|
|
908
|
-
useMemo?: string[] | undefined;
|
|
909
|
-
useOptimistic?: string[] | undefined;
|
|
910
|
-
useReducer?: string[] | undefined;
|
|
911
|
-
useRef?: string[] | undefined;
|
|
912
|
-
useState?: string[] | undefined;
|
|
913
|
-
useSyncExternalStore?: string[] | undefined;
|
|
914
|
-
useTransition?: string[] | undefined;
|
|
199
|
+
declare const normalizeSettings: ({
|
|
200
|
+
additionalComponents,
|
|
201
|
+
additionalHooks,
|
|
202
|
+
importSource,
|
|
203
|
+
polymorphicPropName,
|
|
204
|
+
skipImportCheck,
|
|
205
|
+
strict,
|
|
206
|
+
version,
|
|
207
|
+
...rest
|
|
208
|
+
}: ESLintReactSettings) => {
|
|
209
|
+
readonly components: {
|
|
210
|
+
name: string;
|
|
211
|
+
re: {
|
|
212
|
+
test(s: string): boolean;
|
|
915
213
|
};
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
214
|
+
as: string;
|
|
215
|
+
attributes: {
|
|
216
|
+
name: string;
|
|
217
|
+
as: string;
|
|
218
|
+
controlled?: boolean | undefined;
|
|
219
|
+
defaultValue?: string | undefined;
|
|
220
|
+
}[];
|
|
221
|
+
selector?: string | undefined;
|
|
222
|
+
}[];
|
|
223
|
+
readonly additionalHooks: {
|
|
224
|
+
use?: string[] | undefined;
|
|
225
|
+
useActionState?: string[] | undefined;
|
|
226
|
+
useCallback?: string[] | undefined;
|
|
227
|
+
useContext?: string[] | undefined;
|
|
228
|
+
useDebugValue?: string[] | undefined;
|
|
229
|
+
useDeferredValue?: string[] | undefined;
|
|
230
|
+
useEffect?: string[] | undefined;
|
|
231
|
+
useFormStatus?: string[] | undefined;
|
|
232
|
+
useId?: string[] | undefined;
|
|
233
|
+
useImperativeHandle?: string[] | undefined;
|
|
234
|
+
useInsertionEffect?: string[] | undefined;
|
|
235
|
+
useLayoutEffect?: string[] | undefined;
|
|
236
|
+
useMemo?: string[] | undefined;
|
|
237
|
+
useOptimistic?: string[] | undefined;
|
|
238
|
+
useReducer?: string[] | undefined;
|
|
239
|
+
useRef?: string[] | undefined;
|
|
240
|
+
useState?: string[] | undefined;
|
|
241
|
+
useSyncExternalStore?: string[] | undefined;
|
|
242
|
+
useTransition?: string[] | undefined;
|
|
243
|
+
};
|
|
244
|
+
readonly importSource: string;
|
|
245
|
+
readonly polymorphicPropName: string;
|
|
246
|
+
readonly skipImportCheck: boolean;
|
|
247
|
+
readonly strict: boolean;
|
|
248
|
+
readonly version: string;
|
|
921
249
|
};
|
|
922
250
|
declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
|
|
923
251
|
/**
|
|
@@ -927,9 +255,9 @@ declare function getSettingsFromContext(context: RuleContext): ESLintReactSettin
|
|
|
927
255
|
*/
|
|
928
256
|
declare const defineSettings: (settings: ESLintReactSettings) => ESLintReactSettings;
|
|
929
257
|
declare module "@typescript-eslint/utils/ts-eslint" {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
258
|
+
interface SharedConfigurationSettings {
|
|
259
|
+
["react-x"]?: Partial<ESLintReactSettings>;
|
|
260
|
+
}
|
|
933
261
|
}
|
|
934
|
-
|
|
935
|
-
export {
|
|
262
|
+
//#endregion
|
|
263
|
+
export { CustomComponent, CustomComponentNormalized, CustomComponentProp, CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
|