@eslint-react/shared 1.50.0-next.0 → 2.0.0-beta.14

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
@@ -2,6 +2,16 @@ import { _ } from '@eslint-react/eff';
2
2
  import { RuleContext } from '@eslint-react/kit';
3
3
  import * as z from '@zod/mini';
4
4
 
5
+ /**
6
+ * @internal
7
+ */
8
+ declare const getId: () => string;
9
+
10
+ /**
11
+ * @internal
12
+ */
13
+ declare const _require: NodeJS.Require;
14
+
5
15
  /**
6
16
  * The NPM scope for this project.
7
17
  */
@@ -23,8 +33,6 @@ declare const WEBSITE_URL = "https://eslint-react.xyz";
23
33
  */
24
34
  declare const getDocsUrl: (pluginName: string) => (ruleName: string) => string;
25
35
 
26
- declare const getId: () => string;
27
-
28
36
  declare function getReactVersion(fallback: string): string;
29
37
 
30
38
  /**
@@ -741,7 +749,7 @@ declare const CustomComponentPropSchema: z.ZodMiniObject<{
741
749
  * `"/"`
742
750
  */
743
751
  defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
744
- }, {}, {}>;
752
+ }, {}>;
745
753
  /**
746
754
  * @description
747
755
  * This will provide some key information to the rule before checking for user-defined components.
@@ -792,7 +800,7 @@ declare const CustomComponentSchema: z.ZodMiniObject<{
792
800
  * `"/"`
793
801
  */
794
802
  defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
795
- }, {}, {}>>>;
803
+ }, {}>>>;
796
804
  /**
797
805
  * The ESQuery selector to select the component precisely.
798
806
  * @internal
@@ -800,7 +808,7 @@ declare const CustomComponentSchema: z.ZodMiniObject<{
800
808
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
801
809
  */
802
810
  selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
803
- }, {}, {}>;
811
+ }, {}>;
804
812
  declare const CustomHooksSchema: z.ZodMiniObject<{
805
813
  use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
806
814
  useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
@@ -821,7 +829,7 @@ declare const CustomHooksSchema: z.ZodMiniObject<{
821
829
  useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
822
830
  useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
823
831
  useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
824
- }, {}, {}>;
832
+ }, {}>;
825
833
  /**
826
834
  * @internal
827
835
  */
@@ -895,7 +903,7 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
895
903
  useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
896
904
  useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
897
905
  useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
898
- }, {}, {}>>;
906
+ }, {}>>;
899
907
  /**
900
908
  * An array of user-defined components
901
909
  * @description This is used to inform the ESLint React plugins how to treat these components during checks.
@@ -945,7 +953,7 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
945
953
  * `"/"`
946
954
  */
947
955
  defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
948
- }, {}, {}>>>;
956
+ }, {}>>>;
949
957
  /**
950
958
  * The ESQuery selector to select the component precisely.
951
959
  * @internal
@@ -953,14 +961,14 @@ declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
953
961
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
954
962
  */
955
963
  selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
956
- }, {}, {}>>>;
957
- }, {}, {}>;
964
+ }, {}>>>;
965
+ }, {}>;
958
966
  /**
959
967
  * @internal
960
968
  */
961
969
  declare const ESLintSettingsSchema: z.ZodMiniOptional<z.ZodMiniObject<{
962
970
  "react-x": z.ZodMiniOptional<z.ZodMiniUnknown>;
963
- }, {}, {}>>;
971
+ }, {}>>;
964
972
  type CustomComponent = z.infer<typeof CustomComponentSchema>;
965
973
  type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
966
974
  type CustomHooks = z.infer<typeof CustomHooksSchema>;
@@ -1080,4 +1088,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
1080
1088
  }
1081
1089
  }
1082
1090
 
1083
- export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
1091
+ export { type CustomComponent, type CustomComponentNormalized, type CustomComponentProp, type CustomComponentPropNormalized, CustomComponentPropSchema, CustomComponentSchema, type CustomHooks, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsNormalized, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
package/dist/index.js CHANGED
@@ -1,34 +1,14 @@
1
- 'use strict';
1
+ import module from 'node:module';
2
+ import path from 'node:path';
3
+ import { identity, getOrElseUpdate } from '@eslint-react/eff';
4
+ import { match, P } from 'ts-pattern';
5
+ import { RegExp } from '@eslint-react/kit';
6
+ import * as z from '@zod/mini';
2
7
 
3
- var module$1 = require('module');
4
- var eff = require('@eslint-react/eff');
5
- var tsPattern = require('ts-pattern');
6
- var kit = require('@eslint-react/kit');
7
- var z = require('@zod/mini');
8
-
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- function _interopNamespace(e) {
13
- if (e && e.__esModule) return e;
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n.default = e;
27
- return Object.freeze(n);
28
- }
29
-
30
- var module__default = /*#__PURE__*/_interopDefault(module$1);
31
- var z__namespace = /*#__PURE__*/_interopNamespace(z);
8
+ // src/_id.ts
9
+ var id = 0n;
10
+ var getId = () => (id++).toString();
11
+ var _require = module.createRequire(process.cwd() + path.sep);
32
12
 
33
13
  // src/constants.ts
34
14
  var NPM_SCOPE = "@eslint-react";
@@ -42,154 +22,149 @@ var getDocsUrl = (pluginName) => (ruleName) => {
42
22
  }
43
23
  return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
44
24
  };
45
-
46
- // src/get-id.ts
47
- var id = 0n;
48
- var getId = () => (id++).toString();
49
- var _require = module__default.default.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
50
25
  function getReactVersion(fallback) {
51
26
  try {
52
- return tsPattern.match(_require("react")).with({ version: tsPattern.P.select(tsPattern.P.string) }, eff.identity).otherwise(() => fallback);
27
+ return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
53
28
  } catch {
54
29
  return fallback;
55
30
  }
56
31
  }
57
- var CustomComponentPropSchema = z__namespace.object({
32
+ var CustomComponentPropSchema = z.object({
58
33
  /**
59
34
  * The name of the prop in the user-defined component.
60
35
  * @example
61
36
  * "to"
62
37
  */
63
- name: z__namespace.string(),
38
+ name: z.string(),
64
39
  /**
65
40
  * The name of the prop in the host component.
66
41
  * @example
67
42
  * "href"
68
43
  */
69
- as: z__namespace.optional(z__namespace.string()),
44
+ as: z.optional(z.string()),
70
45
  /**
71
46
  * Whether the prop is controlled or not in the user-defined component.
72
47
  * @internal
73
48
  * @example
74
49
  * `true`
75
50
  */
76
- controlled: z__namespace.optional(z__namespace.boolean()),
51
+ controlled: z.optional(z.boolean()),
77
52
  /**
78
53
  * The default value of the prop in the user-defined component.
79
54
  * @example
80
55
  * `"/"`
81
56
  */
82
- defaultValue: z__namespace.optional(z__namespace.string())
57
+ defaultValue: z.optional(z.string())
83
58
  });
84
- var CustomComponentSchema = z__namespace.object({
59
+ var CustomComponentSchema = z.object({
85
60
  /**
86
61
  * The name of the user-defined component.
87
62
  * @example
88
63
  * "Link"
89
64
  */
90
- name: z__namespace.string(),
65
+ name: z.string(),
91
66
  /**
92
67
  * The name of the host component that the user-defined component represents.
93
68
  * @example
94
69
  * "a"
95
70
  */
96
- as: z__namespace.optional(z__namespace.string()),
71
+ as: z.optional(z.string()),
97
72
  /**
98
73
  * Attributes mapping between the user-defined component and the host component.
99
74
  * @example
100
75
  * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
101
76
  */
102
- attributes: z__namespace.optional(z__namespace.array(CustomComponentPropSchema)),
77
+ attributes: z.optional(z.array(CustomComponentPropSchema)),
103
78
  /**
104
79
  * The ESQuery selector to select the component precisely.
105
80
  * @internal
106
81
  * @example
107
82
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
108
83
  */
109
- selector: z__namespace.optional(z__namespace.string())
84
+ selector: z.optional(z.string())
110
85
  });
111
- var CustomHooksSchema = z__namespace.object({
112
- use: z__namespace.optional(z__namespace.array(z__namespace.string())),
113
- useActionState: z__namespace.optional(z__namespace.array(z__namespace.string())),
114
- useCallback: z__namespace.optional(z__namespace.array(z__namespace.string())),
115
- useContext: z__namespace.optional(z__namespace.array(z__namespace.string())),
116
- useDebugValue: z__namespace.optional(z__namespace.array(z__namespace.string())),
117
- useDeferredValue: z__namespace.optional(z__namespace.array(z__namespace.string())),
118
- useEffect: z__namespace.optional(z__namespace.array(z__namespace.string())),
119
- useFormStatus: z__namespace.optional(z__namespace.array(z__namespace.string())),
120
- useId: z__namespace.optional(z__namespace.array(z__namespace.string())),
121
- useImperativeHandle: z__namespace.optional(z__namespace.array(z__namespace.string())),
122
- useInsertionEffect: z__namespace.optional(z__namespace.array(z__namespace.string())),
123
- useLayoutEffect: z__namespace.optional(z__namespace.array(z__namespace.string())),
124
- useMemo: z__namespace.optional(z__namespace.array(z__namespace.string())),
125
- useOptimistic: z__namespace.optional(z__namespace.array(z__namespace.string())),
126
- useReducer: z__namespace.optional(z__namespace.array(z__namespace.string())),
127
- useRef: z__namespace.optional(z__namespace.array(z__namespace.string())),
128
- useState: z__namespace.optional(z__namespace.array(z__namespace.string())),
129
- useSyncExternalStore: z__namespace.optional(z__namespace.array(z__namespace.string())),
130
- useTransition: z__namespace.optional(z__namespace.array(z__namespace.string()))
86
+ var CustomHooksSchema = z.object({
87
+ use: z.optional(z.array(z.string())),
88
+ useActionState: z.optional(z.array(z.string())),
89
+ useCallback: z.optional(z.array(z.string())),
90
+ useContext: z.optional(z.array(z.string())),
91
+ useDebugValue: z.optional(z.array(z.string())),
92
+ useDeferredValue: z.optional(z.array(z.string())),
93
+ useEffect: z.optional(z.array(z.string())),
94
+ useFormStatus: z.optional(z.array(z.string())),
95
+ useId: z.optional(z.array(z.string())),
96
+ useImperativeHandle: z.optional(z.array(z.string())),
97
+ useInsertionEffect: z.optional(z.array(z.string())),
98
+ useLayoutEffect: z.optional(z.array(z.string())),
99
+ useMemo: z.optional(z.array(z.string())),
100
+ useOptimistic: z.optional(z.array(z.string())),
101
+ useReducer: z.optional(z.array(z.string())),
102
+ useRef: z.optional(z.array(z.string())),
103
+ useState: z.optional(z.array(z.string())),
104
+ useSyncExternalStore: z.optional(z.array(z.string())),
105
+ useTransition: z.optional(z.array(z.string()))
131
106
  });
132
- var ESLintReactSettingsSchema = z__namespace.object({
107
+ var ESLintReactSettingsSchema = z.object({
133
108
  /**
134
109
  * The source where React is imported from.
135
110
  * @description This allows to specify a custom import location for React when not using the official distribution.
136
111
  * @default `"react"`
137
112
  * @example `"@pika/react"`
138
113
  */
139
- importSource: z__namespace.optional(z__namespace.string()),
114
+ importSource: z.optional(z.string()),
140
115
  /**
141
116
  * The identifier that's used for JSX Element creation.
142
117
  * @default `"createElement"`
143
118
  * @deprecated
144
119
  */
145
- jsxPragma: z__namespace.optional(z__namespace.string()),
120
+ jsxPragma: z.optional(z.string()),
146
121
  /**
147
122
  * The identifier that's used for JSX fragment elements.
148
123
  * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
149
124
  * @default `"Fragment"`
150
125
  * @deprecated
151
126
  */
152
- jsxPragmaFrag: z__namespace.optional(z__namespace.string()),
127
+ jsxPragmaFrag: z.optional(z.string()),
153
128
  /**
154
129
  * The name of the prop that is used for polymorphic components.
155
130
  * @description This is used to determine the type of the component.
156
131
  * @example `"as"`
157
132
  */
158
- polymorphicPropName: z__namespace.optional(z__namespace.string()),
133
+ polymorphicPropName: z.optional(z.string()),
159
134
  /**
160
135
  * @default `true`
161
136
  * @internal
162
137
  */
163
- strict: z__namespace.optional(z__namespace.boolean()),
138
+ strict: z.optional(z.boolean()),
164
139
  /**
165
140
  * Check both the shape and the import to determine if an API is from React.
166
141
  * @default `true`
167
142
  * @internal
168
143
  */
169
- skipImportCheck: z__namespace.optional(z__namespace.boolean()),
144
+ skipImportCheck: z.optional(z.boolean()),
170
145
  /**
171
146
  * React version to use, "detect" means auto detect React version from the project's dependencies.
172
147
  * If `importSource` is specified, an equivalent version of React should be provided here.
173
148
  * @example `"18.3.1"`
174
149
  * @default `"detect"`
175
150
  */
176
- version: z__namespace.optional(z__namespace.string()),
151
+ version: z.optional(z.string()),
177
152
  /**
178
153
  * A object to define additional hooks that are equivalent to the built-in React Hooks.
179
154
  * @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
180
155
  * @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
181
156
  */
182
- additionalHooks: z__namespace.optional(CustomHooksSchema),
157
+ additionalHooks: z.optional(CustomHooksSchema),
183
158
  /**
184
159
  * An array of user-defined components
185
160
  * @description This is used to inform the ESLint React plugins how to treat these components during checks.
186
161
  * @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
187
162
  */
188
- additionalComponents: z__namespace.optional(z__namespace.array(CustomComponentSchema))
163
+ additionalComponents: z.optional(z.array(CustomComponentSchema))
189
164
  });
190
- var ESLintSettingsSchema = z__namespace.optional(
191
- z__namespace.object({
192
- "react-x": z__namespace.optional(z__namespace.unknown())
165
+ var ESLintSettingsSchema = z.optional(
166
+ z.object({
167
+ "react-x": z.optional(z.unknown())
193
168
  }),
194
169
  {}
195
170
  );
@@ -246,7 +221,7 @@ var normalizeSettings = ({
246
221
  ...rest,
247
222
  components: additionalComponents.map((component) => {
248
223
  const { name, as = name, attributes = [], ...rest2 } = component;
249
- const re = kit.RegExp.toRegExp(name);
224
+ const re = RegExp.toRegExp(name);
250
225
  return {
251
226
  ...rest2,
252
227
  name,
@@ -264,39 +239,18 @@ var normalizeSettings = ({
264
239
  polymorphicPropName,
265
240
  skipImportCheck,
266
241
  strict,
267
- version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(eff.identity)
242
+ version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(identity)
268
243
  };
269
244
  };
270
245
  var cache = /* @__PURE__ */ new Map();
271
246
  function getSettingsFromContext(context) {
272
247
  const settings = context.settings;
273
- return eff.getOrElseUpdate(
248
+ return getOrElseUpdate(
274
249
  cache,
275
250
  settings["react-x"],
276
251
  () => normalizeSettings(decodeSettings(settings["react-x"]))
277
252
  );
278
253
  }
279
- var defineSettings = eff.identity;
254
+ var defineSettings = identity;
280
255
 
281
- exports.CustomComponentPropSchema = CustomComponentPropSchema;
282
- exports.CustomComponentSchema = CustomComponentSchema;
283
- exports.CustomHooksSchema = CustomHooksSchema;
284
- exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
285
- exports.DEFAULT_ESLINT_SETTINGS = DEFAULT_ESLINT_SETTINGS;
286
- exports.ESLintReactSettingsSchema = ESLintReactSettingsSchema;
287
- exports.ESLintSettingsSchema = ESLintSettingsSchema;
288
- exports.GITHUB_URL = GITHUB_URL;
289
- exports.NPM_SCOPE = NPM_SCOPE;
290
- exports.WEBSITE_URL = WEBSITE_URL;
291
- exports.coerceESLintSettings = coerceESLintSettings;
292
- exports.coerceSettings = coerceSettings;
293
- exports.decodeESLintSettings = decodeESLintSettings;
294
- exports.decodeSettings = decodeSettings;
295
- exports.defineSettings = defineSettings;
296
- exports.getDocsUrl = getDocsUrl;
297
- exports.getId = getId;
298
- exports.getReactVersion = getReactVersion;
299
- exports.getSettingsFromContext = getSettingsFromContext;
300
- exports.isESLintReactSettings = isESLintReactSettings;
301
- exports.isESLintSettings = isESLintSettings;
302
- exports.normalizeSettings = normalizeSettings;
256
+ export { CustomComponentPropSchema, CustomComponentSchema, CustomHooksSchema, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.50.0-next.0",
3
+ "version": "2.0.0-beta.14",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -14,43 +14,35 @@
14
14
  "license": "MIT",
15
15
  "author": "Rel1cx<rel1cx@proton.me>",
16
16
  "sideEffects": false,
17
+ "type": "module",
17
18
  "exports": {
18
19
  ".": {
19
- "import": {
20
- "types": "./dist/index.d.mts",
21
- "default": "./dist/index.mjs"
22
- },
23
- "require": {
24
- "types": "./dist/index.d.ts",
25
- "default": "./dist/index.js"
26
- }
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
27
22
  },
28
23
  "./package.json": "./package.json"
29
24
  },
30
- "main": "dist/index.js",
31
- "module": "dist/index.mjs",
32
- "types": "dist/index.d.ts",
33
25
  "files": [
34
26
  "dist",
35
27
  "./package.json"
36
28
  ],
37
29
  "dependencies": {
38
- "@typescript-eslint/utils": "^8.32.0",
39
- "@zod/mini": "^4.0.0-beta.20250505T195954",
30
+ "@typescript-eslint/utils": "^8.31.1",
31
+ "@zod/mini": "^4.0.0-beta.20250503T014749",
40
32
  "ts-pattern": "^5.7.0",
41
- "@eslint-react/eff": "1.50.0-next.0",
42
- "@eslint-react/kit": "1.50.0-next.0"
33
+ "@eslint-react/eff": "2.0.0-beta.14",
34
+ "@eslint-react/kit": "2.0.0-beta.14"
43
35
  },
44
36
  "devDependencies": {
45
37
  "@tsconfig/node22": "^22.0.1",
46
38
  "@types/picomatch": "^4.0.0",
47
39
  "tsup": "^8.4.0",
48
- "type-fest": "^4.41.0",
40
+ "type-fest": "^4.40.1",
49
41
  "@local/configs": "0.0.0"
50
42
  },
51
43
  "engines": {
52
44
  "bun": ">=1.0.15",
53
- "node": ">=18.18.0"
45
+ "node": ">=20.19.0"
54
46
  },
55
47
  "scripts": {
56
48
  "build": "tsup --dts-resolve",