@eslint-react/shared 1.23.2-next.2 → 1.23.2-next.3
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 +5 -147
- package/dist/index.d.ts +5 -147
- package/dist/index.js +14 -18
- package/dist/index.mjs +16 -18
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -583,140 +583,6 @@ interface ESLintReactSettingsNormalized extends ESLintReactSettings {
|
|
|
583
583
|
version: string;
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
/**
|
|
587
|
-
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
588
|
-
|
|
589
|
-
@category Type
|
|
590
|
-
*/
|
|
591
|
-
type Primitive =
|
|
592
|
-
| null
|
|
593
|
-
| undefined
|
|
594
|
-
| string
|
|
595
|
-
| number
|
|
596
|
-
| boolean
|
|
597
|
-
| symbol
|
|
598
|
-
| bigint;
|
|
599
|
-
|
|
600
|
-
declare global {
|
|
601
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
602
|
-
interface SymbolConstructor {
|
|
603
|
-
readonly observable: symbol;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
609
|
-
*/
|
|
610
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
@see PartialDeep
|
|
614
|
-
*/
|
|
615
|
-
type PartialDeepOptions = {
|
|
616
|
-
/**
|
|
617
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
618
|
-
|
|
619
|
-
@default false
|
|
620
|
-
*/
|
|
621
|
-
readonly recurseIntoArrays?: boolean;
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
626
|
-
|
|
627
|
-
Use-cases:
|
|
628
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
629
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
630
|
-
|
|
631
|
-
@example
|
|
632
|
-
```
|
|
633
|
-
import type {PartialDeep} from 'type-fest';
|
|
634
|
-
|
|
635
|
-
const settings: Settings = {
|
|
636
|
-
textEditor: {
|
|
637
|
-
fontSize: 14;
|
|
638
|
-
fontColor: '#000000';
|
|
639
|
-
fontWeight: 400;
|
|
640
|
-
}
|
|
641
|
-
autocomplete: false;
|
|
642
|
-
autosave: true;
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
|
|
646
|
-
return {...settings, ...savedSettings};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
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:
|
|
653
|
-
|
|
654
|
-
```
|
|
655
|
-
import type {PartialDeep} from 'type-fest';
|
|
656
|
-
|
|
657
|
-
interface Settings {
|
|
658
|
-
languages: string[];
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
662
|
-
languages: [undefined]
|
|
663
|
-
};
|
|
664
|
-
```
|
|
665
|
-
|
|
666
|
-
@category Object
|
|
667
|
-
@category Array
|
|
668
|
-
@category Set
|
|
669
|
-
@category Map
|
|
670
|
-
*/
|
|
671
|
-
type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
|
|
672
|
-
? T
|
|
673
|
-
: T extends Map<infer KeyType, infer ValueType>
|
|
674
|
-
? PartialMapDeep<KeyType, ValueType, Options>
|
|
675
|
-
: T extends Set<infer ItemType>
|
|
676
|
-
? PartialSetDeep<ItemType, Options>
|
|
677
|
-
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
678
|
-
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
|
|
679
|
-
: T extends ReadonlySet<infer ItemType>
|
|
680
|
-
? PartialReadonlySetDeep<ItemType, Options>
|
|
681
|
-
: T extends object
|
|
682
|
-
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
683
|
-
? Options['recurseIntoArrays'] extends true
|
|
684
|
-
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
685
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
686
|
-
? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
|
|
687
|
-
: Array<PartialDeep<ItemType | undefined, Options>>
|
|
688
|
-
: PartialObjectDeep<T, Options> // Tuples behave properly
|
|
689
|
-
: T // If they don't opt into array testing, just use the original type
|
|
690
|
-
: PartialObjectDeep<T, Options>
|
|
691
|
-
: unknown;
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
695
|
-
*/
|
|
696
|
-
type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
700
|
-
*/
|
|
701
|
-
type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
705
|
-
*/
|
|
706
|
-
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
710
|
-
*/
|
|
711
|
-
type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
715
|
-
*/
|
|
716
|
-
type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
|
|
717
|
-
[KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
|
|
718
|
-
};
|
|
719
|
-
|
|
720
586
|
/**
|
|
721
587
|
* The default ESLint settings for "react-x".
|
|
722
588
|
*/
|
|
@@ -729,19 +595,11 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
|
729
595
|
readonly version: "detect";
|
|
730
596
|
};
|
|
731
597
|
/**
|
|
732
|
-
*
|
|
733
|
-
* @
|
|
734
|
-
* @param
|
|
735
|
-
* @returns
|
|
736
|
-
*/
|
|
737
|
-
declare function unsafeReadSettings(data: unknown): PartialDeep<ESLintReactSettings>;
|
|
738
|
-
/**
|
|
739
|
-
* Normalizes the settings by converting all shorthand properties to their full form.
|
|
740
|
-
* @param data The raw settings.
|
|
741
|
-
* @returns The normalized settings.
|
|
742
|
-
* @internal
|
|
598
|
+
* Get the normalized ESLint settings for "react-x" from the given context.
|
|
599
|
+
* @param context The context.
|
|
600
|
+
* @param context.settings The ESLint settings.
|
|
601
|
+
* @returns The normalized ESLint settings.
|
|
743
602
|
*/
|
|
744
|
-
declare function normalizeSettings(data: unknown): ESLintReactSettingsNormalized;
|
|
745
603
|
declare function getSettingsFromContext(context: {
|
|
746
604
|
settings: unknown;
|
|
747
605
|
}): ESLintReactSettingsNormalized;
|
|
@@ -757,4 +615,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
757
615
|
}
|
|
758
616
|
}
|
|
759
617
|
|
|
760
|
-
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, defineSettings, getReactVersion, getSettingsFromContext
|
|
618
|
+
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, defineSettings, getReactVersion, getSettingsFromContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -583,140 +583,6 @@ interface ESLintReactSettingsNormalized extends ESLintReactSettings {
|
|
|
583
583
|
version: string;
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
/**
|
|
587
|
-
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
588
|
-
|
|
589
|
-
@category Type
|
|
590
|
-
*/
|
|
591
|
-
type Primitive =
|
|
592
|
-
| null
|
|
593
|
-
| undefined
|
|
594
|
-
| string
|
|
595
|
-
| number
|
|
596
|
-
| boolean
|
|
597
|
-
| symbol
|
|
598
|
-
| bigint;
|
|
599
|
-
|
|
600
|
-
declare global {
|
|
601
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
602
|
-
interface SymbolConstructor {
|
|
603
|
-
readonly observable: symbol;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
609
|
-
*/
|
|
610
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
@see PartialDeep
|
|
614
|
-
*/
|
|
615
|
-
type PartialDeepOptions = {
|
|
616
|
-
/**
|
|
617
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
618
|
-
|
|
619
|
-
@default false
|
|
620
|
-
*/
|
|
621
|
-
readonly recurseIntoArrays?: boolean;
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
626
|
-
|
|
627
|
-
Use-cases:
|
|
628
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
629
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
630
|
-
|
|
631
|
-
@example
|
|
632
|
-
```
|
|
633
|
-
import type {PartialDeep} from 'type-fest';
|
|
634
|
-
|
|
635
|
-
const settings: Settings = {
|
|
636
|
-
textEditor: {
|
|
637
|
-
fontSize: 14;
|
|
638
|
-
fontColor: '#000000';
|
|
639
|
-
fontWeight: 400;
|
|
640
|
-
}
|
|
641
|
-
autocomplete: false;
|
|
642
|
-
autosave: true;
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
|
|
646
|
-
return {...settings, ...savedSettings};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
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:
|
|
653
|
-
|
|
654
|
-
```
|
|
655
|
-
import type {PartialDeep} from 'type-fest';
|
|
656
|
-
|
|
657
|
-
interface Settings {
|
|
658
|
-
languages: string[];
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
|
|
662
|
-
languages: [undefined]
|
|
663
|
-
};
|
|
664
|
-
```
|
|
665
|
-
|
|
666
|
-
@category Object
|
|
667
|
-
@category Array
|
|
668
|
-
@category Set
|
|
669
|
-
@category Map
|
|
670
|
-
*/
|
|
671
|
-
type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
|
|
672
|
-
? T
|
|
673
|
-
: T extends Map<infer KeyType, infer ValueType>
|
|
674
|
-
? PartialMapDeep<KeyType, ValueType, Options>
|
|
675
|
-
: T extends Set<infer ItemType>
|
|
676
|
-
? PartialSetDeep<ItemType, Options>
|
|
677
|
-
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
678
|
-
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
|
|
679
|
-
: T extends ReadonlySet<infer ItemType>
|
|
680
|
-
? PartialReadonlySetDeep<ItemType, Options>
|
|
681
|
-
: T extends object
|
|
682
|
-
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
683
|
-
? Options['recurseIntoArrays'] extends true
|
|
684
|
-
? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
685
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
686
|
-
? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
|
|
687
|
-
: Array<PartialDeep<ItemType | undefined, Options>>
|
|
688
|
-
: PartialObjectDeep<T, Options> // Tuples behave properly
|
|
689
|
-
: T // If they don't opt into array testing, just use the original type
|
|
690
|
-
: PartialObjectDeep<T, Options>
|
|
691
|
-
: unknown;
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
695
|
-
*/
|
|
696
|
-
type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
700
|
-
*/
|
|
701
|
-
type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
705
|
-
*/
|
|
706
|
-
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
710
|
-
*/
|
|
711
|
-
type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
715
|
-
*/
|
|
716
|
-
type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
|
|
717
|
-
[KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
|
|
718
|
-
};
|
|
719
|
-
|
|
720
586
|
/**
|
|
721
587
|
* The default ESLint settings for "react-x".
|
|
722
588
|
*/
|
|
@@ -729,19 +595,11 @@ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
|
729
595
|
readonly version: "detect";
|
|
730
596
|
};
|
|
731
597
|
/**
|
|
732
|
-
*
|
|
733
|
-
* @
|
|
734
|
-
* @param
|
|
735
|
-
* @returns
|
|
736
|
-
*/
|
|
737
|
-
declare function unsafeReadSettings(data: unknown): PartialDeep<ESLintReactSettings>;
|
|
738
|
-
/**
|
|
739
|
-
* Normalizes the settings by converting all shorthand properties to their full form.
|
|
740
|
-
* @param data The raw settings.
|
|
741
|
-
* @returns The normalized settings.
|
|
742
|
-
* @internal
|
|
598
|
+
* Get the normalized ESLint settings for "react-x" from the given context.
|
|
599
|
+
* @param context The context.
|
|
600
|
+
* @param context.settings The ESLint settings.
|
|
601
|
+
* @returns The normalized ESLint settings.
|
|
743
602
|
*/
|
|
744
|
-
declare function normalizeSettings(data: unknown): ESLintReactSettingsNormalized;
|
|
745
603
|
declare function getSettingsFromContext(context: {
|
|
746
604
|
settings: unknown;
|
|
747
605
|
}): ESLintReactSettingsNormalized;
|
|
@@ -757,4 +615,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
|
|
|
757
615
|
}
|
|
758
616
|
}
|
|
759
617
|
|
|
760
|
-
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, defineSettings, getReactVersion, getSettingsFromContext
|
|
618
|
+
export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentNormalized, CustomComponentNormalizedSchema, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, defineSettings, getReactVersion, getSettingsFromContext };
|
package/dist/index.js
CHANGED
|
@@ -384,7 +384,7 @@ var ESLintSettingsSchema = valibot.optional(
|
|
|
384
384
|
);
|
|
385
385
|
|
|
386
386
|
// src/cache.ts
|
|
387
|
-
var normalizedSettingsCache = /* @__PURE__ */ new
|
|
387
|
+
var normalizedSettingsCache = /* @__PURE__ */ new WeakMap();
|
|
388
388
|
|
|
389
389
|
// src/settings.ts
|
|
390
390
|
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
@@ -395,19 +395,20 @@ var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
|
395
395
|
strictImportCheck: false,
|
|
396
396
|
version: "detect"
|
|
397
397
|
};
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
398
|
+
function getSettingsFromContext(context) {
|
|
399
|
+
valibot.assert(ESLintSettingsSchema, context.settings);
|
|
400
|
+
const raw = context.settings?.["react-x"] ?? {};
|
|
401
|
+
const memoized = normalizedSettingsCache.get(raw);
|
|
402
|
+
if (memoized) {
|
|
403
|
+
return memoized;
|
|
404
|
+
}
|
|
405
|
+
const rawWithDefaults = {
|
|
405
406
|
...DEFAULT_ESLINT_REACT_SETTINGS,
|
|
406
|
-
...
|
|
407
|
+
...raw
|
|
407
408
|
};
|
|
408
|
-
const additionalComponents =
|
|
409
|
+
const additionalComponents = rawWithDefaults.additionalComponents ?? [];
|
|
409
410
|
const normalized = {
|
|
410
|
-
...
|
|
411
|
+
...rawWithDefaults,
|
|
411
412
|
additionalComponents: additionalComponents.map((component) => ({
|
|
412
413
|
...component,
|
|
413
414
|
attributes: component.attributes?.map((attr) => ({
|
|
@@ -422,14 +423,11 @@ function normalizeSettings(data) {
|
|
|
422
423
|
if (!/^[\w-]+$/u.test(name)) return acc;
|
|
423
424
|
return acc.set(name, as);
|
|
424
425
|
}, /* @__PURE__ */ new Map()),
|
|
425
|
-
version: tsPattern.match(
|
|
426
|
+
version: tsPattern.match(rawWithDefaults.version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => eff.E.getOrElse(getReactVersion(), eff.F.constant("19.0.0"))).otherwise(eff.F.identity)
|
|
426
427
|
};
|
|
427
|
-
normalizedSettingsCache.set(
|
|
428
|
+
normalizedSettingsCache.set(raw, normalized);
|
|
428
429
|
return normalized;
|
|
429
430
|
}
|
|
430
|
-
function getSettingsFromContext(context) {
|
|
431
|
-
return normalizeSettings(context.settings);
|
|
432
|
-
}
|
|
433
431
|
var defineSettings = eff.F.identity;
|
|
434
432
|
|
|
435
433
|
exports.CustomAttributeSchema = CustomAttributeSchema;
|
|
@@ -455,5 +453,3 @@ exports.createRuleForPlugin = createRuleForPlugin;
|
|
|
455
453
|
exports.defineSettings = defineSettings;
|
|
456
454
|
exports.getReactVersion = getReactVersion;
|
|
457
455
|
exports.getSettingsFromContext = getSettingsFromContext;
|
|
458
|
-
exports.normalizeSettings = normalizeSettings;
|
|
459
|
-
exports.unsafeReadSettings = unsafeReadSettings;
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
2
2
|
import { F, E } from '@eslint-react/eff';
|
|
3
3
|
import { isMatching, P, match } from 'ts-pattern';
|
|
4
4
|
import module from 'node:module';
|
|
5
|
-
import { object, string, optional, boolean, array, instance,
|
|
5
|
+
import { object, string, optional, boolean, array, instance, assert } from 'valibot';
|
|
6
6
|
import pm from 'picomatch';
|
|
7
7
|
|
|
8
8
|
// src/constants.ts
|
|
@@ -376,7 +376,7 @@ var ESLintSettingsSchema = optional(
|
|
|
376
376
|
);
|
|
377
377
|
|
|
378
378
|
// src/cache.ts
|
|
379
|
-
var normalizedSettingsCache = /* @__PURE__ */ new
|
|
379
|
+
var normalizedSettingsCache = /* @__PURE__ */ new WeakMap();
|
|
380
380
|
|
|
381
381
|
// src/settings.ts
|
|
382
382
|
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
@@ -387,19 +387,20 @@ var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
|
387
387
|
strictImportCheck: false,
|
|
388
388
|
version: "detect"
|
|
389
389
|
};
|
|
390
|
-
function
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
function getSettingsFromContext(context) {
|
|
391
|
+
assert(ESLintSettingsSchema, context.settings);
|
|
392
|
+
const raw = context.settings?.["react-x"] ?? {};
|
|
393
|
+
const memoized = normalizedSettingsCache.get(raw);
|
|
394
|
+
if (memoized) {
|
|
395
|
+
return memoized;
|
|
396
|
+
}
|
|
397
|
+
const rawWithDefaults = {
|
|
397
398
|
...DEFAULT_ESLINT_REACT_SETTINGS,
|
|
398
|
-
...
|
|
399
|
+
...raw
|
|
399
400
|
};
|
|
400
|
-
const additionalComponents =
|
|
401
|
+
const additionalComponents = rawWithDefaults.additionalComponents ?? [];
|
|
401
402
|
const normalized = {
|
|
402
|
-
...
|
|
403
|
+
...rawWithDefaults,
|
|
403
404
|
additionalComponents: additionalComponents.map((component) => ({
|
|
404
405
|
...component,
|
|
405
406
|
attributes: component.attributes?.map((attr) => ({
|
|
@@ -414,14 +415,11 @@ function normalizeSettings(data) {
|
|
|
414
415
|
if (!/^[\w-]+$/u.test(name)) return acc;
|
|
415
416
|
return acc.set(name, as);
|
|
416
417
|
}, /* @__PURE__ */ new Map()),
|
|
417
|
-
version: match(
|
|
418
|
+
version: match(rawWithDefaults.version).with(P.union(P.nullish, "", "detect"), () => E.getOrElse(getReactVersion(), F.constant("19.0.0"))).otherwise(F.identity)
|
|
418
419
|
};
|
|
419
|
-
normalizedSettingsCache.set(
|
|
420
|
+
normalizedSettingsCache.set(raw, normalized);
|
|
420
421
|
return normalized;
|
|
421
422
|
}
|
|
422
|
-
function getSettingsFromContext(context) {
|
|
423
|
-
return normalizeSettings(context.settings);
|
|
424
|
-
}
|
|
425
423
|
var defineSettings = F.identity;
|
|
426
424
|
|
|
427
|
-
export { CustomAttributeSchema, CustomComponentNormalizedSchema, CustomComponentSchema, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, defineSettings, getReactVersion, getSettingsFromContext
|
|
425
|
+
export { CustomAttributeSchema, CustomComponentNormalizedSchema, CustomComponentSchema, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, 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, defineSettings, getReactVersion, getSettingsFromContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.23.2-next.
|
|
3
|
+
"version": "1.23.2-next.3",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/rEl1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@typescript-eslint/utils": "^8.19.0",
|
|
37
37
|
"picomatch": "^4.0.2",
|
|
38
38
|
"ts-pattern": "^5.6.0",
|
|
39
|
-
"valibot": "^1.0.0-beta.
|
|
40
|
-
"@eslint-react/eff": "1.23.2-next.
|
|
39
|
+
"valibot": "^1.0.0-beta.10",
|
|
40
|
+
"@eslint-react/eff": "1.23.2-next.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/picomatch": "^3.0.1",
|