@eslint-react/shared 5.24.2 → 5.24.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.ts CHANGED
@@ -167,11 +167,11 @@ export declare const normalizeSettings: ({ importSource, compilationMode, polymo
167
167
  */
168
168
  export declare function getReactVersion(fallback: string): string;
169
169
  /**
170
- * Get the normalized ESLint React settings, memoized by the input settings object.
171
- * @param settings The ESLint React settings to decode and normalize.
170
+ * Get the normalized ESLint React settings, memoized by the input settings value.
171
+ * @param settings The value to decode and normalize.
172
172
  * @returns The normalized ESLint React settings.
173
173
  */
174
- export declare const getNormalizedSettings: (ast: object) => {
174
+ export declare const getNormalizedSettings: (a: unknown) => {
175
175
  readonly importSource: string;
176
176
  readonly compilationMode: "infer" | "annotation" | "syntax" | "all" | "off";
177
177
  readonly polymorphicPropName: string;
package/dist/index.js CHANGED
@@ -72,13 +72,11 @@ const absurd = (_) => {
72
72
  };
73
73
  const hole = cast(absurd);
74
74
  function memoize(f) {
75
- const cache = /* @__PURE__ */ new WeakMap();
75
+ const objects = /* @__PURE__ */ new WeakMap();
76
+ const primitives = /* @__PURE__ */ new Map();
76
77
  return (a) => {
77
- const cached = cache.get(a);
78
- if (cached !== void 0) return cached;
79
- const result = f(a);
80
- cache.set(a, result);
81
- return result;
78
+ if (isObjectKeyword(a)) return getOrInsertComputed(objects, a, () => f(a));
79
+ return getOrInsertComputed(primitives, a, () => f(a));
82
80
  };
83
81
  }
84
82
  const and = dual(2, (a, b) => (data) => a(data) && b(data));
@@ -95,6 +93,12 @@ function isObjectKeyword(input) {
95
93
  return typeof input === "object" && input !== null || isFunction(input);
96
94
  }
97
95
  const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
96
+ function getOrInsertComputed(map, key, callback) {
97
+ if (map.has(key)) return map.get(key);
98
+ const value = callback(key);
99
+ map.set(key, value);
100
+ return value;
101
+ }
98
102
  const dropWhile = dual(2, (self, predicate) => {
99
103
  const input = Array.isArray(self) ? self : Array.from(self);
100
104
  const len = input.length;
@@ -198,8 +202,7 @@ function getReactVersion(fallback) {
198
202
  }
199
203
  const getNormalizedSettings = memoize((settings) => normalizeSettings(decodeSettings(settings)));
200
204
  function getSettingsFromContext(context) {
201
- const settings = context.settings["react-x"];
202
- return getNormalizedSettings(isObjectKeyword(settings) ? settings : DEFAULT_ESLINT_REACT_SETTINGS);
205
+ return getNormalizedSettings(context.settings["react-x"]);
203
206
  }
204
207
 
205
208
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "5.24.2",
3
+ "version": "5.24.3",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/eslint": "5.24.2",
32
+ "@eslint-react/eslint": "5.24.3",
33
33
  "@typescript-eslint/utils": "^8.71.0",
34
34
  "ts-pattern": "^5.9.0",
35
35
  "zod": "^3.25.0 || ^4.0.0"