@eslint-react/shared 2.0.0-next.0 → 2.0.0-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.js CHANGED
@@ -1,34 +1,8 @@
1
- 'use strict';
2
-
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);
1
+ import module from 'node:module';
2
+ import { identity, getOrElseUpdate } from '@eslint-react/eff';
3
+ import { match, P } from 'ts-pattern';
4
+ import { RegExp } from '@eslint-react/kit';
5
+ import * as z from '@zod/mini';
32
6
 
33
7
  // src/constants.ts
34
8
  var NPM_SCOPE = "@eslint-react";
@@ -46,150 +20,150 @@ var getDocsUrl = (pluginName) => (ruleName) => {
46
20
  // src/get-id.ts
47
21
  var id = 0n;
48
22
  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)));
23
+ var _require = module.createRequire(import.meta.url);
50
24
  function getReactVersion(fallback) {
51
25
  try {
52
- return tsPattern.match(_require("react")).with({ version: tsPattern.P.select(tsPattern.P.string) }, eff.identity).otherwise(() => fallback);
26
+ return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
53
27
  } catch {
54
28
  return fallback;
55
29
  }
56
30
  }
57
- var CustomComponentPropSchema = z__namespace.object({
31
+ var CustomComponentPropSchema = z.object({
58
32
  /**
59
33
  * The name of the prop in the user-defined component.
60
34
  * @example
61
35
  * "to"
62
36
  */
63
- name: z__namespace.string(),
37
+ name: z.string(),
64
38
  /**
65
39
  * The name of the prop in the host component.
66
40
  * @example
67
41
  * "href"
68
42
  */
69
- as: z__namespace.optional(z__namespace.string()),
43
+ as: z.optional(z.string()),
70
44
  /**
71
45
  * Whether the prop is controlled or not in the user-defined component.
72
46
  * @internal
73
47
  * @example
74
48
  * `true`
75
49
  */
76
- controlled: z__namespace.optional(z__namespace.boolean()),
50
+ controlled: z.optional(z.boolean()),
77
51
  /**
78
52
  * The default value of the prop in the user-defined component.
79
53
  * @example
80
54
  * `"/"`
81
55
  */
82
- defaultValue: z__namespace.optional(z__namespace.string())
56
+ defaultValue: z.optional(z.string())
83
57
  });
84
- var CustomComponentSchema = z__namespace.object({
58
+ var CustomComponentSchema = z.object({
85
59
  /**
86
60
  * The name of the user-defined component.
87
61
  * @example
88
62
  * "Link"
89
63
  */
90
- name: z__namespace.string(),
64
+ name: z.string(),
91
65
  /**
92
66
  * The name of the host component that the user-defined component represents.
93
67
  * @example
94
68
  * "a"
95
69
  */
96
- as: z__namespace.optional(z__namespace.string()),
70
+ as: z.optional(z.string()),
97
71
  /**
98
72
  * Attributes mapping between the user-defined component and the host component.
99
73
  * @example
100
74
  * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
101
75
  */
102
- attributes: z__namespace.optional(z__namespace.array(CustomComponentPropSchema)),
76
+ attributes: z.optional(z.array(CustomComponentPropSchema)),
103
77
  /**
104
78
  * The ESQuery selector to select the component precisely.
105
79
  * @internal
106
80
  * @example
107
81
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
108
82
  */
109
- selector: z__namespace.optional(z__namespace.string())
83
+ selector: z.optional(z.string())
110
84
  });
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()))
85
+ var CustomHooksSchema = z.object({
86
+ use: z.optional(z.array(z.string())),
87
+ useActionState: z.optional(z.array(z.string())),
88
+ useCallback: z.optional(z.array(z.string())),
89
+ useContext: z.optional(z.array(z.string())),
90
+ useDebugValue: z.optional(z.array(z.string())),
91
+ useDeferredValue: z.optional(z.array(z.string())),
92
+ useEffect: z.optional(z.array(z.string())),
93
+ useFormStatus: z.optional(z.array(z.string())),
94
+ useId: z.optional(z.array(z.string())),
95
+ useImperativeHandle: z.optional(z.array(z.string())),
96
+ useInsertionEffect: z.optional(z.array(z.string())),
97
+ useLayoutEffect: z.optional(z.array(z.string())),
98
+ useMemo: z.optional(z.array(z.string())),
99
+ useOptimistic: z.optional(z.array(z.string())),
100
+ useReducer: z.optional(z.array(z.string())),
101
+ useRef: z.optional(z.array(z.string())),
102
+ useState: z.optional(z.array(z.string())),
103
+ useSyncExternalStore: z.optional(z.array(z.string())),
104
+ useTransition: z.optional(z.array(z.string()))
131
105
  });
132
- var ESLintReactSettingsSchema = z__namespace.object({
106
+ var ESLintReactSettingsSchema = z.object({
133
107
  /**
134
108
  * The source where React is imported from.
135
109
  * @description This allows to specify a custom import location for React when not using the official distribution.
136
110
  * @default `"react"`
137
111
  * @example `"@pika/react"`
138
112
  */
139
- importSource: z__namespace.optional(z__namespace.string()),
113
+ importSource: z.optional(z.string()),
140
114
  /**
141
115
  * The identifier that's used for JSX Element creation.
142
116
  * @default `"createElement"`
143
117
  * @deprecated
144
118
  */
145
- jsxPragma: z__namespace.optional(z__namespace.string()),
119
+ jsxPragma: z.optional(z.string()),
146
120
  /**
147
121
  * The identifier that's used for JSX fragment elements.
148
122
  * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
149
123
  * @default `"Fragment"`
150
124
  * @deprecated
151
125
  */
152
- jsxPragmaFrag: z__namespace.optional(z__namespace.string()),
126
+ jsxPragmaFrag: z.optional(z.string()),
153
127
  /**
154
128
  * The name of the prop that is used for polymorphic components.
155
129
  * @description This is used to determine the type of the component.
156
130
  * @example `"as"`
157
131
  */
158
- polymorphicPropName: z__namespace.optional(z__namespace.string()),
132
+ polymorphicPropName: z.optional(z.string()),
159
133
  /**
160
134
  * @default `true`
161
135
  * @internal
162
136
  */
163
- strict: z__namespace.optional(z__namespace.boolean()),
137
+ strict: z.optional(z.boolean()),
164
138
  /**
165
139
  * Check both the shape and the import to determine if an API is from React.
166
140
  * @default `true`
167
141
  * @internal
168
142
  */
169
- skipImportCheck: z__namespace.optional(z__namespace.boolean()),
143
+ skipImportCheck: z.optional(z.boolean()),
170
144
  /**
171
145
  * React version to use, "detect" means auto detect React version from the project's dependencies.
172
146
  * If `importSource` is specified, an equivalent version of React should be provided here.
173
147
  * @example `"18.3.1"`
174
148
  * @default `"detect"`
175
149
  */
176
- version: z__namespace.optional(z__namespace.string()),
150
+ version: z.optional(z.string()),
177
151
  /**
178
152
  * A object to define additional hooks that are equivalent to the built-in React Hooks.
179
153
  * @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
180
154
  * @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
181
155
  */
182
- additionalHooks: z__namespace.optional(CustomHooksSchema),
156
+ additionalHooks: z.optional(CustomHooksSchema),
183
157
  /**
184
158
  * An array of user-defined components
185
159
  * @description This is used to inform the ESLint React plugins how to treat these components during checks.
186
160
  * @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
187
161
  */
188
- additionalComponents: z__namespace.optional(z__namespace.array(CustomComponentSchema))
162
+ additionalComponents: z.optional(z.array(CustomComponentSchema))
189
163
  });
190
- var ESLintSettingsSchema = z__namespace.optional(
191
- z__namespace.object({
192
- "react-x": z__namespace.optional(z__namespace.unknown())
164
+ var ESLintSettingsSchema = z.optional(
165
+ z.object({
166
+ "react-x": z.optional(z.unknown())
193
167
  }),
194
168
  {}
195
169
  );
@@ -247,7 +221,7 @@ var normalizeSettings = ({
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(fallbackVersion)).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, 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.1",
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.1",
34
+ "@eslint-react/kit": "2.0.0-next.1"
43
35
  },
44
36
  "devDependencies": {
45
37
  "@tsconfig/node22": "^22.0.1",