@eslint-react/shared 1.52.3-next.9 → 2.0.0-beta.0

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 { unit } from '@eslint-react/eff';
2
2
  import { RuleContext } from '@eslint-react/kit';
3
3
  import { z } from 'zod/v4';
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
  /**
@@ -764,8 +772,6 @@ declare const CustomHooksSchema: z.ZodObject<{
764
772
  */
765
773
  declare const ESLintReactSettingsSchema: z.ZodObject<{
766
774
  importSource: z.ZodOptional<z.ZodString>;
767
- jsxPragma: z.ZodOptional<z.ZodString>;
768
- jsxPragmaFrag: z.ZodOptional<z.ZodString>;
769
775
  polymorphicPropName: z.ZodOptional<z.ZodString>;
770
776
  strict: z.ZodOptional<z.ZodBoolean>;
771
777
  skipImportCheck: z.ZodOptional<z.ZodBoolean>;
@@ -912,8 +918,6 @@ declare const normalizeSettings: ({ additionalComponents, additionalHooks, impor
912
918
  readonly skipImportCheck: boolean;
913
919
  readonly strict: boolean;
914
920
  readonly version: string;
915
- readonly jsxPragma?: string | undefined;
916
- readonly jsxPragmaFrag?: string | undefined;
917
921
  };
918
922
  declare function getSettingsFromContext(context: RuleContext): ESLintReactSettingsNormalized;
919
923
  /**
@@ -928,4 +932,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
928
932
  }
929
933
  }
930
934
 
931
- 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 };
935
+ 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,15 +1,14 @@
1
- 'use strict';
1
+ import module from 'module';
2
+ import path from '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 { z } from 'zod/v4';
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 v4 = require('zod/v4');
8
-
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var module__default = /*#__PURE__*/_interopDefault(module$1);
8
+ // src/_id.ts
9
+ var id = 0n;
10
+ var getId = () => (id++).toString();
11
+ var _require = module.createRequire(process.cwd() + path.sep);
13
12
 
14
13
  // src/constants.ts
15
14
  var NPM_SCOPE = "@eslint-react";
@@ -23,154 +22,136 @@ var getDocsUrl = (pluginName) => (ruleName) => {
23
22
  }
24
23
  return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
25
24
  };
26
-
27
- // src/get-id.ts
28
- var id = 0n;
29
- var getId = () => (id++).toString();
30
- 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)));
31
25
  function getReactVersion(fallback) {
32
26
  try {
33
- 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);
34
28
  } catch {
35
29
  return fallback;
36
30
  }
37
31
  }
38
- var CustomComponentPropSchema = v4.z.object({
32
+ var CustomComponentPropSchema = z.object({
39
33
  /**
40
34
  * The name of the prop in the user-defined component.
41
35
  * @example
42
36
  * "to"
43
37
  */
44
- name: v4.z.string(),
38
+ name: z.string(),
45
39
  /**
46
40
  * The name of the prop in the host component.
47
41
  * @example
48
42
  * "href"
49
43
  */
50
- as: v4.z.optional(v4.z.string()),
44
+ as: z.optional(z.string()),
51
45
  /**
52
46
  * Whether the prop is controlled or not in the user-defined component.
53
47
  * @internal
54
48
  * @example
55
49
  * `true`
56
50
  */
57
- controlled: v4.z.optional(v4.z.boolean()),
51
+ controlled: z.optional(z.boolean()),
58
52
  /**
59
53
  * The default value of the prop in the user-defined component.
60
54
  * @example
61
55
  * `"/"`
62
56
  */
63
- defaultValue: v4.z.optional(v4.z.string())
57
+ defaultValue: z.optional(z.string())
64
58
  });
65
- var CustomComponentSchema = v4.z.object({
59
+ var CustomComponentSchema = z.object({
66
60
  /**
67
61
  * The name of the user-defined component.
68
62
  * @example
69
63
  * "Link"
70
64
  */
71
- name: v4.z.string(),
65
+ name: z.string(),
72
66
  /**
73
67
  * The name of the host component that the user-defined component represents.
74
68
  * @example
75
69
  * "a"
76
70
  */
77
- as: v4.z.optional(v4.z.string()),
71
+ as: z.optional(z.string()),
78
72
  /**
79
73
  * Attributes mapping between the user-defined component and the host component.
80
74
  * @example
81
75
  * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
82
76
  */
83
- attributes: v4.z.optional(v4.z.array(CustomComponentPropSchema)),
77
+ attributes: z.optional(z.array(CustomComponentPropSchema)),
84
78
  /**
85
79
  * The ESQuery selector to select the component precisely.
86
80
  * @internal
87
81
  * @example
88
82
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
89
83
  */
90
- selector: v4.z.optional(v4.z.string())
84
+ selector: z.optional(z.string())
91
85
  });
92
- var CustomHooksSchema = v4.z.object({
93
- use: v4.z.optional(v4.z.array(v4.z.string())),
94
- useActionState: v4.z.optional(v4.z.array(v4.z.string())),
95
- useCallback: v4.z.optional(v4.z.array(v4.z.string())),
96
- useContext: v4.z.optional(v4.z.array(v4.z.string())),
97
- useDebugValue: v4.z.optional(v4.z.array(v4.z.string())),
98
- useDeferredValue: v4.z.optional(v4.z.array(v4.z.string())),
99
- useEffect: v4.z.optional(v4.z.array(v4.z.string())),
100
- useFormStatus: v4.z.optional(v4.z.array(v4.z.string())),
101
- useId: v4.z.optional(v4.z.array(v4.z.string())),
102
- useImperativeHandle: v4.z.optional(v4.z.array(v4.z.string())),
103
- useInsertionEffect: v4.z.optional(v4.z.array(v4.z.string())),
104
- useLayoutEffect: v4.z.optional(v4.z.array(v4.z.string())),
105
- useMemo: v4.z.optional(v4.z.array(v4.z.string())),
106
- useOptimistic: v4.z.optional(v4.z.array(v4.z.string())),
107
- useReducer: v4.z.optional(v4.z.array(v4.z.string())),
108
- useRef: v4.z.optional(v4.z.array(v4.z.string())),
109
- useState: v4.z.optional(v4.z.array(v4.z.string())),
110
- useSyncExternalStore: v4.z.optional(v4.z.array(v4.z.string())),
111
- useTransition: v4.z.optional(v4.z.array(v4.z.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()))
112
106
  });
113
- var ESLintReactSettingsSchema = v4.z.object({
107
+ var ESLintReactSettingsSchema = z.object({
114
108
  /**
115
109
  * The source where React is imported from.
116
110
  * @description This allows to specify a custom import location for React when not using the official distribution.
117
111
  * @default `"react"`
118
112
  * @example `"@pika/react"`
119
113
  */
120
- importSource: v4.z.optional(v4.z.string()),
121
- /**
122
- * The identifier that's used for JSX Element creation.
123
- * @default `"createElement"`
124
- * @deprecated
125
- */
126
- jsxPragma: v4.z.optional(v4.z.string()),
127
- /**
128
- * The identifier that's used for JSX fragment elements.
129
- * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
130
- * @default `"Fragment"`
131
- * @deprecated
132
- */
133
- jsxPragmaFrag: v4.z.optional(v4.z.string()),
114
+ importSource: z.optional(z.string()),
134
115
  /**
135
116
  * The name of the prop that is used for polymorphic components.
136
117
  * @description This is used to determine the type of the component.
137
118
  * @example `"as"`
138
119
  */
139
- polymorphicPropName: v4.z.optional(v4.z.string()),
120
+ polymorphicPropName: z.optional(z.string()),
140
121
  /**
141
122
  * @default `true`
142
123
  * @internal
143
124
  */
144
- strict: v4.z.optional(v4.z.boolean()),
125
+ strict: z.optional(z.boolean()),
145
126
  /**
146
127
  * Check both the shape and the import to determine if an API is from React.
147
128
  * @default `true`
148
129
  * @internal
149
130
  */
150
- skipImportCheck: v4.z.optional(v4.z.boolean()),
131
+ skipImportCheck: z.optional(z.boolean()),
151
132
  /**
152
133
  * React version to use, "detect" means auto detect React version from the project's dependencies.
153
134
  * If `importSource` is specified, an equivalent version of React should be provided here.
154
135
  * @example `"18.3.1"`
155
136
  * @default `"detect"`
156
137
  */
157
- version: v4.z.optional(v4.z.string()),
138
+ version: z.optional(z.string()),
158
139
  /**
159
140
  * A object to define additional hooks that are equivalent to the built-in React Hooks.
160
141
  * @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
161
142
  * @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
162
143
  */
163
- additionalHooks: v4.z.optional(CustomHooksSchema),
144
+ additionalHooks: z.optional(CustomHooksSchema),
164
145
  /**
165
146
  * An array of user-defined components
166
147
  * @description This is used to inform the ESLint React plugins how to treat these components during checks.
167
148
  * @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
168
149
  */
169
- additionalComponents: v4.z.optional(v4.z.array(CustomComponentSchema))
150
+ additionalComponents: z.optional(z.array(CustomComponentSchema))
170
151
  });
171
- var ESLintSettingsSchema = v4.z.optional(
172
- v4.z.object({
173
- "react-x": v4.z.optional(v4.z.unknown())
152
+ var ESLintSettingsSchema = z.optional(
153
+ z.object({
154
+ "react-x": z.optional(z.unknown())
174
155
  })
175
156
  );
176
157
  function isESLintSettings(settings) {
@@ -226,7 +207,7 @@ var normalizeSettings = ({
226
207
  ...rest,
227
208
  components: additionalComponents.map((component) => {
228
209
  const { name, as = name, attributes = [], ...rest2 } = component;
229
- const re = kit.RegExp.toRegExp(name);
210
+ const re = RegExp.toRegExp(name);
230
211
  return {
231
212
  ...rest2,
232
213
  name,
@@ -244,39 +225,18 @@ var normalizeSettings = ({
244
225
  polymorphicPropName,
245
226
  skipImportCheck,
246
227
  strict,
247
- version: tsPattern.match(version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(eff.identity)
228
+ version: match(version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.1.0")).otherwise(identity)
248
229
  };
249
230
  };
250
231
  var cache = /* @__PURE__ */ new Map();
251
232
  function getSettingsFromContext(context) {
252
233
  const settings = context.settings;
253
- return eff.getOrElseUpdate(
234
+ return getOrElseUpdate(
254
235
  cache,
255
236
  settings["react-x"],
256
237
  () => normalizeSettings(decodeSettings(settings["react-x"]))
257
238
  );
258
239
  }
259
- var defineSettings = eff.identity;
240
+ var defineSettings = identity;
260
241
 
261
- exports.CustomComponentPropSchema = CustomComponentPropSchema;
262
- exports.CustomComponentSchema = CustomComponentSchema;
263
- exports.CustomHooksSchema = CustomHooksSchema;
264
- exports.DEFAULT_ESLINT_REACT_SETTINGS = DEFAULT_ESLINT_REACT_SETTINGS;
265
- exports.DEFAULT_ESLINT_SETTINGS = DEFAULT_ESLINT_SETTINGS;
266
- exports.ESLintReactSettingsSchema = ESLintReactSettingsSchema;
267
- exports.ESLintSettingsSchema = ESLintSettingsSchema;
268
- exports.GITHUB_URL = GITHUB_URL;
269
- exports.NPM_SCOPE = NPM_SCOPE;
270
- exports.WEBSITE_URL = WEBSITE_URL;
271
- exports.coerceESLintSettings = coerceESLintSettings;
272
- exports.coerceSettings = coerceSettings;
273
- exports.decodeESLintSettings = decodeESLintSettings;
274
- exports.decodeSettings = decodeSettings;
275
- exports.defineSettings = defineSettings;
276
- exports.getDocsUrl = getDocsUrl;
277
- exports.getId = getId;
278
- exports.getReactVersion = getReactVersion;
279
- exports.getSettingsFromContext = getSettingsFromContext;
280
- exports.isESLintReactSettings = isESLintReactSettings;
281
- exports.isESLintSettings = isESLintSettings;
282
- exports.normalizeSettings = normalizeSettings;
242
+ 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.52.3-next.9",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -14,32 +14,24 @@
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.35.1",
30
+ "@typescript-eslint/utils": "^8.35.0",
39
31
  "ts-pattern": "^5.7.1",
40
32
  "zod": "^3.25.67",
41
- "@eslint-react/eff": "1.52.3-next.9",
42
- "@eslint-react/kit": "1.52.3-next.9"
33
+ "@eslint-react/eff": "2.0.0-beta.0",
34
+ "@eslint-react/kit": "2.0.0-beta.0"
43
35
  },
44
36
  "devDependencies": {
45
37
  "@tsconfig/node22": "^22.0.2",
@@ -50,7 +42,7 @@
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",