@eslint-react/shared 1.24.0-next.0 → 1.24.0-next.11
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 +168 -170
- package/dist/index.d.ts +168 -170
- package/dist/index.js +78 -97
- package/dist/index.mjs +76 -94
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -417,29 +417,6 @@ function boolean(message) {
|
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
// @__NO_SIDE_EFFECTS__
|
|
420
|
-
function instance(class_, message) {
|
|
421
|
-
return {
|
|
422
|
-
kind: "schema",
|
|
423
|
-
type: "instance",
|
|
424
|
-
reference: instance,
|
|
425
|
-
expects: class_.name,
|
|
426
|
-
async: false,
|
|
427
|
-
class: class_,
|
|
428
|
-
message,
|
|
429
|
-
get "~standard"() {
|
|
430
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
431
|
-
},
|
|
432
|
-
"~run"(dataset, config2) {
|
|
433
|
-
if (dataset.value instanceof this.class) {
|
|
434
|
-
dataset.typed = true;
|
|
435
|
-
} else {
|
|
436
|
-
_addIssue(this, "type", dataset, config2);
|
|
437
|
-
}
|
|
438
|
-
return dataset;
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
// @__NO_SIDE_EFFECTS__
|
|
443
420
|
function object(entries, message) {
|
|
444
421
|
return {
|
|
445
422
|
kind: "schema",
|
|
@@ -557,30 +534,27 @@ function parse(schema, input, config2) {
|
|
|
557
534
|
}
|
|
558
535
|
|
|
559
536
|
// src/schemas.ts
|
|
560
|
-
var
|
|
561
|
-
// TODO: Define the schema for custom Hooks
|
|
562
|
-
});
|
|
563
|
-
var CustomAttributeSchema = object({
|
|
537
|
+
var CustomComponentPropSchema = object({
|
|
564
538
|
/**
|
|
565
|
-
* The name of the
|
|
539
|
+
* The name of the prop in the user-defined component.
|
|
566
540
|
* @example
|
|
567
541
|
* "to"
|
|
568
542
|
*/
|
|
569
543
|
name: string(),
|
|
570
544
|
/**
|
|
571
|
-
* The name of the
|
|
545
|
+
* The name of the prop in the built-in component.
|
|
572
546
|
* @example
|
|
573
547
|
* "href"
|
|
574
548
|
*/
|
|
575
549
|
as: optional(string()),
|
|
576
550
|
/**
|
|
577
|
-
* Whether the
|
|
551
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
578
552
|
* @example
|
|
579
553
|
* `true`
|
|
580
554
|
*/
|
|
581
555
|
controlled: optional(boolean()),
|
|
582
556
|
/**
|
|
583
|
-
* The default value of the
|
|
557
|
+
* The default value of the prop in the user-defined component.
|
|
584
558
|
* @example
|
|
585
559
|
* `"/"`
|
|
586
560
|
*/
|
|
@@ -595,6 +569,7 @@ var CustomComponentSchema = object({
|
|
|
595
569
|
name: string(),
|
|
596
570
|
/**
|
|
597
571
|
* The ESQuery selector to select the component precisely.
|
|
572
|
+
* @internal
|
|
598
573
|
* @example
|
|
599
574
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
600
575
|
*/
|
|
@@ -606,18 +581,32 @@ var CustomComponentSchema = object({
|
|
|
606
581
|
*/
|
|
607
582
|
as: optional(string()),
|
|
608
583
|
/**
|
|
609
|
-
*
|
|
584
|
+
* Attributes mapping between the user-defined component and the built-in component.
|
|
610
585
|
* @example
|
|
611
586
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
612
587
|
*/
|
|
613
|
-
attributes: optional(array(
|
|
588
|
+
attributes: optional(array(CustomComponentPropSchema))
|
|
614
589
|
});
|
|
615
|
-
var
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
590
|
+
var CustomHooksSchema = object({
|
|
591
|
+
use: optional(array(string())),
|
|
592
|
+
useActionState: optional(array(string())),
|
|
593
|
+
useCallback: optional(array(string())),
|
|
594
|
+
useContext: optional(array(string())),
|
|
595
|
+
useDebugValue: optional(array(string())),
|
|
596
|
+
useDeferredValue: optional(array(string())),
|
|
597
|
+
useEffect: optional(array(string())),
|
|
598
|
+
useFormStatus: optional(array(string())),
|
|
599
|
+
useId: optional(array(string())),
|
|
600
|
+
useImperativeHandle: optional(array(string())),
|
|
601
|
+
useInsertionEffect: optional(array(string())),
|
|
602
|
+
useLayoutEffect: optional(array(string())),
|
|
603
|
+
useMemo: optional(array(string())),
|
|
604
|
+
useOptimistic: optional(array(string())),
|
|
605
|
+
useReducer: optional(array(string())),
|
|
606
|
+
useRef: optional(array(string())),
|
|
607
|
+
useState: optional(array(string())),
|
|
608
|
+
useSyncExternalStore: optional(array(string())),
|
|
609
|
+
useTransition: optional(array(string()))
|
|
621
610
|
});
|
|
622
611
|
var ESLintReactSettingsSchema = object({
|
|
623
612
|
/**
|
|
@@ -626,41 +615,41 @@ var ESLintReactSettingsSchema = object({
|
|
|
626
615
|
* @default `"react"`
|
|
627
616
|
* @example `"@pika/react"`
|
|
628
617
|
*/
|
|
629
|
-
importSource: optional(string()),
|
|
618
|
+
importSource: optional(string(), "react"),
|
|
630
619
|
/**
|
|
631
620
|
* The identifier that’s used for JSX Element creation.
|
|
632
621
|
* @default `"createElement"`
|
|
633
622
|
* @deprecated
|
|
634
623
|
*/
|
|
635
|
-
jsxPragma: optional(string()),
|
|
624
|
+
jsxPragma: optional(string(), "createElement"),
|
|
636
625
|
/**
|
|
637
626
|
* The identifier that’s used for JSX fragment elements.
|
|
638
627
|
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
639
628
|
* @default `"Fragment"`
|
|
640
629
|
* @deprecated
|
|
641
630
|
*/
|
|
642
|
-
jsxPragmaFrag: optional(string()),
|
|
631
|
+
jsxPragmaFrag: optional(string(), "Fragment"),
|
|
643
632
|
/**
|
|
644
633
|
* The name of the prop that is used for polymorphic components.
|
|
645
634
|
* @description This is used to determine the type of the component.
|
|
646
635
|
* @example `"as"`
|
|
647
636
|
*/
|
|
648
|
-
polymorphicPropName: optional(string()),
|
|
637
|
+
polymorphicPropName: optional(string(), "as"),
|
|
649
638
|
/**
|
|
650
639
|
* @internal
|
|
651
640
|
*/
|
|
652
|
-
strict: optional(boolean()),
|
|
641
|
+
strict: optional(boolean(), false),
|
|
653
642
|
/**
|
|
654
643
|
* @internal
|
|
655
644
|
*/
|
|
656
|
-
strictImportCheck: optional(boolean()),
|
|
645
|
+
strictImportCheck: optional(boolean(), false),
|
|
657
646
|
/**
|
|
658
647
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
659
648
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
660
649
|
* @example `"18.3.1"`
|
|
661
650
|
* @default `"detect"`
|
|
662
651
|
*/
|
|
663
|
-
version: optional(string()),
|
|
652
|
+
version: optional(string(), "detect"),
|
|
664
653
|
/**
|
|
665
654
|
* An array of user-defined components
|
|
666
655
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
@@ -668,31 +657,11 @@ var ESLintReactSettingsSchema = object({
|
|
|
668
657
|
*/
|
|
669
658
|
additionalComponents: optional(array(CustomComponentSchema)),
|
|
670
659
|
/**
|
|
671
|
-
* A object
|
|
660
|
+
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
672
661
|
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
673
662
|
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
674
663
|
*/
|
|
675
|
-
additionalHooks: optional(
|
|
676
|
-
use: optional(array(string())),
|
|
677
|
-
useActionState: optional(array(string())),
|
|
678
|
-
useCallback: optional(array(string())),
|
|
679
|
-
useContext: optional(array(string())),
|
|
680
|
-
useDebugValue: optional(array(string())),
|
|
681
|
-
useDeferredValue: optional(array(string())),
|
|
682
|
-
useEffect: optional(array(string())),
|
|
683
|
-
useFormStatus: optional(array(string())),
|
|
684
|
-
useId: optional(array(string())),
|
|
685
|
-
useImperativeHandle: optional(array(string())),
|
|
686
|
-
useInsertionEffect: optional(array(string())),
|
|
687
|
-
useLayoutEffect: optional(array(string())),
|
|
688
|
-
useMemo: optional(array(string())),
|
|
689
|
-
useOptimistic: optional(array(string())),
|
|
690
|
-
useReducer: optional(array(string())),
|
|
691
|
-
useRef: optional(array(string())),
|
|
692
|
-
useState: optional(array(string())),
|
|
693
|
-
useSyncExternalStore: optional(array(string())),
|
|
694
|
-
useTransition: optional(array(string()))
|
|
695
|
-
}))
|
|
664
|
+
additionalHooks: optional(CustomHooksSchema)
|
|
696
665
|
});
|
|
697
666
|
var ESLintSettingsSchema = optional(
|
|
698
667
|
object({
|
|
@@ -702,6 +671,12 @@ var ESLintSettingsSchema = optional(
|
|
|
702
671
|
}),
|
|
703
672
|
{}
|
|
704
673
|
);
|
|
674
|
+
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
675
|
+
...parse(ESLintReactSettingsSchema, {}),
|
|
676
|
+
additionalHooks: {
|
|
677
|
+
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
678
|
+
}
|
|
679
|
+
};
|
|
705
680
|
|
|
706
681
|
// ../../node_modules/.pnpm/fast-equals@5.2.2/node_modules/fast-equals/dist/esm/index.mjs
|
|
707
682
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
@@ -1396,14 +1371,6 @@ function createMemoizedFunction(fn, options) {
|
|
|
1396
1371
|
memoized.options = normalizedOptions;
|
|
1397
1372
|
return memoized;
|
|
1398
1373
|
}
|
|
1399
|
-
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
1400
|
-
additionalHooks: {
|
|
1401
|
-
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
1402
|
-
},
|
|
1403
|
-
polymorphicPropName: "as",
|
|
1404
|
-
strictImportCheck: false,
|
|
1405
|
-
version: "detect"
|
|
1406
|
-
};
|
|
1407
1374
|
function unsafeDecodeSettings(data) {
|
|
1408
1375
|
return data?.["react-x"] ?? {};
|
|
1409
1376
|
}
|
|
@@ -1413,31 +1380,45 @@ var decodeSettings = createMemoizedFunction((data) => {
|
|
|
1413
1380
|
...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
|
|
1414
1381
|
};
|
|
1415
1382
|
}, { isEqual: (a, b) => a === b });
|
|
1416
|
-
var
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1383
|
+
var toNormalizedSettings = createMemoizedFunction(
|
|
1384
|
+
({
|
|
1385
|
+
additionalComponents = [],
|
|
1386
|
+
additionalHooks = {},
|
|
1387
|
+
version,
|
|
1388
|
+
...rest
|
|
1389
|
+
}) => {
|
|
1390
|
+
return {
|
|
1391
|
+
...rest,
|
|
1392
|
+
additionalComponents: additionalComponents.map(({
|
|
1393
|
+
name,
|
|
1394
|
+
as = name,
|
|
1395
|
+
attributes = [],
|
|
1396
|
+
...rest2
|
|
1397
|
+
}) => ({
|
|
1398
|
+
...rest2,
|
|
1399
|
+
name,
|
|
1400
|
+
as,
|
|
1401
|
+
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
1402
|
+
...rest3,
|
|
1403
|
+
name: name2,
|
|
1404
|
+
as: as2
|
|
1405
|
+
})),
|
|
1406
|
+
re: pm__default.default.makeRe(name, { fastpaths: true })
|
|
1407
|
+
})),
|
|
1408
|
+
additionalHooks,
|
|
1409
|
+
version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(eff.identity)
|
|
1410
|
+
};
|
|
1411
|
+
},
|
|
1412
|
+
{ isEqual: shallowEqual }
|
|
1413
|
+
);
|
|
1432
1414
|
function getSettingsFromContext(context) {
|
|
1433
|
-
return
|
|
1415
|
+
return toNormalizedSettings(decodeSettings(context.settings));
|
|
1434
1416
|
}
|
|
1435
1417
|
var defineSettings = eff.identity;
|
|
1436
1418
|
|
|
1437
|
-
exports.
|
|
1438
|
-
exports.CustomComponentNormalizedSchema = CustomComponentNormalizedSchema;
|
|
1419
|
+
exports.CustomComponentPropSchema = CustomComponentPropSchema;
|
|
1439
1420
|
exports.CustomComponentSchema = CustomComponentSchema;
|
|
1440
|
-
exports.
|
|
1421
|
+
exports.CustomHooksSchema = CustomHooksSchema;
|
|
1441
1422
|
exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
|
|
1442
1423
|
exports.DOM_HTML_COMPONENT_TYPES = DOM_HTML_COMPONENT_TYPES;
|
|
1443
1424
|
exports.DOM_SVG_COMPONENT_TYPES = DOM_SVG_COMPONENT_TYPES;
|
|
@@ -1458,5 +1439,5 @@ exports.decodeSettings = decodeSettings;
|
|
|
1458
1439
|
exports.defineSettings = defineSettings;
|
|
1459
1440
|
exports.getReactVersion = getReactVersion;
|
|
1460
1441
|
exports.getSettingsFromContext = getSettingsFromContext;
|
|
1461
|
-
exports.
|
|
1442
|
+
exports.toNormalizedSettings = toNormalizedSettings;
|
|
1462
1443
|
exports.unsafeDecodeSettings = unsafeDecodeSettings;
|
package/dist/index.mjs
CHANGED
|
@@ -409,29 +409,6 @@ function boolean(message) {
|
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
// @__NO_SIDE_EFFECTS__
|
|
412
|
-
function instance(class_, message) {
|
|
413
|
-
return {
|
|
414
|
-
kind: "schema",
|
|
415
|
-
type: "instance",
|
|
416
|
-
reference: instance,
|
|
417
|
-
expects: class_.name,
|
|
418
|
-
async: false,
|
|
419
|
-
class: class_,
|
|
420
|
-
message,
|
|
421
|
-
get "~standard"() {
|
|
422
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
423
|
-
},
|
|
424
|
-
"~run"(dataset, config2) {
|
|
425
|
-
if (dataset.value instanceof this.class) {
|
|
426
|
-
dataset.typed = true;
|
|
427
|
-
} else {
|
|
428
|
-
_addIssue(this, "type", dataset, config2);
|
|
429
|
-
}
|
|
430
|
-
return dataset;
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
// @__NO_SIDE_EFFECTS__
|
|
435
412
|
function object(entries, message) {
|
|
436
413
|
return {
|
|
437
414
|
kind: "schema",
|
|
@@ -549,30 +526,27 @@ function parse(schema, input, config2) {
|
|
|
549
526
|
}
|
|
550
527
|
|
|
551
528
|
// src/schemas.ts
|
|
552
|
-
var
|
|
553
|
-
// TODO: Define the schema for custom Hooks
|
|
554
|
-
});
|
|
555
|
-
var CustomAttributeSchema = object({
|
|
529
|
+
var CustomComponentPropSchema = object({
|
|
556
530
|
/**
|
|
557
|
-
* The name of the
|
|
531
|
+
* The name of the prop in the user-defined component.
|
|
558
532
|
* @example
|
|
559
533
|
* "to"
|
|
560
534
|
*/
|
|
561
535
|
name: string(),
|
|
562
536
|
/**
|
|
563
|
-
* The name of the
|
|
537
|
+
* The name of the prop in the built-in component.
|
|
564
538
|
* @example
|
|
565
539
|
* "href"
|
|
566
540
|
*/
|
|
567
541
|
as: optional(string()),
|
|
568
542
|
/**
|
|
569
|
-
* Whether the
|
|
543
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
570
544
|
* @example
|
|
571
545
|
* `true`
|
|
572
546
|
*/
|
|
573
547
|
controlled: optional(boolean()),
|
|
574
548
|
/**
|
|
575
|
-
* The default value of the
|
|
549
|
+
* The default value of the prop in the user-defined component.
|
|
576
550
|
* @example
|
|
577
551
|
* `"/"`
|
|
578
552
|
*/
|
|
@@ -587,6 +561,7 @@ var CustomComponentSchema = object({
|
|
|
587
561
|
name: string(),
|
|
588
562
|
/**
|
|
589
563
|
* The ESQuery selector to select the component precisely.
|
|
564
|
+
* @internal
|
|
590
565
|
* @example
|
|
591
566
|
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
592
567
|
*/
|
|
@@ -598,18 +573,32 @@ var CustomComponentSchema = object({
|
|
|
598
573
|
*/
|
|
599
574
|
as: optional(string()),
|
|
600
575
|
/**
|
|
601
|
-
*
|
|
576
|
+
* Attributes mapping between the user-defined component and the built-in component.
|
|
602
577
|
* @example
|
|
603
578
|
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
604
579
|
*/
|
|
605
|
-
attributes: optional(array(
|
|
580
|
+
attributes: optional(array(CustomComponentPropSchema))
|
|
606
581
|
});
|
|
607
|
-
var
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
582
|
+
var CustomHooksSchema = object({
|
|
583
|
+
use: optional(array(string())),
|
|
584
|
+
useActionState: optional(array(string())),
|
|
585
|
+
useCallback: optional(array(string())),
|
|
586
|
+
useContext: optional(array(string())),
|
|
587
|
+
useDebugValue: optional(array(string())),
|
|
588
|
+
useDeferredValue: optional(array(string())),
|
|
589
|
+
useEffect: optional(array(string())),
|
|
590
|
+
useFormStatus: optional(array(string())),
|
|
591
|
+
useId: optional(array(string())),
|
|
592
|
+
useImperativeHandle: optional(array(string())),
|
|
593
|
+
useInsertionEffect: optional(array(string())),
|
|
594
|
+
useLayoutEffect: optional(array(string())),
|
|
595
|
+
useMemo: optional(array(string())),
|
|
596
|
+
useOptimistic: optional(array(string())),
|
|
597
|
+
useReducer: optional(array(string())),
|
|
598
|
+
useRef: optional(array(string())),
|
|
599
|
+
useState: optional(array(string())),
|
|
600
|
+
useSyncExternalStore: optional(array(string())),
|
|
601
|
+
useTransition: optional(array(string()))
|
|
613
602
|
});
|
|
614
603
|
var ESLintReactSettingsSchema = object({
|
|
615
604
|
/**
|
|
@@ -618,41 +607,41 @@ var ESLintReactSettingsSchema = object({
|
|
|
618
607
|
* @default `"react"`
|
|
619
608
|
* @example `"@pika/react"`
|
|
620
609
|
*/
|
|
621
|
-
importSource: optional(string()),
|
|
610
|
+
importSource: optional(string(), "react"),
|
|
622
611
|
/**
|
|
623
612
|
* The identifier that’s used for JSX Element creation.
|
|
624
613
|
* @default `"createElement"`
|
|
625
614
|
* @deprecated
|
|
626
615
|
*/
|
|
627
|
-
jsxPragma: optional(string()),
|
|
616
|
+
jsxPragma: optional(string(), "createElement"),
|
|
628
617
|
/**
|
|
629
618
|
* The identifier that’s used for JSX fragment elements.
|
|
630
619
|
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
631
620
|
* @default `"Fragment"`
|
|
632
621
|
* @deprecated
|
|
633
622
|
*/
|
|
634
|
-
jsxPragmaFrag: optional(string()),
|
|
623
|
+
jsxPragmaFrag: optional(string(), "Fragment"),
|
|
635
624
|
/**
|
|
636
625
|
* The name of the prop that is used for polymorphic components.
|
|
637
626
|
* @description This is used to determine the type of the component.
|
|
638
627
|
* @example `"as"`
|
|
639
628
|
*/
|
|
640
|
-
polymorphicPropName: optional(string()),
|
|
629
|
+
polymorphicPropName: optional(string(), "as"),
|
|
641
630
|
/**
|
|
642
631
|
* @internal
|
|
643
632
|
*/
|
|
644
|
-
strict: optional(boolean()),
|
|
633
|
+
strict: optional(boolean(), false),
|
|
645
634
|
/**
|
|
646
635
|
* @internal
|
|
647
636
|
*/
|
|
648
|
-
strictImportCheck: optional(boolean()),
|
|
637
|
+
strictImportCheck: optional(boolean(), false),
|
|
649
638
|
/**
|
|
650
639
|
* React version to use, "detect" means auto detect React version from the project’s dependencies.
|
|
651
640
|
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
652
641
|
* @example `"18.3.1"`
|
|
653
642
|
* @default `"detect"`
|
|
654
643
|
*/
|
|
655
|
-
version: optional(string()),
|
|
644
|
+
version: optional(string(), "detect"),
|
|
656
645
|
/**
|
|
657
646
|
* An array of user-defined components
|
|
658
647
|
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
@@ -660,31 +649,11 @@ var ESLintReactSettingsSchema = object({
|
|
|
660
649
|
*/
|
|
661
650
|
additionalComponents: optional(array(CustomComponentSchema)),
|
|
662
651
|
/**
|
|
663
|
-
* A object
|
|
652
|
+
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
664
653
|
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
665
654
|
* @example `{ useLayoutEffect: ["useIsomorphicLayoutEffect"] }`
|
|
666
655
|
*/
|
|
667
|
-
additionalHooks: optional(
|
|
668
|
-
use: optional(array(string())),
|
|
669
|
-
useActionState: optional(array(string())),
|
|
670
|
-
useCallback: optional(array(string())),
|
|
671
|
-
useContext: optional(array(string())),
|
|
672
|
-
useDebugValue: optional(array(string())),
|
|
673
|
-
useDeferredValue: optional(array(string())),
|
|
674
|
-
useEffect: optional(array(string())),
|
|
675
|
-
useFormStatus: optional(array(string())),
|
|
676
|
-
useId: optional(array(string())),
|
|
677
|
-
useImperativeHandle: optional(array(string())),
|
|
678
|
-
useInsertionEffect: optional(array(string())),
|
|
679
|
-
useLayoutEffect: optional(array(string())),
|
|
680
|
-
useMemo: optional(array(string())),
|
|
681
|
-
useOptimistic: optional(array(string())),
|
|
682
|
-
useReducer: optional(array(string())),
|
|
683
|
-
useRef: optional(array(string())),
|
|
684
|
-
useState: optional(array(string())),
|
|
685
|
-
useSyncExternalStore: optional(array(string())),
|
|
686
|
-
useTransition: optional(array(string()))
|
|
687
|
-
}))
|
|
656
|
+
additionalHooks: optional(CustomHooksSchema)
|
|
688
657
|
});
|
|
689
658
|
var ESLintSettingsSchema = optional(
|
|
690
659
|
object({
|
|
@@ -694,6 +663,12 @@ var ESLintSettingsSchema = optional(
|
|
|
694
663
|
}),
|
|
695
664
|
{}
|
|
696
665
|
);
|
|
666
|
+
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
667
|
+
...parse(ESLintReactSettingsSchema, {}),
|
|
668
|
+
additionalHooks: {
|
|
669
|
+
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
670
|
+
}
|
|
671
|
+
};
|
|
697
672
|
|
|
698
673
|
// ../../node_modules/.pnpm/fast-equals@5.2.2/node_modules/fast-equals/dist/esm/index.mjs
|
|
699
674
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
@@ -1388,14 +1363,6 @@ function createMemoizedFunction(fn, options) {
|
|
|
1388
1363
|
memoized.options = normalizedOptions;
|
|
1389
1364
|
return memoized;
|
|
1390
1365
|
}
|
|
1391
|
-
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
1392
|
-
additionalHooks: {
|
|
1393
|
-
useLayoutEffect: ["useIsomorphicLayoutEffect"]
|
|
1394
|
-
},
|
|
1395
|
-
polymorphicPropName: "as",
|
|
1396
|
-
strictImportCheck: false,
|
|
1397
|
-
version: "detect"
|
|
1398
|
-
};
|
|
1399
1366
|
function unsafeDecodeSettings(data) {
|
|
1400
1367
|
return data?.["react-x"] ?? {};
|
|
1401
1368
|
}
|
|
@@ -1405,25 +1372,40 @@ var decodeSettings = createMemoizedFunction((data) => {
|
|
|
1405
1372
|
...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
|
|
1406
1373
|
};
|
|
1407
1374
|
}, { isEqual: (a, b) => a === b });
|
|
1408
|
-
var
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1375
|
+
var toNormalizedSettings = createMemoizedFunction(
|
|
1376
|
+
({
|
|
1377
|
+
additionalComponents = [],
|
|
1378
|
+
additionalHooks = {},
|
|
1379
|
+
version,
|
|
1380
|
+
...rest
|
|
1381
|
+
}) => {
|
|
1382
|
+
return {
|
|
1383
|
+
...rest,
|
|
1384
|
+
additionalComponents: additionalComponents.map(({
|
|
1385
|
+
name,
|
|
1386
|
+
as = name,
|
|
1387
|
+
attributes = [],
|
|
1388
|
+
...rest2
|
|
1389
|
+
}) => ({
|
|
1390
|
+
...rest2,
|
|
1391
|
+
name,
|
|
1392
|
+
as,
|
|
1393
|
+
attributes: attributes.map(({ name: name2, as: as2 = name2, ...rest3 }) => ({
|
|
1394
|
+
...rest3,
|
|
1395
|
+
name: name2,
|
|
1396
|
+
as: as2
|
|
1397
|
+
})),
|
|
1398
|
+
re: pm.makeRe(name, { fastpaths: true })
|
|
1399
|
+
})),
|
|
1400
|
+
additionalHooks,
|
|
1401
|
+
version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(identity)
|
|
1402
|
+
};
|
|
1403
|
+
},
|
|
1404
|
+
{ isEqual: shallowEqual }
|
|
1405
|
+
);
|
|
1424
1406
|
function getSettingsFromContext(context) {
|
|
1425
|
-
return
|
|
1407
|
+
return toNormalizedSettings(decodeSettings(context.settings));
|
|
1426
1408
|
}
|
|
1427
1409
|
var defineSettings = identity;
|
|
1428
1410
|
|
|
1429
|
-
export {
|
|
1411
|
+
export { CustomComponentPropSchema, CustomComponentSchema, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DOM_HTML_COMPONENT_TYPES, DOM_SVG_COMPONENT_TYPES, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, defineSettings, getReactVersion, getSettingsFromContext, toNormalizedSettings, unsafeDecodeSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.11",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"./package.json"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@typescript-eslint/utils": "^8.
|
|
36
|
+
"@typescript-eslint/utils": "^8.20.0",
|
|
37
37
|
"picomatch": "^4.0.2",
|
|
38
38
|
"ts-pattern": "^5.6.0",
|
|
39
|
-
"@eslint-react/eff": "1.24.0-next.
|
|
39
|
+
"@eslint-react/eff": "1.24.0-next.11"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/picomatch": "^3.0.1",
|