@eslint-react/shared 1.47.5-beta.0 → 1.48.1
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 +74 -305
- package/dist/index.d.ts +74 -305
- package/dist/index.js +80 -57
- package/dist/index.mjs +75 -56
- package/package.json +3 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from '@zod/mini';
|
|
2
|
-
import * as micro_memoize from 'micro-memoize';
|
|
3
2
|
import { _ } from '@eslint-react/eff';
|
|
3
|
+
import { RuleContext } from '@eslint-react/kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The NPM scope for this project.
|
|
@@ -165,13 +165,14 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
|
|
|
165
165
|
*/
|
|
166
166
|
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
167
167
|
/**
|
|
168
|
+
* @default `true`
|
|
168
169
|
* @internal
|
|
169
170
|
*/
|
|
170
171
|
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
171
172
|
/**
|
|
172
173
|
* Check both the shape and the import to determine if an API is from React.
|
|
173
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
174
174
|
* @default `true`
|
|
175
|
+
* @internal
|
|
175
176
|
*/
|
|
176
177
|
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
177
178
|
/**
|
|
@@ -270,297 +271,43 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
|
|
|
270
271
|
* @internal
|
|
271
272
|
*/
|
|
272
273
|
declare const ESLintSettingsSchema: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
273
|
-
"react-x": z.ZodMiniOptional<z.
|
|
274
|
-
/**
|
|
275
|
-
* The source where React is imported from.
|
|
276
|
-
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
277
|
-
* @default `"react"`
|
|
278
|
-
* @example `"@pika/react"`
|
|
279
|
-
*/
|
|
280
|
-
importSource: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
281
|
-
/**
|
|
282
|
-
* The identifier that's used for JSX Element creation.
|
|
283
|
-
* @default `"createElement"`
|
|
284
|
-
* @deprecated
|
|
285
|
-
*/
|
|
286
|
-
jsxPragma: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
287
|
-
/**
|
|
288
|
-
* The identifier that's used for JSX fragment elements.
|
|
289
|
-
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
290
|
-
* @default `"Fragment"`
|
|
291
|
-
* @deprecated
|
|
292
|
-
*/
|
|
293
|
-
jsxPragmaFrag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
294
|
-
/**
|
|
295
|
-
* The name of the prop that is used for polymorphic components.
|
|
296
|
-
* @description This is used to determine the type of the component.
|
|
297
|
-
* @example `"as"`
|
|
298
|
-
*/
|
|
299
|
-
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
300
|
-
/**
|
|
301
|
-
* @internal
|
|
302
|
-
*/
|
|
303
|
-
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
304
|
-
/**
|
|
305
|
-
* Check both the shape and the import to determine if an API is from React.
|
|
306
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
307
|
-
* @default `true`
|
|
308
|
-
*/
|
|
309
|
-
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
310
|
-
/**
|
|
311
|
-
* React version to use, "detect" means auto detect React version from the project's dependencies.
|
|
312
|
-
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
313
|
-
* @example `"18.3.1"`
|
|
314
|
-
* @default `"detect"`
|
|
315
|
-
*/
|
|
316
|
-
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
317
|
-
/**
|
|
318
|
-
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
319
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
320
|
-
* @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
|
|
321
|
-
*/
|
|
322
|
-
additionalHooks: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
323
|
-
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
324
|
-
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
325
|
-
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
326
|
-
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
327
|
-
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
328
|
-
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
329
|
-
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
330
|
-
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
331
|
-
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
332
|
-
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
333
|
-
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
334
|
-
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
335
|
-
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
336
|
-
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
337
|
-
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
338
|
-
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
339
|
-
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
340
|
-
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
341
|
-
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
342
|
-
}, {}>>;
|
|
343
|
-
/**
|
|
344
|
-
* An array of user-defined components
|
|
345
|
-
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
346
|
-
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
347
|
-
*/
|
|
348
|
-
additionalComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
349
|
-
/**
|
|
350
|
-
* The name of the user-defined component.
|
|
351
|
-
* @example
|
|
352
|
-
* "Link"
|
|
353
|
-
*/
|
|
354
|
-
name: z.ZodMiniString<string>;
|
|
355
|
-
/**
|
|
356
|
-
* The name of the host component that the user-defined component represents.
|
|
357
|
-
* @example
|
|
358
|
-
* "a"
|
|
359
|
-
*/
|
|
360
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
361
|
-
/**
|
|
362
|
-
* Attributes mapping between the user-defined component and the host component.
|
|
363
|
-
* @example
|
|
364
|
-
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
365
|
-
*/
|
|
366
|
-
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
367
|
-
/**
|
|
368
|
-
* The name of the prop in the user-defined component.
|
|
369
|
-
* @example
|
|
370
|
-
* "to"
|
|
371
|
-
*/
|
|
372
|
-
name: z.ZodMiniString<string>;
|
|
373
|
-
/**
|
|
374
|
-
* The name of the prop in the host component.
|
|
375
|
-
* @example
|
|
376
|
-
* "href"
|
|
377
|
-
*/
|
|
378
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
379
|
-
/**
|
|
380
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
381
|
-
* @internal
|
|
382
|
-
* @example
|
|
383
|
-
* `true`
|
|
384
|
-
*/
|
|
385
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
386
|
-
/**
|
|
387
|
-
* The default value of the prop in the user-defined component.
|
|
388
|
-
* @example
|
|
389
|
-
* `"/"`
|
|
390
|
-
*/
|
|
391
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
392
|
-
}, {}>>>;
|
|
393
|
-
/**
|
|
394
|
-
* The ESQuery selector to select the component precisely.
|
|
395
|
-
* @internal
|
|
396
|
-
* @example
|
|
397
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
398
|
-
*/
|
|
399
|
-
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
400
|
-
}, {}>>>;
|
|
401
|
-
}, {}>>;
|
|
402
|
-
/** @deprecated Use `react-x` instead */
|
|
403
|
-
reactOptions: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
404
|
-
/**
|
|
405
|
-
* The source where React is imported from.
|
|
406
|
-
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
407
|
-
* @default `"react"`
|
|
408
|
-
* @example `"@pika/react"`
|
|
409
|
-
*/
|
|
410
|
-
importSource: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
411
|
-
/**
|
|
412
|
-
* The identifier that's used for JSX Element creation.
|
|
413
|
-
* @default `"createElement"`
|
|
414
|
-
* @deprecated
|
|
415
|
-
*/
|
|
416
|
-
jsxPragma: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
417
|
-
/**
|
|
418
|
-
* The identifier that's used for JSX fragment elements.
|
|
419
|
-
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
420
|
-
* @default `"Fragment"`
|
|
421
|
-
* @deprecated
|
|
422
|
-
*/
|
|
423
|
-
jsxPragmaFrag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
424
|
-
/**
|
|
425
|
-
* The name of the prop that is used for polymorphic components.
|
|
426
|
-
* @description This is used to determine the type of the component.
|
|
427
|
-
* @example `"as"`
|
|
428
|
-
*/
|
|
429
|
-
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
430
|
-
/**
|
|
431
|
-
* @internal
|
|
432
|
-
*/
|
|
433
|
-
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
434
|
-
/**
|
|
435
|
-
* Check both the shape and the import to determine if an API is from React.
|
|
436
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
437
|
-
* @default `true`
|
|
438
|
-
*/
|
|
439
|
-
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
440
|
-
/**
|
|
441
|
-
* React version to use, "detect" means auto detect React version from the project's dependencies.
|
|
442
|
-
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
443
|
-
* @example `"18.3.1"`
|
|
444
|
-
* @default `"detect"`
|
|
445
|
-
*/
|
|
446
|
-
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
447
|
-
/**
|
|
448
|
-
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
449
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
450
|
-
* @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
|
|
451
|
-
*/
|
|
452
|
-
additionalHooks: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
453
|
-
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
454
|
-
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
455
|
-
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
456
|
-
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
457
|
-
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
458
|
-
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
459
|
-
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
460
|
-
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
461
|
-
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
462
|
-
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
463
|
-
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
464
|
-
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
465
|
-
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
466
|
-
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
467
|
-
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
468
|
-
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
469
|
-
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
470
|
-
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
471
|
-
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
472
|
-
}, {}>>;
|
|
473
|
-
/**
|
|
474
|
-
* An array of user-defined components
|
|
475
|
-
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
476
|
-
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
477
|
-
*/
|
|
478
|
-
additionalComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
479
|
-
/**
|
|
480
|
-
* The name of the user-defined component.
|
|
481
|
-
* @example
|
|
482
|
-
* "Link"
|
|
483
|
-
*/
|
|
484
|
-
name: z.ZodMiniString<string>;
|
|
485
|
-
/**
|
|
486
|
-
* The name of the host component that the user-defined component represents.
|
|
487
|
-
* @example
|
|
488
|
-
* "a"
|
|
489
|
-
*/
|
|
490
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
491
|
-
/**
|
|
492
|
-
* Attributes mapping between the user-defined component and the host component.
|
|
493
|
-
* @example
|
|
494
|
-
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
495
|
-
*/
|
|
496
|
-
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
497
|
-
/**
|
|
498
|
-
* The name of the prop in the user-defined component.
|
|
499
|
-
* @example
|
|
500
|
-
* "to"
|
|
501
|
-
*/
|
|
502
|
-
name: z.ZodMiniString<string>;
|
|
503
|
-
/**
|
|
504
|
-
* The name of the prop in the host component.
|
|
505
|
-
* @example
|
|
506
|
-
* "href"
|
|
507
|
-
*/
|
|
508
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
509
|
-
/**
|
|
510
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
511
|
-
* @internal
|
|
512
|
-
* @example
|
|
513
|
-
* `true`
|
|
514
|
-
*/
|
|
515
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
516
|
-
/**
|
|
517
|
-
* The default value of the prop in the user-defined component.
|
|
518
|
-
* @example
|
|
519
|
-
* `"/"`
|
|
520
|
-
*/
|
|
521
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
522
|
-
}, {}>>>;
|
|
523
|
-
/**
|
|
524
|
-
* The ESQuery selector to select the component precisely.
|
|
525
|
-
* @internal
|
|
526
|
-
* @example
|
|
527
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
528
|
-
*/
|
|
529
|
-
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
530
|
-
}, {}>>>;
|
|
531
|
-
}, {}>>;
|
|
274
|
+
"react-x": z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
532
275
|
}, {}>>;
|
|
533
276
|
type CustomComponent = z.infer<typeof CustomComponentSchema>;
|
|
534
277
|
type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
|
|
535
278
|
type CustomHooks = z.infer<typeof CustomHooksSchema>;
|
|
536
|
-
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
537
279
|
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
280
|
+
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
281
|
+
declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
|
|
282
|
+
declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
|
|
538
283
|
/**
|
|
539
284
|
* The default ESLint settings for "react-x".
|
|
540
285
|
*/
|
|
541
286
|
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
542
287
|
readonly version: "detect";
|
|
543
288
|
readonly importSource: "react";
|
|
544
|
-
readonly strict:
|
|
289
|
+
readonly strict: true;
|
|
545
290
|
readonly skipImportCheck: true;
|
|
546
291
|
readonly polymorphicPropName: "as";
|
|
292
|
+
readonly additionalComponents: [];
|
|
547
293
|
readonly additionalHooks: {
|
|
548
294
|
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
549
295
|
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
550
296
|
};
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
readonly
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
297
|
+
};
|
|
298
|
+
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
299
|
+
readonly "react-x": {
|
|
300
|
+
readonly version: "detect";
|
|
301
|
+
readonly importSource: "react";
|
|
302
|
+
readonly strict: true;
|
|
303
|
+
readonly skipImportCheck: true;
|
|
304
|
+
readonly polymorphicPropName: "as";
|
|
305
|
+
readonly additionalComponents: [];
|
|
306
|
+
readonly additionalHooks: {
|
|
307
|
+
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
308
|
+
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
309
|
+
};
|
|
310
|
+
};
|
|
564
311
|
};
|
|
565
312
|
|
|
566
313
|
/**
|
|
@@ -1259,42 +1006,64 @@ interface CustomComponentPropNormalized {
|
|
|
1259
1006
|
as: string;
|
|
1260
1007
|
defaultValue?: string | _;
|
|
1261
1008
|
}
|
|
1262
|
-
/**
|
|
1263
|
-
* The normalized version of the `ESLintReactSettings`.
|
|
1264
|
-
* @internal
|
|
1265
|
-
*/
|
|
1266
1009
|
interface ESLintReactSettingsNormalized {
|
|
1267
1010
|
additionalComponents: CustomComponentNormalized[];
|
|
1268
1011
|
additionalHooks: CustomHooks;
|
|
1269
1012
|
importSource: string;
|
|
1270
1013
|
polymorphicPropName: string | _;
|
|
1271
1014
|
skipImportCheck: boolean;
|
|
1015
|
+
strict: boolean;
|
|
1272
1016
|
version: string;
|
|
1273
1017
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1018
|
+
declare const coerceESLintSettings: (settings: unknown) => PartialDeep<ESLintSettings>;
|
|
1019
|
+
declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
|
|
1020
|
+
declare const coerceSettings: (settings: unknown) => PartialDeep<ESLintReactSettings>;
|
|
1021
|
+
declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
|
|
1022
|
+
declare const normalizeSettings: ({ additionalComponents, additionalHooks, importSource, polymorphicPropName, skipImportCheck, strict, version, ...rest }: ESLintReactSettings) => {
|
|
1023
|
+
readonly additionalComponents: {
|
|
1024
|
+
name: string;
|
|
1025
|
+
as: string;
|
|
1026
|
+
attributes: {
|
|
1027
|
+
name: string;
|
|
1028
|
+
as: string;
|
|
1029
|
+
controlled?: boolean | undefined;
|
|
1030
|
+
defaultValue?: string | undefined;
|
|
1031
|
+
}[];
|
|
1032
|
+
re: {
|
|
1033
|
+
test(s: string): boolean;
|
|
1034
|
+
};
|
|
1035
|
+
selector?: string | undefined;
|
|
1036
|
+
}[];
|
|
1037
|
+
readonly additionalHooks: {
|
|
1038
|
+
use?: string[] | undefined;
|
|
1039
|
+
useActionState?: string[] | undefined;
|
|
1040
|
+
useCallback?: string[] | undefined;
|
|
1041
|
+
useContext?: string[] | undefined;
|
|
1042
|
+
useDebugValue?: string[] | undefined;
|
|
1043
|
+
useDeferredValue?: string[] | undefined;
|
|
1044
|
+
useEffect?: string[] | undefined;
|
|
1045
|
+
useFormStatus?: string[] | undefined;
|
|
1046
|
+
useId?: string[] | undefined;
|
|
1047
|
+
useImperativeHandle?: string[] | undefined;
|
|
1048
|
+
useInsertionEffect?: string[] | undefined;
|
|
1049
|
+
useLayoutEffect?: string[] | undefined;
|
|
1050
|
+
useMemo?: string[] | undefined;
|
|
1051
|
+
useOptimistic?: string[] | undefined;
|
|
1052
|
+
useReducer?: string[] | undefined;
|
|
1053
|
+
useRef?: string[] | undefined;
|
|
1054
|
+
useState?: string[] | undefined;
|
|
1055
|
+
useSyncExternalStore?: string[] | undefined;
|
|
1056
|
+
useTransition?: string[] | undefined;
|
|
1057
|
+
};
|
|
1058
|
+
readonly importSource: string;
|
|
1059
|
+
readonly polymorphicPropName: string;
|
|
1060
|
+
readonly skipImportCheck: boolean;
|
|
1061
|
+
readonly strict: boolean;
|
|
1062
|
+
readonly version: string;
|
|
1063
|
+
readonly jsxPragma?: string | undefined;
|
|
1064
|
+
readonly jsxPragmaFrag?: string | undefined;
|
|
1065
|
+
};
|
|
1066
|
+
declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
|
|
1298
1067
|
/**
|
|
1299
1068
|
* A helper function to define settings for "react-x" with type checking in JavaScript files.
|
|
1300
1069
|
* @param settings The settings.
|
|
@@ -1307,4 +1076,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
1307
1076
|
}
|
|
1308
1077
|
}
|
|
1309
1078
|
|
|
1310
|
-
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,
|
|
1079
|
+
export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from '@zod/mini';
|
|
2
|
-
import * as micro_memoize from 'micro-memoize';
|
|
3
2
|
import { _ } from '@eslint-react/eff';
|
|
3
|
+
import { RuleContext } from '@eslint-react/kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The NPM scope for this project.
|
|
@@ -165,13 +165,14 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
|
|
|
165
165
|
*/
|
|
166
166
|
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
167
167
|
/**
|
|
168
|
+
* @default `true`
|
|
168
169
|
* @internal
|
|
169
170
|
*/
|
|
170
171
|
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
171
172
|
/**
|
|
172
173
|
* Check both the shape and the import to determine if an API is from React.
|
|
173
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
174
174
|
* @default `true`
|
|
175
|
+
* @internal
|
|
175
176
|
*/
|
|
176
177
|
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
177
178
|
/**
|
|
@@ -270,297 +271,43 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
|
|
|
270
271
|
* @internal
|
|
271
272
|
*/
|
|
272
273
|
declare const ESLintSettingsSchema: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
273
|
-
"react-x": z.ZodMiniOptional<z.
|
|
274
|
-
/**
|
|
275
|
-
* The source where React is imported from.
|
|
276
|
-
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
277
|
-
* @default `"react"`
|
|
278
|
-
* @example `"@pika/react"`
|
|
279
|
-
*/
|
|
280
|
-
importSource: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
281
|
-
/**
|
|
282
|
-
* The identifier that's used for JSX Element creation.
|
|
283
|
-
* @default `"createElement"`
|
|
284
|
-
* @deprecated
|
|
285
|
-
*/
|
|
286
|
-
jsxPragma: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
287
|
-
/**
|
|
288
|
-
* The identifier that's used for JSX fragment elements.
|
|
289
|
-
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
290
|
-
* @default `"Fragment"`
|
|
291
|
-
* @deprecated
|
|
292
|
-
*/
|
|
293
|
-
jsxPragmaFrag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
294
|
-
/**
|
|
295
|
-
* The name of the prop that is used for polymorphic components.
|
|
296
|
-
* @description This is used to determine the type of the component.
|
|
297
|
-
* @example `"as"`
|
|
298
|
-
*/
|
|
299
|
-
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
300
|
-
/**
|
|
301
|
-
* @internal
|
|
302
|
-
*/
|
|
303
|
-
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
304
|
-
/**
|
|
305
|
-
* Check both the shape and the import to determine if an API is from React.
|
|
306
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
307
|
-
* @default `true`
|
|
308
|
-
*/
|
|
309
|
-
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
310
|
-
/**
|
|
311
|
-
* React version to use, "detect" means auto detect React version from the project's dependencies.
|
|
312
|
-
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
313
|
-
* @example `"18.3.1"`
|
|
314
|
-
* @default `"detect"`
|
|
315
|
-
*/
|
|
316
|
-
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
317
|
-
/**
|
|
318
|
-
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
319
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
320
|
-
* @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
|
|
321
|
-
*/
|
|
322
|
-
additionalHooks: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
323
|
-
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
324
|
-
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
325
|
-
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
326
|
-
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
327
|
-
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
328
|
-
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
329
|
-
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
330
|
-
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
331
|
-
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
332
|
-
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
333
|
-
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
334
|
-
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
335
|
-
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
336
|
-
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
337
|
-
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
338
|
-
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
339
|
-
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
340
|
-
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
341
|
-
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
342
|
-
}, {}>>;
|
|
343
|
-
/**
|
|
344
|
-
* An array of user-defined components
|
|
345
|
-
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
346
|
-
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
347
|
-
*/
|
|
348
|
-
additionalComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
349
|
-
/**
|
|
350
|
-
* The name of the user-defined component.
|
|
351
|
-
* @example
|
|
352
|
-
* "Link"
|
|
353
|
-
*/
|
|
354
|
-
name: z.ZodMiniString<string>;
|
|
355
|
-
/**
|
|
356
|
-
* The name of the host component that the user-defined component represents.
|
|
357
|
-
* @example
|
|
358
|
-
* "a"
|
|
359
|
-
*/
|
|
360
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
361
|
-
/**
|
|
362
|
-
* Attributes mapping between the user-defined component and the host component.
|
|
363
|
-
* @example
|
|
364
|
-
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
365
|
-
*/
|
|
366
|
-
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
367
|
-
/**
|
|
368
|
-
* The name of the prop in the user-defined component.
|
|
369
|
-
* @example
|
|
370
|
-
* "to"
|
|
371
|
-
*/
|
|
372
|
-
name: z.ZodMiniString<string>;
|
|
373
|
-
/**
|
|
374
|
-
* The name of the prop in the host component.
|
|
375
|
-
* @example
|
|
376
|
-
* "href"
|
|
377
|
-
*/
|
|
378
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
379
|
-
/**
|
|
380
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
381
|
-
* @internal
|
|
382
|
-
* @example
|
|
383
|
-
* `true`
|
|
384
|
-
*/
|
|
385
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
386
|
-
/**
|
|
387
|
-
* The default value of the prop in the user-defined component.
|
|
388
|
-
* @example
|
|
389
|
-
* `"/"`
|
|
390
|
-
*/
|
|
391
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
392
|
-
}, {}>>>;
|
|
393
|
-
/**
|
|
394
|
-
* The ESQuery selector to select the component precisely.
|
|
395
|
-
* @internal
|
|
396
|
-
* @example
|
|
397
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
398
|
-
*/
|
|
399
|
-
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
400
|
-
}, {}>>>;
|
|
401
|
-
}, {}>>;
|
|
402
|
-
/** @deprecated Use `react-x` instead */
|
|
403
|
-
reactOptions: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
404
|
-
/**
|
|
405
|
-
* The source where React is imported from.
|
|
406
|
-
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
407
|
-
* @default `"react"`
|
|
408
|
-
* @example `"@pika/react"`
|
|
409
|
-
*/
|
|
410
|
-
importSource: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
411
|
-
/**
|
|
412
|
-
* The identifier that's used for JSX Element creation.
|
|
413
|
-
* @default `"createElement"`
|
|
414
|
-
* @deprecated
|
|
415
|
-
*/
|
|
416
|
-
jsxPragma: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
417
|
-
/**
|
|
418
|
-
* The identifier that's used for JSX fragment elements.
|
|
419
|
-
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
420
|
-
* @default `"Fragment"`
|
|
421
|
-
* @deprecated
|
|
422
|
-
*/
|
|
423
|
-
jsxPragmaFrag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
424
|
-
/**
|
|
425
|
-
* The name of the prop that is used for polymorphic components.
|
|
426
|
-
* @description This is used to determine the type of the component.
|
|
427
|
-
* @example `"as"`
|
|
428
|
-
*/
|
|
429
|
-
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
430
|
-
/**
|
|
431
|
-
* @internal
|
|
432
|
-
*/
|
|
433
|
-
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
434
|
-
/**
|
|
435
|
-
* Check both the shape and the import to determine if an API is from React.
|
|
436
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
437
|
-
* @default `true`
|
|
438
|
-
*/
|
|
439
|
-
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
440
|
-
/**
|
|
441
|
-
* React version to use, "detect" means auto detect React version from the project's dependencies.
|
|
442
|
-
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
443
|
-
* @example `"18.3.1"`
|
|
444
|
-
* @default `"detect"`
|
|
445
|
-
*/
|
|
446
|
-
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
447
|
-
/**
|
|
448
|
-
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
449
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
450
|
-
* @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
|
|
451
|
-
*/
|
|
452
|
-
additionalHooks: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
453
|
-
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
454
|
-
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
455
|
-
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
456
|
-
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
457
|
-
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
458
|
-
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
459
|
-
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
460
|
-
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
461
|
-
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
462
|
-
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
463
|
-
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
464
|
-
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
465
|
-
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
466
|
-
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
467
|
-
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
468
|
-
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
469
|
-
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
470
|
-
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
471
|
-
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
472
|
-
}, {}>>;
|
|
473
|
-
/**
|
|
474
|
-
* An array of user-defined components
|
|
475
|
-
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
476
|
-
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
477
|
-
*/
|
|
478
|
-
additionalComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
479
|
-
/**
|
|
480
|
-
* The name of the user-defined component.
|
|
481
|
-
* @example
|
|
482
|
-
* "Link"
|
|
483
|
-
*/
|
|
484
|
-
name: z.ZodMiniString<string>;
|
|
485
|
-
/**
|
|
486
|
-
* The name of the host component that the user-defined component represents.
|
|
487
|
-
* @example
|
|
488
|
-
* "a"
|
|
489
|
-
*/
|
|
490
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
491
|
-
/**
|
|
492
|
-
* Attributes mapping between the user-defined component and the host component.
|
|
493
|
-
* @example
|
|
494
|
-
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
495
|
-
*/
|
|
496
|
-
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
497
|
-
/**
|
|
498
|
-
* The name of the prop in the user-defined component.
|
|
499
|
-
* @example
|
|
500
|
-
* "to"
|
|
501
|
-
*/
|
|
502
|
-
name: z.ZodMiniString<string>;
|
|
503
|
-
/**
|
|
504
|
-
* The name of the prop in the host component.
|
|
505
|
-
* @example
|
|
506
|
-
* "href"
|
|
507
|
-
*/
|
|
508
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
509
|
-
/**
|
|
510
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
511
|
-
* @internal
|
|
512
|
-
* @example
|
|
513
|
-
* `true`
|
|
514
|
-
*/
|
|
515
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
516
|
-
/**
|
|
517
|
-
* The default value of the prop in the user-defined component.
|
|
518
|
-
* @example
|
|
519
|
-
* `"/"`
|
|
520
|
-
*/
|
|
521
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
522
|
-
}, {}>>>;
|
|
523
|
-
/**
|
|
524
|
-
* The ESQuery selector to select the component precisely.
|
|
525
|
-
* @internal
|
|
526
|
-
* @example
|
|
527
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
528
|
-
*/
|
|
529
|
-
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
530
|
-
}, {}>>>;
|
|
531
|
-
}, {}>>;
|
|
274
|
+
"react-x": z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
532
275
|
}, {}>>;
|
|
533
276
|
type CustomComponent = z.infer<typeof CustomComponentSchema>;
|
|
534
277
|
type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
|
|
535
278
|
type CustomHooks = z.infer<typeof CustomHooksSchema>;
|
|
536
|
-
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
537
279
|
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
280
|
+
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
281
|
+
declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
|
|
282
|
+
declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
|
|
538
283
|
/**
|
|
539
284
|
* The default ESLint settings for "react-x".
|
|
540
285
|
*/
|
|
541
286
|
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
542
287
|
readonly version: "detect";
|
|
543
288
|
readonly importSource: "react";
|
|
544
|
-
readonly strict:
|
|
289
|
+
readonly strict: true;
|
|
545
290
|
readonly skipImportCheck: true;
|
|
546
291
|
readonly polymorphicPropName: "as";
|
|
292
|
+
readonly additionalComponents: [];
|
|
547
293
|
readonly additionalHooks: {
|
|
548
294
|
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
549
295
|
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
550
296
|
};
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
readonly
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
297
|
+
};
|
|
298
|
+
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
299
|
+
readonly "react-x": {
|
|
300
|
+
readonly version: "detect";
|
|
301
|
+
readonly importSource: "react";
|
|
302
|
+
readonly strict: true;
|
|
303
|
+
readonly skipImportCheck: true;
|
|
304
|
+
readonly polymorphicPropName: "as";
|
|
305
|
+
readonly additionalComponents: [];
|
|
306
|
+
readonly additionalHooks: {
|
|
307
|
+
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
308
|
+
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
309
|
+
};
|
|
310
|
+
};
|
|
564
311
|
};
|
|
565
312
|
|
|
566
313
|
/**
|
|
@@ -1259,42 +1006,64 @@ interface CustomComponentPropNormalized {
|
|
|
1259
1006
|
as: string;
|
|
1260
1007
|
defaultValue?: string | _;
|
|
1261
1008
|
}
|
|
1262
|
-
/**
|
|
1263
|
-
* The normalized version of the `ESLintReactSettings`.
|
|
1264
|
-
* @internal
|
|
1265
|
-
*/
|
|
1266
1009
|
interface ESLintReactSettingsNormalized {
|
|
1267
1010
|
additionalComponents: CustomComponentNormalized[];
|
|
1268
1011
|
additionalHooks: CustomHooks;
|
|
1269
1012
|
importSource: string;
|
|
1270
1013
|
polymorphicPropName: string | _;
|
|
1271
1014
|
skipImportCheck: boolean;
|
|
1015
|
+
strict: boolean;
|
|
1272
1016
|
version: string;
|
|
1273
1017
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1018
|
+
declare const coerceESLintSettings: (settings: unknown) => PartialDeep<ESLintSettings>;
|
|
1019
|
+
declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
|
|
1020
|
+
declare const coerceSettings: (settings: unknown) => PartialDeep<ESLintReactSettings>;
|
|
1021
|
+
declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
|
|
1022
|
+
declare const normalizeSettings: ({ additionalComponents, additionalHooks, importSource, polymorphicPropName, skipImportCheck, strict, version, ...rest }: ESLintReactSettings) => {
|
|
1023
|
+
readonly additionalComponents: {
|
|
1024
|
+
name: string;
|
|
1025
|
+
as: string;
|
|
1026
|
+
attributes: {
|
|
1027
|
+
name: string;
|
|
1028
|
+
as: string;
|
|
1029
|
+
controlled?: boolean | undefined;
|
|
1030
|
+
defaultValue?: string | undefined;
|
|
1031
|
+
}[];
|
|
1032
|
+
re: {
|
|
1033
|
+
test(s: string): boolean;
|
|
1034
|
+
};
|
|
1035
|
+
selector?: string | undefined;
|
|
1036
|
+
}[];
|
|
1037
|
+
readonly additionalHooks: {
|
|
1038
|
+
use?: string[] | undefined;
|
|
1039
|
+
useActionState?: string[] | undefined;
|
|
1040
|
+
useCallback?: string[] | undefined;
|
|
1041
|
+
useContext?: string[] | undefined;
|
|
1042
|
+
useDebugValue?: string[] | undefined;
|
|
1043
|
+
useDeferredValue?: string[] | undefined;
|
|
1044
|
+
useEffect?: string[] | undefined;
|
|
1045
|
+
useFormStatus?: string[] | undefined;
|
|
1046
|
+
useId?: string[] | undefined;
|
|
1047
|
+
useImperativeHandle?: string[] | undefined;
|
|
1048
|
+
useInsertionEffect?: string[] | undefined;
|
|
1049
|
+
useLayoutEffect?: string[] | undefined;
|
|
1050
|
+
useMemo?: string[] | undefined;
|
|
1051
|
+
useOptimistic?: string[] | undefined;
|
|
1052
|
+
useReducer?: string[] | undefined;
|
|
1053
|
+
useRef?: string[] | undefined;
|
|
1054
|
+
useState?: string[] | undefined;
|
|
1055
|
+
useSyncExternalStore?: string[] | undefined;
|
|
1056
|
+
useTransition?: string[] | undefined;
|
|
1057
|
+
};
|
|
1058
|
+
readonly importSource: string;
|
|
1059
|
+
readonly polymorphicPropName: string;
|
|
1060
|
+
readonly skipImportCheck: boolean;
|
|
1061
|
+
readonly strict: boolean;
|
|
1062
|
+
readonly version: string;
|
|
1063
|
+
readonly jsxPragma?: string | undefined;
|
|
1064
|
+
readonly jsxPragmaFrag?: string | undefined;
|
|
1065
|
+
};
|
|
1066
|
+
declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
|
|
1298
1067
|
/**
|
|
1299
1068
|
* A helper function to define settings for "react-x" with type checking in JavaScript files.
|
|
1300
1069
|
* @param settings The settings.
|
|
@@ -1307,4 +1076,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
1307
1076
|
}
|
|
1308
1077
|
}
|
|
1309
1078
|
|
|
1310
|
-
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,
|
|
1079
|
+
export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,6 @@ var eff = require('@eslint-react/eff');
|
|
|
5
5
|
var tsPattern = require('ts-pattern');
|
|
6
6
|
var z = require('@zod/mini');
|
|
7
7
|
var kit = require('@eslint-react/kit');
|
|
8
|
-
var fastEquals = require('fast-equals');
|
|
9
|
-
var memoize = require('micro-memoize');
|
|
10
8
|
|
|
11
9
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
12
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -31,7 +29,6 @@ function _interopNamespace(e) {
|
|
|
31
29
|
|
|
32
30
|
var module__default = /*#__PURE__*/_interopDefault(module$1);
|
|
33
31
|
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
34
|
-
var memoize__default = /*#__PURE__*/_interopDefault(memoize);
|
|
35
32
|
|
|
36
33
|
// src/constants.ts
|
|
37
34
|
var NPM_SCOPE = "@eslint-react";
|
|
@@ -160,13 +157,14 @@ var ESLintReactSettingsSchema = z__namespace.object({
|
|
|
160
157
|
*/
|
|
161
158
|
polymorphicPropName: z__namespace.optional(z__namespace.string()),
|
|
162
159
|
/**
|
|
160
|
+
* @default `true`
|
|
163
161
|
* @internal
|
|
164
162
|
*/
|
|
165
163
|
strict: z__namespace.optional(z__namespace.boolean()),
|
|
166
164
|
/**
|
|
167
165
|
* Check both the shape and the import to determine if an API is from React.
|
|
168
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
169
166
|
* @default `true`
|
|
167
|
+
* @internal
|
|
170
168
|
*/
|
|
171
169
|
skipImportCheck: z__namespace.optional(z__namespace.boolean()),
|
|
172
170
|
/**
|
|
@@ -191,73 +189,93 @@ var ESLintReactSettingsSchema = z__namespace.object({
|
|
|
191
189
|
});
|
|
192
190
|
var ESLintSettingsSchema = z__namespace.optional(
|
|
193
191
|
z__namespace.object({
|
|
194
|
-
"react-x": z__namespace.optional(
|
|
195
|
-
/** @deprecated Use `react-x` instead */
|
|
196
|
-
reactOptions: z__namespace.optional(ESLintReactSettingsSchema)
|
|
192
|
+
"react-x": z__namespace.optional(z__namespace.unknown())
|
|
197
193
|
}),
|
|
198
194
|
{}
|
|
199
195
|
);
|
|
196
|
+
function isESLintSettings(settings) {
|
|
197
|
+
return ESLintSettingsSchema.safeParse(settings).success;
|
|
198
|
+
}
|
|
199
|
+
function isESLintReactSettings(settings) {
|
|
200
|
+
return ESLintReactSettingsSchema.safeParse(settings).success;
|
|
201
|
+
}
|
|
200
202
|
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
201
|
-
...z__namespace.parse(ESLintReactSettingsSchema, {}),
|
|
202
203
|
version: "detect",
|
|
203
204
|
importSource: "react",
|
|
204
|
-
strict:
|
|
205
|
+
strict: true,
|
|
205
206
|
skipImportCheck: true,
|
|
206
207
|
polymorphicPropName: "as",
|
|
208
|
+
additionalComponents: [],
|
|
207
209
|
additionalHooks: {
|
|
208
210
|
useEffect: ["useIsomorphicLayoutEffect"],
|
|
209
211
|
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
210
212
|
}
|
|
211
213
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
var
|
|
214
|
+
var DEFAULT_ESLINT_SETTINGS = {
|
|
215
|
+
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
216
|
+
};
|
|
217
|
+
var coerceESLintSettings = (settings) => {
|
|
218
|
+
return settings;
|
|
219
|
+
};
|
|
220
|
+
var decodeESLintSettings = (settings) => {
|
|
221
|
+
if (isESLintSettings(settings)) {
|
|
222
|
+
return settings;
|
|
223
|
+
}
|
|
224
|
+
return DEFAULT_ESLINT_SETTINGS;
|
|
225
|
+
};
|
|
226
|
+
var coerceSettings = (settings) => {
|
|
227
|
+
return settings;
|
|
228
|
+
};
|
|
229
|
+
var decodeSettings = (settings) => {
|
|
230
|
+
if (isESLintReactSettings(settings)) {
|
|
231
|
+
return settings;
|
|
232
|
+
}
|
|
233
|
+
return DEFAULT_ESLINT_REACT_SETTINGS;
|
|
234
|
+
};
|
|
235
|
+
var normalizeSettings = ({
|
|
236
|
+
additionalComponents = [],
|
|
237
|
+
additionalHooks = {},
|
|
238
|
+
importSource = "react",
|
|
239
|
+
polymorphicPropName = "as",
|
|
240
|
+
skipImportCheck = true,
|
|
241
|
+
strict = true,
|
|
242
|
+
version,
|
|
243
|
+
...rest
|
|
244
|
+
}) => {
|
|
216
245
|
return {
|
|
217
|
-
...
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}) => {
|
|
232
|
-
return {
|
|
233
|
-
...rest,
|
|
234
|
-
additionalComponents: additionalComponents.map(({
|
|
235
|
-
name,
|
|
236
|
-
as = name,
|
|
237
|
-
attributes = [],
|
|
238
|
-
...rest2
|
|
239
|
-
}) => ({
|
|
240
|
-
...rest2,
|
|
241
|
-
name,
|
|
242
|
-
as,
|
|
243
|
-
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
244
|
-
...rest3,
|
|
245
|
-
name: name2,
|
|
246
|
-
as: as2
|
|
247
|
-
})),
|
|
248
|
-
re: kit.RegExp.toRegExp(name)
|
|
246
|
+
...rest,
|
|
247
|
+
additionalComponents: additionalComponents.map(({
|
|
248
|
+
name,
|
|
249
|
+
as = name,
|
|
250
|
+
attributes = [],
|
|
251
|
+
...rest2
|
|
252
|
+
}) => ({
|
|
253
|
+
...rest2,
|
|
254
|
+
name,
|
|
255
|
+
as,
|
|
256
|
+
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
257
|
+
...rest3,
|
|
258
|
+
name: name2,
|
|
259
|
+
as: as2
|
|
249
260
|
})),
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
261
|
+
re: kit.RegExp.toRegExp(name)
|
|
262
|
+
})),
|
|
263
|
+
additionalHooks,
|
|
264
|
+
importSource,
|
|
265
|
+
polymorphicPropName,
|
|
266
|
+
skipImportCheck,
|
|
267
|
+
strict,
|
|
268
|
+
version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(eff.identity)
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
var cache = /* @__PURE__ */ new Map();
|
|
259
272
|
function getSettingsFromContext(context) {
|
|
260
|
-
|
|
273
|
+
const settings = context.settings;
|
|
274
|
+
return eff.getOrElseUpdate(
|
|
275
|
+
cache,
|
|
276
|
+
settings["react-x"],
|
|
277
|
+
() => normalizeSettings(decodeSettings(settings["react-x"]))
|
|
278
|
+
);
|
|
261
279
|
}
|
|
262
280
|
var defineSettings = eff.identity;
|
|
263
281
|
|
|
@@ -265,16 +283,21 @@ exports.CustomComponentPropSchema = CustomComponentPropSchema;
|
|
|
265
283
|
exports.CustomComponentSchema = CustomComponentSchema;
|
|
266
284
|
exports.CustomHooksSchema = CustomHooksSchema;
|
|
267
285
|
exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
|
|
286
|
+
exports.DEFAULT_ESLINT_SETTINGS = DEFAULT_ESLINT_SETTINGS;
|
|
268
287
|
exports.ESLintReactSettingsSchema = ESLintReactSettingsSchema;
|
|
269
288
|
exports.ESLintSettingsSchema = ESLintSettingsSchema;
|
|
270
289
|
exports.GITHUB_URL = GITHUB_URL;
|
|
271
290
|
exports.NPM_SCOPE = NPM_SCOPE;
|
|
272
291
|
exports.WEBSITE_URL = WEBSITE_URL;
|
|
292
|
+
exports.coerceESLintSettings = coerceESLintSettings;
|
|
293
|
+
exports.coerceSettings = coerceSettings;
|
|
294
|
+
exports.decodeESLintSettings = decodeESLintSettings;
|
|
273
295
|
exports.decodeSettings = decodeSettings;
|
|
274
296
|
exports.defineSettings = defineSettings;
|
|
275
297
|
exports.getDocsUrl = getDocsUrl;
|
|
276
298
|
exports.getId = getId;
|
|
277
299
|
exports.getReactVersion = getReactVersion;
|
|
278
300
|
exports.getSettingsFromContext = getSettingsFromContext;
|
|
279
|
-
exports.
|
|
280
|
-
exports.
|
|
301
|
+
exports.isESLintReactSettings = isESLintReactSettings;
|
|
302
|
+
exports.isESLintSettings = isESLintSettings;
|
|
303
|
+
exports.normalizeSettings = normalizeSettings;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import module from 'node:module';
|
|
2
|
-
import { identity } from '@eslint-react/eff';
|
|
2
|
+
import { identity, getOrElseUpdate } from '@eslint-react/eff';
|
|
3
3
|
import { match, P } from 'ts-pattern';
|
|
4
4
|
import * as z from '@zod/mini';
|
|
5
5
|
import { RegExp } from '@eslint-react/kit';
|
|
6
|
-
import { shallowEqual } from 'fast-equals';
|
|
7
|
-
import memoize from 'micro-memoize';
|
|
8
6
|
|
|
9
7
|
// src/constants.ts
|
|
10
8
|
var NPM_SCOPE = "@eslint-react";
|
|
@@ -133,13 +131,14 @@ var ESLintReactSettingsSchema = z.object({
|
|
|
133
131
|
*/
|
|
134
132
|
polymorphicPropName: z.optional(z.string()),
|
|
135
133
|
/**
|
|
134
|
+
* @default `true`
|
|
136
135
|
* @internal
|
|
137
136
|
*/
|
|
138
137
|
strict: z.optional(z.boolean()),
|
|
139
138
|
/**
|
|
140
139
|
* Check both the shape and the import to determine if an API is from React.
|
|
141
|
-
* @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
|
|
142
140
|
* @default `true`
|
|
141
|
+
* @internal
|
|
143
142
|
*/
|
|
144
143
|
skipImportCheck: z.optional(z.boolean()),
|
|
145
144
|
/**
|
|
@@ -164,74 +163,94 @@ var ESLintReactSettingsSchema = z.object({
|
|
|
164
163
|
});
|
|
165
164
|
var ESLintSettingsSchema = z.optional(
|
|
166
165
|
z.object({
|
|
167
|
-
"react-x": z.optional(
|
|
168
|
-
/** @deprecated Use `react-x` instead */
|
|
169
|
-
reactOptions: z.optional(ESLintReactSettingsSchema)
|
|
166
|
+
"react-x": z.optional(z.unknown())
|
|
170
167
|
}),
|
|
171
168
|
{}
|
|
172
169
|
);
|
|
170
|
+
function isESLintSettings(settings) {
|
|
171
|
+
return ESLintSettingsSchema.safeParse(settings).success;
|
|
172
|
+
}
|
|
173
|
+
function isESLintReactSettings(settings) {
|
|
174
|
+
return ESLintReactSettingsSchema.safeParse(settings).success;
|
|
175
|
+
}
|
|
173
176
|
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
174
|
-
...z.parse(ESLintReactSettingsSchema, {}),
|
|
175
177
|
version: "detect",
|
|
176
178
|
importSource: "react",
|
|
177
|
-
strict:
|
|
179
|
+
strict: true,
|
|
178
180
|
skipImportCheck: true,
|
|
179
181
|
polymorphicPropName: "as",
|
|
182
|
+
additionalComponents: [],
|
|
180
183
|
additionalHooks: {
|
|
181
184
|
useEffect: ["useIsomorphicLayoutEffect"],
|
|
182
185
|
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
183
186
|
}
|
|
184
187
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
var
|
|
188
|
+
var DEFAULT_ESLINT_SETTINGS = {
|
|
189
|
+
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
190
|
+
};
|
|
191
|
+
var coerceESLintSettings = (settings) => {
|
|
192
|
+
return settings;
|
|
193
|
+
};
|
|
194
|
+
var decodeESLintSettings = (settings) => {
|
|
195
|
+
if (isESLintSettings(settings)) {
|
|
196
|
+
return settings;
|
|
197
|
+
}
|
|
198
|
+
return DEFAULT_ESLINT_SETTINGS;
|
|
199
|
+
};
|
|
200
|
+
var coerceSettings = (settings) => {
|
|
201
|
+
return settings;
|
|
202
|
+
};
|
|
203
|
+
var decodeSettings = (settings) => {
|
|
204
|
+
if (isESLintReactSettings(settings)) {
|
|
205
|
+
return settings;
|
|
206
|
+
}
|
|
207
|
+
return DEFAULT_ESLINT_REACT_SETTINGS;
|
|
208
|
+
};
|
|
209
|
+
var normalizeSettings = ({
|
|
210
|
+
additionalComponents = [],
|
|
211
|
+
additionalHooks = {},
|
|
212
|
+
importSource = "react",
|
|
213
|
+
polymorphicPropName = "as",
|
|
214
|
+
skipImportCheck = true,
|
|
215
|
+
strict = true,
|
|
216
|
+
version,
|
|
217
|
+
...rest
|
|
218
|
+
}) => {
|
|
189
219
|
return {
|
|
190
|
-
...
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}) => {
|
|
205
|
-
return {
|
|
206
|
-
...rest,
|
|
207
|
-
additionalComponents: additionalComponents.map(({
|
|
208
|
-
name,
|
|
209
|
-
as = name,
|
|
210
|
-
attributes = [],
|
|
211
|
-
...rest2
|
|
212
|
-
}) => ({
|
|
213
|
-
...rest2,
|
|
214
|
-
name,
|
|
215
|
-
as,
|
|
216
|
-
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
217
|
-
...rest3,
|
|
218
|
-
name: name2,
|
|
219
|
-
as: as2
|
|
220
|
-
})),
|
|
221
|
-
re: RegExp.toRegExp(name)
|
|
220
|
+
...rest,
|
|
221
|
+
additionalComponents: additionalComponents.map(({
|
|
222
|
+
name,
|
|
223
|
+
as = name,
|
|
224
|
+
attributes = [],
|
|
225
|
+
...rest2
|
|
226
|
+
}) => ({
|
|
227
|
+
...rest2,
|
|
228
|
+
name,
|
|
229
|
+
as,
|
|
230
|
+
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
231
|
+
...rest3,
|
|
232
|
+
name: name2,
|
|
233
|
+
as: as2
|
|
222
234
|
})),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
re: RegExp.toRegExp(name)
|
|
236
|
+
})),
|
|
237
|
+
additionalHooks,
|
|
238
|
+
importSource,
|
|
239
|
+
polymorphicPropName,
|
|
240
|
+
skipImportCheck,
|
|
241
|
+
strict,
|
|
242
|
+
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(identity)
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
var cache = /* @__PURE__ */ new Map();
|
|
232
246
|
function getSettingsFromContext(context) {
|
|
233
|
-
|
|
247
|
+
const settings = context.settings;
|
|
248
|
+
return getOrElseUpdate(
|
|
249
|
+
cache,
|
|
250
|
+
settings["react-x"],
|
|
251
|
+
() => normalizeSettings(decodeSettings(settings["react-x"]))
|
|
252
|
+
);
|
|
234
253
|
}
|
|
235
254
|
var defineSettings = identity;
|
|
236
255
|
|
|
237
|
-
export { CustomComponentPropSchema, CustomComponentSchema, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext,
|
|
256
|
+
export { CustomComponentPropSchema, CustomComponentSchema, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.1",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -37,11 +37,9 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@typescript-eslint/utils": "^8.30.1",
|
|
39
39
|
"@zod/mini": "^4.0.0-beta.0",
|
|
40
|
-
"fast-equals": "^5.2.2",
|
|
41
|
-
"micro-memoize": "^4.1.3",
|
|
42
40
|
"ts-pattern": "^5.7.0",
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
41
|
+
"@eslint-react/eff": "1.48.1",
|
|
42
|
+
"@eslint-react/kit": "1.48.1"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"@tsconfig/node22": "^22.0.1",
|