@eslint-react/shared 2.0.0-next.0 → 2.0.0-next.2

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
  /**
@@ -1075,4 +1083,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
1075
1083
  }
1076
1084
  }
1077
1085
 
1078
- 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 };
1086
+ 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
  );
@@ -242,12 +217,11 @@ var normalizeSettings = ({
242
217
  version,
243
218
  ...rest
244
219
  }) => {
245
- const fallbackVersion = DEFAULT_ESLINT_REACT_SETTINGS.version;
246
220
  return {
247
221
  ...rest,
248
222
  components: additionalComponents.map((component) => {
249
223
  const { name, as = name, attributes = [], ...rest2 } = component;
250
- const re = kit.RegExp.toRegExp(name);
224
+ const re = RegExp.toRegExp(name);
251
225
  return {
252
226
  ...rest2,
253
227
  name,
@@ -265,39 +239,18 @@ var normalizeSettings = ({
265
239
  polymorphicPropName,
266
240
  skipImportCheck,
267
241
  strict,
268
- version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion(fallbackVersion)).otherwise(eff.identity)
242
+ version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(identity)
269
243
  };
270
244
  };
271
245
  var cache = /* @__PURE__ */ new Map();
272
246
  function getSettingsFromContext(context) {
273
247
  const settings = context.settings;
274
- return eff.getOrElseUpdate(
248
+ return getOrElseUpdate(
275
249
  cache,
276
250
  settings["react-x"],
277
251
  () => normalizeSettings(decodeSettings(settings["react-x"]))
278
252
  );
279
253
  }
280
- var defineSettings = eff.identity;
254
+ var defineSettings = identity;
281
255
 
282
- exports.CustomComponentPropSchema = CustomComponentPropSchema;
283
- exports.CustomComponentSchema = CustomComponentSchema;
284
- exports.CustomHooksSchema = CustomHooksSchema;
285
- exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
286
- exports.DEFAULT_ESLINT_SETTINGS = DEFAULT_ESLINT_SETTINGS;
287
- exports.ESLintReactSettingsSchema = ESLintReactSettingsSchema;
288
- exports.ESLintSettingsSchema = ESLintSettingsSchema;
289
- exports.GITHUB_URL = GITHUB_URL;
290
- exports.NPM_SCOPE = NPM_SCOPE;
291
- exports.WEBSITE_URL = WEBSITE_URL;
292
- exports.coerceESLintSettings = coerceESLintSettings;
293
- exports.coerceSettings = coerceSettings;
294
- exports.decodeESLintSettings = decodeESLintSettings;
295
- exports.decodeSettings = decodeSettings;
296
- exports.defineSettings = defineSettings;
297
- exports.getDocsUrl = getDocsUrl;
298
- exports.getId = getId;
299
- exports.getReactVersion = getReactVersion;
300
- exports.getSettingsFromContext = getSettingsFromContext;
301
- exports.isESLintReactSettings = isESLintReactSettings;
302
- exports.isESLintSettings = isESLintSettings;
303
- 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": "2.0.0-next.0",
3
+ "version": "2.0.0-next.2",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -14,22 +14,14 @@
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"
@@ -38,8 +30,8 @@
38
30
  "@typescript-eslint/utils": "^8.30.1",
39
31
  "@zod/mini": "^4.0.0-beta.20250418T073619",
40
32
  "ts-pattern": "^5.7.0",
41
- "@eslint-react/eff": "2.0.0-next.0",
42
- "@eslint-react/kit": "2.0.0-next.0"
33
+ "@eslint-react/eff": "2.0.0-next.2",
34
+ "@eslint-react/kit": "2.0.0-next.2"
43
35
  },
44
36
  "devDependencies": {
45
37
  "@tsconfig/node22": "^22.0.1",