@eslint-react/shared 5.24.2 → 5.24.4

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
@@ -2,7 +2,6 @@ import module from "node:module";
2
2
  import path from "node:path";
3
3
  import { P, match } from "ts-pattern";
4
4
  import { z } from "zod/v4";
5
-
6
5
  //#region ../../.pkgs/eff/dist/index.js
7
6
  const pipeArguments = (self, args) => {
8
7
  switch (args.length) {
@@ -26,7 +25,7 @@ const pipeArguments = (self, args) => {
26
25
  const Prototype = { pipe() {
27
26
  return pipeArguments(this, arguments);
28
27
  } };
29
- const Class = (function() {
28
+ (function() {
30
29
  function PipeableBase() {}
31
30
  PipeableBase.prototype = Prototype;
32
31
  return PipeableBase;
@@ -62,54 +61,54 @@ const dual = function(arity, body) {
62
61
  const identity = (a) => a;
63
62
  const cast = identity;
64
63
  const constant = (value) => () => value;
65
- const constTrue = constant(true);
66
64
  const constFalse = constant(false);
67
- const constNull = constant(null);
68
- const constUndefined = constant(void 0);
69
- const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
65
+ dual(2, (ab, bc) => (a) => bc(ab(a)));
70
66
  const absurd = (_) => {
71
67
  throw new Error("Called `absurd` function which should be uncallable");
72
68
  };
73
- const hole = cast(absurd);
69
+ cast(absurd);
74
70
  function memoize(f) {
75
- const cache = /* @__PURE__ */ new WeakMap();
71
+ const objects = /* @__PURE__ */ new WeakMap();
72
+ const primitives = /* @__PURE__ */ new Map();
76
73
  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;
74
+ if (isObjectKeyword(a)) return getOrInsertComputed(objects, a, () => f(a));
75
+ return getOrInsertComputed(primitives, a, () => f(a));
82
76
  };
83
77
  }
84
- const and = dual(2, (a, b) => (data) => a(data) && b(data));
85
- const or = dual(2, (a, b) => (data) => a(data) || b(data));
86
- const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
87
- const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
88
- const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
89
- const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
90
- const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
78
+ dual(2, (a, b) => (data) => a(data) && b(data));
79
+ dual(2, (a, b) => (data) => a(data) || b(data));
80
+ dual(2, (a, b) => (data) => a(data) !== b(data));
81
+ dual(2, (a, b) => (data) => a(data) === b(data));
82
+ dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
83
+ dual(2, (a, b) => (data) => !a(data) && !b(data));
84
+ dual(2, (a, b) => (data) => !a(data) || !b(data));
91
85
  function isFunction(input) {
92
86
  return typeof input === "function";
93
87
  }
94
88
  function isObjectKeyword(input) {
95
89
  return typeof input === "object" && input !== null || isFunction(input);
96
90
  }
97
- const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
98
- const dropWhile = dual(2, (self, predicate) => {
91
+ dual(2, (data, property) => isObjectKeyword(data) && property in data);
92
+ function getOrInsertComputed(map, key, callback) {
93
+ if (map.has(key)) return map.get(key);
94
+ const value = callback(key);
95
+ map.set(key, value);
96
+ return value;
97
+ }
98
+ dual(2, (self, predicate) => {
99
99
  const input = Array.isArray(self) ? self : Array.from(self);
100
100
  const len = input.length;
101
101
  let idx = 0;
102
102
  while (idx < len && predicate(input[idx], idx)) idx++;
103
103
  return input.slice(idx);
104
104
  });
105
- const takeWhile = dual(2, (self, predicate) => {
105
+ dual(2, (self, predicate) => {
106
106
  const input = Array.isArray(self) ? self : Array.from(self);
107
107
  const len = input.length;
108
108
  let idx = 0;
109
109
  while (idx < len && predicate(input[idx], idx)) idx++;
110
110
  return input.slice(0, idx);
111
111
  });
112
-
113
112
  //#endregion
114
113
  //#region src/regexp.ts
115
114
  const RE_HTML_TAG = /^[a-z][^-]*$/u;
@@ -139,7 +138,6 @@ function toRegExp(string) {
139
138
  function isRegExp(string) {
140
139
  return RE_REGEXP_STR.test(string);
141
140
  }
142
-
143
141
  //#endregion
144
142
  //#region src/settings.ts
145
143
  const ESLintReactSettingsSchema = z.object({
@@ -198,9 +196,7 @@ function getReactVersion(fallback) {
198
196
  }
199
197
  const getNormalizedSettings = memoize((settings) => normalizeSettings(decodeSettings(settings)));
200
198
  function getSettingsFromContext(context) {
201
- const settings = context.settings["react-x"];
202
- return getNormalizedSettings(isObjectKeyword(settings) ? settings : DEFAULT_ESLINT_REACT_SETTINGS);
199
+ return getNormalizedSettings(context.settings["react-x"]);
203
200
  }
204
-
205
201
  //#endregion
206
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, decodeESLintSettings, decodeSettings, getNormalizedSettings, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, toRegExp };
202
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, decodeESLintSettings, decodeSettings, getNormalizedSettings, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, toRegExp };
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.4",
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.4",
33
33
  "@typescript-eslint/utils": "^8.71.0",
34
34
  "ts-pattern": "^5.9.0",
35
35
  "zod": "^3.25.0 || ^4.0.0"