@eslint-react/shared 1.9.0 → 1.9.1-next.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 CHANGED
@@ -2068,14 +2068,157 @@ type Memoized<Fn extends AnyFn> = Fn &
2068
2068
  options: NormalizedOptions<Fn>;
2069
2069
  };
2070
2070
 
2071
+ /**
2072
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
2073
+
2074
+ @category Type
2075
+ */
2076
+ type Primitive =
2077
+ | null
2078
+ | undefined
2079
+ | string
2080
+ | number
2081
+ | boolean
2082
+ | symbol
2083
+ | bigint;
2084
+
2085
+ declare global {
2086
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
2087
+ interface SymbolConstructor {
2088
+ readonly observable: symbol;
2089
+ }
2090
+ }
2091
+
2092
+ /**
2093
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
2094
+ */
2095
+ type BuiltIns = Primitive | void | Date | RegExp;
2096
+
2097
+ /**
2098
+ @see PartialDeep
2099
+ */
2100
+ type PartialDeepOptions = {
2101
+ /**
2102
+ Whether to affect the individual elements of arrays and tuples.
2103
+
2104
+ @default false
2105
+ */
2106
+ readonly recurseIntoArrays?: boolean;
2107
+ };
2108
+
2109
+ /**
2110
+ Create a type from another type with all keys and nested keys set to optional.
2111
+
2112
+ Use-cases:
2113
+ - Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
2114
+ - Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
2115
+
2116
+ @example
2117
+ ```
2118
+ import type {PartialDeep} from 'type-fest';
2119
+
2120
+ const settings: Settings = {
2121
+ textEditor: {
2122
+ fontSize: 14;
2123
+ fontColor: '#000000';
2124
+ fontWeight: 400;
2125
+ }
2126
+ autocomplete: false;
2127
+ autosave: true;
2128
+ };
2129
+
2130
+ const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
2131
+ return {...settings, ...savedSettings};
2132
+ }
2133
+
2134
+ settings = applySavedSettings({textEditor: {fontWeight: 500}});
2135
+ ```
2136
+
2137
+ 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:
2138
+
2139
+ ```
2140
+ import type {PartialDeep} from 'type-fest';
2141
+
2142
+ interface Settings {
2143
+ languages: string[];
2144
+ }
2145
+
2146
+ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
2147
+ languages: [undefined]
2148
+ };
2149
+ ```
2150
+
2151
+ @category Object
2152
+ @category Array
2153
+ @category Set
2154
+ @category Map
2155
+ */
2156
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
2157
+ ? T
2158
+ : T extends Map<infer KeyType, infer ValueType>
2159
+ ? PartialMapDeep<KeyType, ValueType, Options>
2160
+ : T extends Set<infer ItemType>
2161
+ ? PartialSetDeep<ItemType, Options>
2162
+ : T extends ReadonlyMap<infer KeyType, infer ValueType>
2163
+ ? PartialReadonlyMapDeep<KeyType, ValueType, Options>
2164
+ : T extends ReadonlySet<infer ItemType>
2165
+ ? PartialReadonlySetDeep<ItemType, Options>
2166
+ : T extends object
2167
+ ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
2168
+ ? Options['recurseIntoArrays'] extends true
2169
+ ? ItemType[] extends T // Test for arrays (non-tuples) specifically
2170
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
2171
+ ? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
2172
+ : Array<PartialDeep<ItemType | undefined, Options>>
2173
+ : PartialObjectDeep<T, Options> // Tuples behave properly
2174
+ : T // If they don't opt into array testing, just use the original type
2175
+ : PartialObjectDeep<T, Options>
2176
+ : unknown;
2177
+
2178
+ /**
2179
+ Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
2180
+ */
2181
+ type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
2182
+
2183
+ /**
2184
+ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
2185
+ */
2186
+ type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
2187
+
2188
+ /**
2189
+ Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
2190
+ */
2191
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
2192
+
2193
+ /**
2194
+ Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
2195
+ */
2196
+ type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
2197
+
2198
+ /**
2199
+ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
2200
+ */
2201
+ type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
2202
+ [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
2203
+ };
2204
+
2071
2205
  /**
2072
2206
  * The initial settings for "react-x".
2073
2207
  */
2074
- declare const INITIAL_ESLINT_REACT_SETTINGS: ESLintReactSettings;
2208
+ declare const INITIAL_ESLINT_REACT_SETTINGS: {
2209
+ readonly skipImportCheck: true;
2210
+ };
2075
2211
  /**
2076
2212
  * The default ESLint settings for "react-x".
2077
2213
  */
2078
- declare const DEFAULT_ESLINT_REACT_SETTINGS: ESLintReactSettings;
2214
+ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
2215
+ readonly additionalHooks: {
2216
+ readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
2217
+ };
2218
+ readonly polymorphicPropName: "as";
2219
+ readonly skipImportCheck: true;
2220
+ readonly version: "detect";
2221
+ };
2079
2222
  /**
2080
2223
  * This is an expanded version of `CustomComponent` with all shorthand properties expanded.
2081
2224
  * @internal
@@ -2107,14 +2250,14 @@ declare function defineSettings(settings: ESLintReactSettings): {};
2107
2250
  * @param data The data object.
2108
2251
  * @returns settings The settings.
2109
2252
  */
2110
- declare function decodeSettings(data: unknown): ESLintReactSettings;
2253
+ declare const decodeSettings: Memoized<(data: unknown) => ESLintReactSettings>;
2111
2254
  /**
2112
2255
  * Unsafely casts settings from a data object from `context.settings`.
2113
2256
  * @internal
2114
2257
  * @param data The data object.
2115
2258
  * @returns settings The settings.
2116
2259
  */
2117
- declare function unsafeCastSettings(data: unknown): ESLintReactSettings;
2260
+ declare function unsafeCastSettings(data: unknown): PartialDeep<ESLintReactSettings>;
2118
2261
  /**
2119
2262
  * Expands the settings by converting all shorthand properties to their full form.
2120
2263
  * @param settings The settings.
package/dist/index.d.ts CHANGED
@@ -2068,14 +2068,157 @@ type Memoized<Fn extends AnyFn> = Fn &
2068
2068
  options: NormalizedOptions<Fn>;
2069
2069
  };
2070
2070
 
2071
+ /**
2072
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
2073
+
2074
+ @category Type
2075
+ */
2076
+ type Primitive =
2077
+ | null
2078
+ | undefined
2079
+ | string
2080
+ | number
2081
+ | boolean
2082
+ | symbol
2083
+ | bigint;
2084
+
2085
+ declare global {
2086
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
2087
+ interface SymbolConstructor {
2088
+ readonly observable: symbol;
2089
+ }
2090
+ }
2091
+
2092
+ /**
2093
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
2094
+ */
2095
+ type BuiltIns = Primitive | void | Date | RegExp;
2096
+
2097
+ /**
2098
+ @see PartialDeep
2099
+ */
2100
+ type PartialDeepOptions = {
2101
+ /**
2102
+ Whether to affect the individual elements of arrays and tuples.
2103
+
2104
+ @default false
2105
+ */
2106
+ readonly recurseIntoArrays?: boolean;
2107
+ };
2108
+
2109
+ /**
2110
+ Create a type from another type with all keys and nested keys set to optional.
2111
+
2112
+ Use-cases:
2113
+ - Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
2114
+ - Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
2115
+
2116
+ @example
2117
+ ```
2118
+ import type {PartialDeep} from 'type-fest';
2119
+
2120
+ const settings: Settings = {
2121
+ textEditor: {
2122
+ fontSize: 14;
2123
+ fontColor: '#000000';
2124
+ fontWeight: 400;
2125
+ }
2126
+ autocomplete: false;
2127
+ autosave: true;
2128
+ };
2129
+
2130
+ const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
2131
+ return {...settings, ...savedSettings};
2132
+ }
2133
+
2134
+ settings = applySavedSettings({textEditor: {fontWeight: 500}});
2135
+ ```
2136
+
2137
+ 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:
2138
+
2139
+ ```
2140
+ import type {PartialDeep} from 'type-fest';
2141
+
2142
+ interface Settings {
2143
+ languages: string[];
2144
+ }
2145
+
2146
+ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
2147
+ languages: [undefined]
2148
+ };
2149
+ ```
2150
+
2151
+ @category Object
2152
+ @category Array
2153
+ @category Set
2154
+ @category Map
2155
+ */
2156
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIns | (((...arguments_: any[]) => unknown)) | (new (...arguments_: any[]) => unknown)
2157
+ ? T
2158
+ : T extends Map<infer KeyType, infer ValueType>
2159
+ ? PartialMapDeep<KeyType, ValueType, Options>
2160
+ : T extends Set<infer ItemType>
2161
+ ? PartialSetDeep<ItemType, Options>
2162
+ : T extends ReadonlyMap<infer KeyType, infer ValueType>
2163
+ ? PartialReadonlyMapDeep<KeyType, ValueType, Options>
2164
+ : T extends ReadonlySet<infer ItemType>
2165
+ ? PartialReadonlySetDeep<ItemType, Options>
2166
+ : T extends object
2167
+ ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
2168
+ ? Options['recurseIntoArrays'] extends true
2169
+ ? ItemType[] extends T // Test for arrays (non-tuples) specifically
2170
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
2171
+ ? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
2172
+ : Array<PartialDeep<ItemType | undefined, Options>>
2173
+ : PartialObjectDeep<T, Options> // Tuples behave properly
2174
+ : T // If they don't opt into array testing, just use the original type
2175
+ : PartialObjectDeep<T, Options>
2176
+ : unknown;
2177
+
2178
+ /**
2179
+ Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
2180
+ */
2181
+ type PartialMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & Map<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
2182
+
2183
+ /**
2184
+ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
2185
+ */
2186
+ type PartialSetDeep<T, Options extends PartialDeepOptions> = {} & Set<PartialDeep<T, Options>>;
2187
+
2188
+ /**
2189
+ Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
2190
+ */
2191
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends PartialDeepOptions> = {} & ReadonlyMap<PartialDeep<KeyType, Options>, PartialDeep<ValueType, Options>>;
2192
+
2193
+ /**
2194
+ Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
2195
+ */
2196
+ type PartialReadonlySetDeep<T, Options extends PartialDeepOptions> = {} & ReadonlySet<PartialDeep<T, Options>>;
2197
+
2198
+ /**
2199
+ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
2200
+ */
2201
+ type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOptions> = {
2202
+ [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
2203
+ };
2204
+
2071
2205
  /**
2072
2206
  * The initial settings for "react-x".
2073
2207
  */
2074
- declare const INITIAL_ESLINT_REACT_SETTINGS: ESLintReactSettings;
2208
+ declare const INITIAL_ESLINT_REACT_SETTINGS: {
2209
+ readonly skipImportCheck: true;
2210
+ };
2075
2211
  /**
2076
2212
  * The default ESLint settings for "react-x".
2077
2213
  */
2078
- declare const DEFAULT_ESLINT_REACT_SETTINGS: ESLintReactSettings;
2214
+ declare const DEFAULT_ESLINT_REACT_SETTINGS: {
2215
+ readonly additionalHooks: {
2216
+ readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
2217
+ };
2218
+ readonly polymorphicPropName: "as";
2219
+ readonly skipImportCheck: true;
2220
+ readonly version: "detect";
2221
+ };
2079
2222
  /**
2080
2223
  * This is an expanded version of `CustomComponent` with all shorthand properties expanded.
2081
2224
  * @internal
@@ -2107,14 +2250,14 @@ declare function defineSettings(settings: ESLintReactSettings): {};
2107
2250
  * @param data The data object.
2108
2251
  * @returns settings The settings.
2109
2252
  */
2110
- declare function decodeSettings(data: unknown): ESLintReactSettings;
2253
+ declare const decodeSettings: Memoized<(data: unknown) => ESLintReactSettings>;
2111
2254
  /**
2112
2255
  * Unsafely casts settings from a data object from `context.settings`.
2113
2256
  * @internal
2114
2257
  * @param data The data object.
2115
2258
  * @returns settings The settings.
2116
2259
  */
2117
- declare function unsafeCastSettings(data: unknown): ESLintReactSettings;
2260
+ declare function unsafeCastSettings(data: unknown): PartialDeep<ESLintReactSettings>;
2118
2261
  /**
2119
2262
  * Expands the settings by converting all shorthand properties to their full form.
2120
2263
  * @param settings The settings.
package/dist/index.js CHANGED
@@ -930,17 +930,14 @@ var DEFAULT_ESLINT_REACT_SETTINGS = {
930
930
  function defineSettings(settings) {
931
931
  return parse(ESLintSettingsSchema, settings)["react-x"] ?? {};
932
932
  }
933
- function decodeSettings(data) {
933
+ var decodeSettings = createMemoizedFunction((data) => {
934
934
  return {
935
935
  ...INITIAL_ESLINT_REACT_SETTINGS,
936
936
  ...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
937
937
  };
938
- }
938
+ }, { isEqual: (a, b) => a === b });
939
939
  function unsafeCastSettings(data) {
940
- return {
941
- ...INITIAL_ESLINT_REACT_SETTINGS,
942
- ...data["react-x"] ?? {}
943
- };
940
+ return data?.["react-x"] ?? {};
944
941
  }
945
942
  var expandSettings = createMemoizedFunction(
946
943
  (settings) => {
package/dist/index.mjs CHANGED
@@ -924,17 +924,14 @@ var DEFAULT_ESLINT_REACT_SETTINGS = {
924
924
  function defineSettings(settings) {
925
925
  return parse(ESLintSettingsSchema, settings)["react-x"] ?? {};
926
926
  }
927
- function decodeSettings(data) {
927
+ var decodeSettings = createMemoizedFunction((data) => {
928
928
  return {
929
929
  ...INITIAL_ESLINT_REACT_SETTINGS,
930
930
  ...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
931
931
  };
932
- }
932
+ }, { isEqual: (a, b) => a === b });
933
933
  function unsafeCastSettings(data) {
934
- return {
935
- ...INITIAL_ESLINT_REACT_SETTINGS,
936
- ...data["react-x"] ?? {}
937
- };
934
+ return data?.["react-x"] ?? {};
938
935
  }
939
936
  var expandSettings = createMemoizedFunction(
940
937
  (settings) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.9.0",
3
+ "version": "1.9.1-next.1",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/rel1cx/eslint-react",
6
6
  "bugs": {