@eslint-react/shared 1.43.1-next.0 → 1.43.2-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.js CHANGED
@@ -3,13 +3,32 @@
3
3
  var module$1 = require('module');
4
4
  var eff = require('@eslint-react/eff');
5
5
  var tsPattern = require('ts-pattern');
6
- var valibot = require('valibot');
6
+ var z = require('@zod/mini');
7
7
  var pm = require('picomatch');
8
8
 
9
9
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
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
+
12
30
  var module__default = /*#__PURE__*/_interopDefault(module$1);
31
+ var z__namespace = /*#__PURE__*/_interopNamespace(z);
13
32
  var pm__default = /*#__PURE__*/_interopDefault(pm);
14
33
 
15
34
  // src/constants.ts
@@ -36,152 +55,153 @@ function getReactVersion(fallback = "19.0.0") {
36
55
  return fallback;
37
56
  }
38
57
  }
39
- var CustomComponentPropSchema = valibot.object({
58
+ var CustomComponentPropSchema = z__namespace.object({
40
59
  /**
41
60
  * The name of the prop in the user-defined component.
42
61
  * @example
43
62
  * "to"
44
63
  */
45
- name: valibot.string(),
64
+ name: z__namespace.string(),
46
65
  /**
47
66
  * The name of the prop in the host component.
48
67
  * @example
49
68
  * "href"
50
69
  */
51
- as: valibot.optional(valibot.string()),
70
+ as: z__namespace.optional(z__namespace.string()),
52
71
  /**
53
72
  * Whether the prop is controlled or not in the user-defined component.
54
73
  * @internal
55
74
  * @example
56
75
  * `true`
57
76
  */
58
- controlled: valibot.optional(valibot.boolean()),
77
+ controlled: z__namespace.optional(z__namespace.boolean()),
59
78
  /**
60
79
  * The default value of the prop in the user-defined component.
61
80
  * @example
62
81
  * `"/"`
63
82
  */
64
- defaultValue: valibot.optional(valibot.string())
83
+ defaultValue: z__namespace.optional(z__namespace.string())
65
84
  });
66
- var CustomComponentSchema = valibot.object({
85
+ var CustomComponentSchema = z__namespace.object({
67
86
  /**
68
87
  * The name of the user-defined component.
69
88
  * @example
70
89
  * "Link"
71
90
  */
72
- name: valibot.string(),
91
+ name: z__namespace.string(),
73
92
  /**
74
93
  * The name of the host component that the user-defined component represents.
75
94
  * @example
76
95
  * "a"
77
96
  */
78
- as: valibot.optional(valibot.string()),
97
+ as: z__namespace.optional(z__namespace.string()),
79
98
  /**
80
99
  * Attributes mapping between the user-defined component and the host component.
81
100
  * @example
82
101
  * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
83
102
  */
84
- attributes: valibot.optional(valibot.array(CustomComponentPropSchema)),
103
+ attributes: z__namespace.optional(z__namespace.array(CustomComponentPropSchema)),
85
104
  /**
86
105
  * The ESQuery selector to select the component precisely.
87
106
  * @internal
88
107
  * @example
89
108
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
90
109
  */
91
- selector: valibot.optional(valibot.string())
110
+ selector: z__namespace.optional(z__namespace.string())
92
111
  });
93
- var CustomHooksSchema = valibot.object({
94
- use: valibot.optional(valibot.array(valibot.string())),
95
- useActionState: valibot.optional(valibot.array(valibot.string())),
96
- useCallback: valibot.optional(valibot.array(valibot.string())),
97
- useContext: valibot.optional(valibot.array(valibot.string())),
98
- useDebugValue: valibot.optional(valibot.array(valibot.string())),
99
- useDeferredValue: valibot.optional(valibot.array(valibot.string())),
100
- useEffect: valibot.optional(valibot.array(valibot.string())),
101
- useFormStatus: valibot.optional(valibot.array(valibot.string())),
102
- useId: valibot.optional(valibot.array(valibot.string())),
103
- useImperativeHandle: valibot.optional(valibot.array(valibot.string())),
104
- useInsertionEffect: valibot.optional(valibot.array(valibot.string())),
105
- useLayoutEffect: valibot.optional(valibot.array(valibot.string())),
106
- useMemo: valibot.optional(valibot.array(valibot.string())),
107
- useOptimistic: valibot.optional(valibot.array(valibot.string())),
108
- useReducer: valibot.optional(valibot.array(valibot.string())),
109
- useRef: valibot.optional(valibot.array(valibot.string())),
110
- useState: valibot.optional(valibot.array(valibot.string())),
111
- useSyncExternalStore: valibot.optional(valibot.array(valibot.string())),
112
- useTransition: valibot.optional(valibot.array(valibot.string()))
112
+ var CustomHooksSchema = z__namespace.object({
113
+ use: z__namespace.optional(z__namespace.array(z__namespace.string())),
114
+ useActionState: z__namespace.optional(z__namespace.array(z__namespace.string())),
115
+ useCallback: z__namespace.optional(z__namespace.array(z__namespace.string())),
116
+ useContext: z__namespace.optional(z__namespace.array(z__namespace.string())),
117
+ useDebugValue: z__namespace.optional(z__namespace.array(z__namespace.string())),
118
+ useDeferredValue: z__namespace.optional(z__namespace.array(z__namespace.string())),
119
+ useEffect: z__namespace.optional(z__namespace.array(z__namespace.string())),
120
+ useFormStatus: z__namespace.optional(z__namespace.array(z__namespace.string())),
121
+ useId: z__namespace.optional(z__namespace.array(z__namespace.string())),
122
+ useImperativeHandle: z__namespace.optional(z__namespace.array(z__namespace.string())),
123
+ useInsertionEffect: z__namespace.optional(z__namespace.array(z__namespace.string())),
124
+ useLayoutEffect: z__namespace.optional(z__namespace.array(z__namespace.string())),
125
+ useMemo: z__namespace.optional(z__namespace.array(z__namespace.string())),
126
+ useOptimistic: z__namespace.optional(z__namespace.array(z__namespace.string())),
127
+ useReducer: z__namespace.optional(z__namespace.array(z__namespace.string())),
128
+ useRef: z__namespace.optional(z__namespace.array(z__namespace.string())),
129
+ useState: z__namespace.optional(z__namespace.array(z__namespace.string())),
130
+ useSyncExternalStore: z__namespace.optional(z__namespace.array(z__namespace.string())),
131
+ useTransition: z__namespace.optional(z__namespace.array(z__namespace.string()))
113
132
  });
114
- var ESLintReactSettingsSchema = valibot.object({
133
+ var ESLintReactSettingsSchema = z__namespace.object({
115
134
  /**
116
135
  * The source where React is imported from.
117
136
  * @description This allows to specify a custom import location for React when not using the official distribution.
118
137
  * @default `"react"`
119
138
  * @example `"@pika/react"`
120
139
  */
121
- importSource: valibot.optional(valibot.string()),
140
+ importSource: z__namespace.optional(z__namespace.string()),
122
141
  /**
123
142
  * The identifier that's used for JSX Element creation.
124
143
  * @default `"createElement"`
125
144
  * @deprecated
126
145
  */
127
- jsxPragma: valibot.optional(valibot.string()),
146
+ jsxPragma: z__namespace.optional(z__namespace.string()),
128
147
  /**
129
148
  * The identifier that's used for JSX fragment elements.
130
149
  * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
131
150
  * @default `"Fragment"`
132
151
  * @deprecated
133
152
  */
134
- jsxPragmaFrag: valibot.optional(valibot.string()),
153
+ jsxPragmaFrag: z__namespace.optional(z__namespace.string()),
135
154
  /**
136
155
  * The name of the prop that is used for polymorphic components.
137
156
  * @description This is used to determine the type of the component.
138
157
  * @example `"as"`
139
158
  */
140
- polymorphicPropName: valibot.optional(valibot.string()),
159
+ polymorphicPropName: z__namespace.optional(z__namespace.string()),
141
160
  /**
142
161
  * @internal
143
162
  */
144
- strict: valibot.optional(valibot.boolean(), false),
163
+ strict: z__namespace.optional(z__namespace.boolean()),
145
164
  /**
146
165
  * Check both the shape and the import to determine if an API is from React.
147
166
  * @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
148
167
  * @default `true`
149
168
  */
150
- skipImportCheck: valibot.optional(valibot.boolean(), true),
169
+ skipImportCheck: z__namespace.optional(z__namespace.boolean()),
151
170
  /**
152
171
  * React version to use, "detect" means auto detect React version from the project's dependencies.
153
172
  * If `importSource` is specified, an equivalent version of React should be provided here.
154
173
  * @example `"18.3.1"`
155
174
  * @default `"detect"`
156
175
  */
157
- version: valibot.optional(valibot.string()),
176
+ version: z__namespace.optional(z__namespace.string()),
158
177
  /**
159
178
  * A object to define additional hooks that are equivalent to the built-in React Hooks.
160
179
  * @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
161
180
  * @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
162
181
  */
163
- additionalHooks: valibot.optional(CustomHooksSchema),
182
+ additionalHooks: z__namespace.optional(CustomHooksSchema),
164
183
  /**
165
184
  * An array of user-defined components
166
185
  * @description This is used to inform the ESLint React plugins how to treat these components during checks.
167
186
  * @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
168
187
  */
169
- additionalComponents: valibot.optional(valibot.array(CustomComponentSchema))
188
+ additionalComponents: z__namespace.optional(z__namespace.array(CustomComponentSchema))
170
189
  });
171
- var ESLintSettingsSchema = valibot.optional(
172
- valibot.object({
173
- "react-x": valibot.optional(ESLintReactSettingsSchema),
190
+ var ESLintSettingsSchema = z__namespace.optional(
191
+ z__namespace.object({
192
+ "react-x": z__namespace.optional(ESLintReactSettingsSchema),
174
193
  /** @deprecated Use `react-x` instead */
175
- reactOptions: valibot.optional(ESLintReactSettingsSchema)
194
+ reactOptions: z__namespace.optional(ESLintReactSettingsSchema)
176
195
  }),
177
196
  {}
178
197
  );
179
198
  var DEFAULT_ESLINT_REACT_SETTINGS = {
180
- ...valibot.parse(ESLintReactSettingsSchema, {}),
199
+ ...z__namespace.parse(ESLintReactSettingsSchema, {}),
200
+ version: "detect",
181
201
  importSource: "react",
182
- polymorphicPropName: "as",
202
+ strict: false,
183
203
  skipImportCheck: true,
184
- version: "detect",
204
+ polymorphicPropName: "as",
185
205
  additionalHooks: {
186
206
  useEffect: ["useIsomorphicLayoutEffect"],
187
207
  useLayoutEffect: ["useIsomorphicLayoutEffect"]
@@ -887,7 +907,7 @@ function unsafeDecodeSettings(data) {
887
907
  var decodeSettings = createMemoizedFunction((data) => {
888
908
  return {
889
909
  ...DEFAULT_ESLINT_REACT_SETTINGS,
890
- ...valibot.parse(ESLintSettingsSchema, data)["react-x"] ?? {}
910
+ ...z__namespace.parse(ESLintSettingsSchema, data)?.["react-x"] ?? {}
891
911
  };
892
912
  }, { isEqual: (a, b) => a === b });
893
913
  var toNormalizedSettings = createMemoizedFunction(
@@ -897,6 +917,7 @@ var toNormalizedSettings = createMemoizedFunction(
897
917
  importSource = "react",
898
918
  polymorphicPropName = "as",
899
919
  skipImportCheck = true,
920
+ // strict = false,
900
921
  version,
901
922
  ...rest
902
923
  }) => {
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import module from 'node:module';
2
2
  import { identity } from '@eslint-react/eff';
3
3
  import { match, P } from 'ts-pattern';
4
- import { object, optional, string, boolean, array, parse } from 'valibot';
4
+ import * as z from '@zod/mini';
5
5
  import pm from 'picomatch';
6
6
 
7
7
  // src/constants.ts
@@ -28,152 +28,153 @@ function getReactVersion(fallback = "19.0.0") {
28
28
  return fallback;
29
29
  }
30
30
  }
31
- var CustomComponentPropSchema = object({
31
+ var CustomComponentPropSchema = z.object({
32
32
  /**
33
33
  * The name of the prop in the user-defined component.
34
34
  * @example
35
35
  * "to"
36
36
  */
37
- name: string(),
37
+ name: z.string(),
38
38
  /**
39
39
  * The name of the prop in the host component.
40
40
  * @example
41
41
  * "href"
42
42
  */
43
- as: optional(string()),
43
+ as: z.optional(z.string()),
44
44
  /**
45
45
  * Whether the prop is controlled or not in the user-defined component.
46
46
  * @internal
47
47
  * @example
48
48
  * `true`
49
49
  */
50
- controlled: optional(boolean()),
50
+ controlled: z.optional(z.boolean()),
51
51
  /**
52
52
  * The default value of the prop in the user-defined component.
53
53
  * @example
54
54
  * `"/"`
55
55
  */
56
- defaultValue: optional(string())
56
+ defaultValue: z.optional(z.string())
57
57
  });
58
- var CustomComponentSchema = object({
58
+ var CustomComponentSchema = z.object({
59
59
  /**
60
60
  * The name of the user-defined component.
61
61
  * @example
62
62
  * "Link"
63
63
  */
64
- name: string(),
64
+ name: z.string(),
65
65
  /**
66
66
  * The name of the host component that the user-defined component represents.
67
67
  * @example
68
68
  * "a"
69
69
  */
70
- as: optional(string()),
70
+ as: z.optional(z.string()),
71
71
  /**
72
72
  * Attributes mapping between the user-defined component and the host component.
73
73
  * @example
74
74
  * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
75
75
  */
76
- attributes: optional(array(CustomComponentPropSchema)),
76
+ attributes: z.optional(z.array(CustomComponentPropSchema)),
77
77
  /**
78
78
  * The ESQuery selector to select the component precisely.
79
79
  * @internal
80
80
  * @example
81
81
  * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
82
82
  */
83
- selector: optional(string())
83
+ selector: z.optional(z.string())
84
84
  });
85
- var CustomHooksSchema = object({
86
- use: optional(array(string())),
87
- useActionState: optional(array(string())),
88
- useCallback: optional(array(string())),
89
- useContext: optional(array(string())),
90
- useDebugValue: optional(array(string())),
91
- useDeferredValue: optional(array(string())),
92
- useEffect: optional(array(string())),
93
- useFormStatus: optional(array(string())),
94
- useId: optional(array(string())),
95
- useImperativeHandle: optional(array(string())),
96
- useInsertionEffect: optional(array(string())),
97
- useLayoutEffect: optional(array(string())),
98
- useMemo: optional(array(string())),
99
- useOptimistic: optional(array(string())),
100
- useReducer: optional(array(string())),
101
- useRef: optional(array(string())),
102
- useState: optional(array(string())),
103
- useSyncExternalStore: optional(array(string())),
104
- useTransition: optional(array(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()))
105
105
  });
106
- var ESLintReactSettingsSchema = object({
106
+ var ESLintReactSettingsSchema = z.object({
107
107
  /**
108
108
  * The source where React is imported from.
109
109
  * @description This allows to specify a custom import location for React when not using the official distribution.
110
110
  * @default `"react"`
111
111
  * @example `"@pika/react"`
112
112
  */
113
- importSource: optional(string()),
113
+ importSource: z.optional(z.string()),
114
114
  /**
115
115
  * The identifier that's used for JSX Element creation.
116
116
  * @default `"createElement"`
117
117
  * @deprecated
118
118
  */
119
- jsxPragma: optional(string()),
119
+ jsxPragma: z.optional(z.string()),
120
120
  /**
121
121
  * The identifier that's used for JSX fragment elements.
122
122
  * @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
123
123
  * @default `"Fragment"`
124
124
  * @deprecated
125
125
  */
126
- jsxPragmaFrag: optional(string()),
126
+ jsxPragmaFrag: z.optional(z.string()),
127
127
  /**
128
128
  * The name of the prop that is used for polymorphic components.
129
129
  * @description This is used to determine the type of the component.
130
130
  * @example `"as"`
131
131
  */
132
- polymorphicPropName: optional(string()),
132
+ polymorphicPropName: z.optional(z.string()),
133
133
  /**
134
134
  * @internal
135
135
  */
136
- strict: optional(boolean(), false),
136
+ strict: z.optional(z.boolean()),
137
137
  /**
138
138
  * Check both the shape and the import to determine if an API is from React.
139
139
  * @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
140
140
  * @default `true`
141
141
  */
142
- skipImportCheck: optional(boolean(), true),
142
+ skipImportCheck: z.optional(z.boolean()),
143
143
  /**
144
144
  * React version to use, "detect" means auto detect React version from the project's dependencies.
145
145
  * If `importSource` is specified, an equivalent version of React should be provided here.
146
146
  * @example `"18.3.1"`
147
147
  * @default `"detect"`
148
148
  */
149
- version: optional(string()),
149
+ version: z.optional(z.string()),
150
150
  /**
151
151
  * A object to define additional hooks that are equivalent to the built-in React Hooks.
152
152
  * @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
153
153
  * @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
154
154
  */
155
- additionalHooks: optional(CustomHooksSchema),
155
+ additionalHooks: z.optional(CustomHooksSchema),
156
156
  /**
157
157
  * An array of user-defined components
158
158
  * @description This is used to inform the ESLint React plugins how to treat these components during checks.
159
159
  * @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
160
160
  */
161
- additionalComponents: optional(array(CustomComponentSchema))
161
+ additionalComponents: z.optional(z.array(CustomComponentSchema))
162
162
  });
163
- var ESLintSettingsSchema = optional(
164
- object({
165
- "react-x": optional(ESLintReactSettingsSchema),
163
+ var ESLintSettingsSchema = z.optional(
164
+ z.object({
165
+ "react-x": z.optional(ESLintReactSettingsSchema),
166
166
  /** @deprecated Use `react-x` instead */
167
- reactOptions: optional(ESLintReactSettingsSchema)
167
+ reactOptions: z.optional(ESLintReactSettingsSchema)
168
168
  }),
169
169
  {}
170
170
  );
171
171
  var DEFAULT_ESLINT_REACT_SETTINGS = {
172
- ...parse(ESLintReactSettingsSchema, {}),
172
+ ...z.parse(ESLintReactSettingsSchema, {}),
173
+ version: "detect",
173
174
  importSource: "react",
174
- polymorphicPropName: "as",
175
+ strict: false,
175
176
  skipImportCheck: true,
176
- version: "detect",
177
+ polymorphicPropName: "as",
177
178
  additionalHooks: {
178
179
  useEffect: ["useIsomorphicLayoutEffect"],
179
180
  useLayoutEffect: ["useIsomorphicLayoutEffect"]
@@ -879,7 +880,7 @@ function unsafeDecodeSettings(data) {
879
880
  var decodeSettings = createMemoizedFunction((data) => {
880
881
  return {
881
882
  ...DEFAULT_ESLINT_REACT_SETTINGS,
882
- ...parse(ESLintSettingsSchema, data)["react-x"] ?? {}
883
+ ...z.parse(ESLintSettingsSchema, data)?.["react-x"] ?? {}
883
884
  };
884
885
  }, { isEqual: (a, b) => a === b });
885
886
  var toNormalizedSettings = createMemoizedFunction(
@@ -889,6 +890,7 @@ var toNormalizedSettings = createMemoizedFunction(
889
890
  importSource = "react",
890
891
  polymorphicPropName = "as",
891
892
  skipImportCheck = true,
893
+ // strict = false,
892
894
  version,
893
895
  ...rest
894
896
  }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.43.1-next.0",
3
+ "version": "1.43.2-beta.0",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -36,11 +36,11 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@typescript-eslint/utils": "^8.29.1",
39
+ "@zod/mini": "^4.0.0-beta.0",
39
40
  "picomatch": "^4.0.2",
40
41
  "ts-pattern": "^5.7.0",
41
- "valibot": "^1.0.0",
42
- "@eslint-react/eff": "1.43.1-next.0",
43
- "@eslint-react/kit": "1.43.1-next.0"
42
+ "@eslint-react/kit": "1.43.2-beta.0",
43
+ "@eslint-react/eff": "1.43.2-beta.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@tsconfig/node22": "^22.0.1",