@eslint-react/shared 1.48.2 → 1.48.3-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.d.mts +307 -308
- package/dist/index.d.ts +307 -308
- package/dist/index.js +19 -19
- package/dist/index.mjs +19 -19
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as z from '@zod/mini';
|
|
2
1
|
import { _ } from '@eslint-react/eff';
|
|
3
2
|
import { RuleContext } from '@eslint-react/kit';
|
|
3
|
+
import * as z from '@zod/mini';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The NPM scope for this project.
|
|
@@ -25,290 +25,7 @@ declare const getDocsUrl: (pluginName: string) => (ruleName: string) => string;
|
|
|
25
25
|
|
|
26
26
|
declare const getId: () => string;
|
|
27
27
|
|
|
28
|
-
declare function getReactVersion(fallback
|
|
29
|
-
|
|
30
|
-
declare const CustomComponentPropSchema: z.ZodMiniObject<{
|
|
31
|
-
/**
|
|
32
|
-
* The name of the prop in the user-defined component.
|
|
33
|
-
* @example
|
|
34
|
-
* "to"
|
|
35
|
-
*/
|
|
36
|
-
name: z.ZodMiniString<string>;
|
|
37
|
-
/**
|
|
38
|
-
* The name of the prop in the host component.
|
|
39
|
-
* @example
|
|
40
|
-
* "href"
|
|
41
|
-
*/
|
|
42
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
-
/**
|
|
44
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
45
|
-
* @internal
|
|
46
|
-
* @example
|
|
47
|
-
* `true`
|
|
48
|
-
*/
|
|
49
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
50
|
-
/**
|
|
51
|
-
* The default value of the prop in the user-defined component.
|
|
52
|
-
* @example
|
|
53
|
-
* `"/"`
|
|
54
|
-
*/
|
|
55
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
56
|
-
}, {}>;
|
|
57
|
-
/**
|
|
58
|
-
* @description
|
|
59
|
-
* This will provide some key information to the rule before checking for user-defined components.
|
|
60
|
-
* For example:
|
|
61
|
-
* Which prop is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
|
|
62
|
-
*/
|
|
63
|
-
declare const CustomComponentSchema: z.ZodMiniObject<{
|
|
64
|
-
/**
|
|
65
|
-
* The name of the user-defined component.
|
|
66
|
-
* @example
|
|
67
|
-
* "Link"
|
|
68
|
-
*/
|
|
69
|
-
name: z.ZodMiniString<string>;
|
|
70
|
-
/**
|
|
71
|
-
* The name of the host component that the user-defined component represents.
|
|
72
|
-
* @example
|
|
73
|
-
* "a"
|
|
74
|
-
*/
|
|
75
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
76
|
-
/**
|
|
77
|
-
* Attributes mapping between the user-defined component and the host component.
|
|
78
|
-
* @example
|
|
79
|
-
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
80
|
-
*/
|
|
81
|
-
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
82
|
-
/**
|
|
83
|
-
* The name of the prop in the user-defined component.
|
|
84
|
-
* @example
|
|
85
|
-
* "to"
|
|
86
|
-
*/
|
|
87
|
-
name: z.ZodMiniString<string>;
|
|
88
|
-
/**
|
|
89
|
-
* The name of the prop in the host component.
|
|
90
|
-
* @example
|
|
91
|
-
* "href"
|
|
92
|
-
*/
|
|
93
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
94
|
-
/**
|
|
95
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
96
|
-
* @internal
|
|
97
|
-
* @example
|
|
98
|
-
* `true`
|
|
99
|
-
*/
|
|
100
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
101
|
-
/**
|
|
102
|
-
* The default value of the prop in the user-defined component.
|
|
103
|
-
* @example
|
|
104
|
-
* `"/"`
|
|
105
|
-
*/
|
|
106
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
107
|
-
}, {}>>>;
|
|
108
|
-
/**
|
|
109
|
-
* The ESQuery selector to select the component precisely.
|
|
110
|
-
* @internal
|
|
111
|
-
* @example
|
|
112
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
113
|
-
*/
|
|
114
|
-
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
115
|
-
}, {}>;
|
|
116
|
-
declare const CustomHooksSchema: z.ZodMiniObject<{
|
|
117
|
-
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
118
|
-
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
119
|
-
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
120
|
-
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
121
|
-
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
122
|
-
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
123
|
-
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
124
|
-
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
125
|
-
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
126
|
-
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
127
|
-
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
128
|
-
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
129
|
-
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
130
|
-
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
131
|
-
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
132
|
-
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
133
|
-
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
134
|
-
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
135
|
-
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
136
|
-
}, {}>;
|
|
137
|
-
/**
|
|
138
|
-
* @internal
|
|
139
|
-
*/
|
|
140
|
-
declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
|
|
141
|
-
/**
|
|
142
|
-
* The source where React is imported from.
|
|
143
|
-
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
144
|
-
* @default `"react"`
|
|
145
|
-
* @example `"@pika/react"`
|
|
146
|
-
*/
|
|
147
|
-
importSource: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
148
|
-
/**
|
|
149
|
-
* The identifier that's used for JSX Element creation.
|
|
150
|
-
* @default `"createElement"`
|
|
151
|
-
* @deprecated
|
|
152
|
-
*/
|
|
153
|
-
jsxPragma: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
154
|
-
/**
|
|
155
|
-
* The identifier that's used for JSX fragment elements.
|
|
156
|
-
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
157
|
-
* @default `"Fragment"`
|
|
158
|
-
* @deprecated
|
|
159
|
-
*/
|
|
160
|
-
jsxPragmaFrag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
161
|
-
/**
|
|
162
|
-
* The name of the prop that is used for polymorphic components.
|
|
163
|
-
* @description This is used to determine the type of the component.
|
|
164
|
-
* @example `"as"`
|
|
165
|
-
*/
|
|
166
|
-
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
167
|
-
/**
|
|
168
|
-
* @default `true`
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
172
|
-
/**
|
|
173
|
-
* Check both the shape and the import to determine if an API is from React.
|
|
174
|
-
* @default `true`
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
178
|
-
/**
|
|
179
|
-
* React version to use, "detect" means auto detect React version from the project's dependencies.
|
|
180
|
-
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
181
|
-
* @example `"18.3.1"`
|
|
182
|
-
* @default `"detect"`
|
|
183
|
-
*/
|
|
184
|
-
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
185
|
-
/**
|
|
186
|
-
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
187
|
-
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
188
|
-
* @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
|
|
189
|
-
*/
|
|
190
|
-
additionalHooks: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
191
|
-
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
192
|
-
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
193
|
-
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
194
|
-
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
195
|
-
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
196
|
-
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
197
|
-
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
198
|
-
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
199
|
-
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
200
|
-
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
201
|
-
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
202
|
-
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
203
|
-
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
204
|
-
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
205
|
-
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
206
|
-
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
207
|
-
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
208
|
-
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
209
|
-
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
210
|
-
}, {}>>;
|
|
211
|
-
/**
|
|
212
|
-
* An array of user-defined components
|
|
213
|
-
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
214
|
-
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
215
|
-
*/
|
|
216
|
-
additionalComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
217
|
-
/**
|
|
218
|
-
* The name of the user-defined component.
|
|
219
|
-
* @example
|
|
220
|
-
* "Link"
|
|
221
|
-
*/
|
|
222
|
-
name: z.ZodMiniString<string>;
|
|
223
|
-
/**
|
|
224
|
-
* The name of the host component that the user-defined component represents.
|
|
225
|
-
* @example
|
|
226
|
-
* "a"
|
|
227
|
-
*/
|
|
228
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
229
|
-
/**
|
|
230
|
-
* Attributes mapping between the user-defined component and the host component.
|
|
231
|
-
* @example
|
|
232
|
-
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
233
|
-
*/
|
|
234
|
-
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
235
|
-
/**
|
|
236
|
-
* The name of the prop in the user-defined component.
|
|
237
|
-
* @example
|
|
238
|
-
* "to"
|
|
239
|
-
*/
|
|
240
|
-
name: z.ZodMiniString<string>;
|
|
241
|
-
/**
|
|
242
|
-
* The name of the prop in the host component.
|
|
243
|
-
* @example
|
|
244
|
-
* "href"
|
|
245
|
-
*/
|
|
246
|
-
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
247
|
-
/**
|
|
248
|
-
* Whether the prop is controlled or not in the user-defined component.
|
|
249
|
-
* @internal
|
|
250
|
-
* @example
|
|
251
|
-
* `true`
|
|
252
|
-
*/
|
|
253
|
-
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
254
|
-
/**
|
|
255
|
-
* The default value of the prop in the user-defined component.
|
|
256
|
-
* @example
|
|
257
|
-
* `"/"`
|
|
258
|
-
*/
|
|
259
|
-
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
260
|
-
}, {}>>>;
|
|
261
|
-
/**
|
|
262
|
-
* The ESQuery selector to select the component precisely.
|
|
263
|
-
* @internal
|
|
264
|
-
* @example
|
|
265
|
-
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
266
|
-
*/
|
|
267
|
-
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
268
|
-
}, {}>>>;
|
|
269
|
-
}, {}>;
|
|
270
|
-
/**
|
|
271
|
-
* @internal
|
|
272
|
-
*/
|
|
273
|
-
declare const ESLintSettingsSchema: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
274
|
-
"react-x": z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
275
|
-
}, {}>>;
|
|
276
|
-
type CustomComponent = z.infer<typeof CustomComponentSchema>;
|
|
277
|
-
type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
|
|
278
|
-
type CustomHooks = z.infer<typeof CustomHooksSchema>;
|
|
279
|
-
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
280
|
-
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
281
|
-
declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
|
|
282
|
-
declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
|
|
283
|
-
/**
|
|
284
|
-
* The default ESLint settings for "react-x".
|
|
285
|
-
*/
|
|
286
|
-
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
287
|
-
readonly version: "detect";
|
|
288
|
-
readonly importSource: "react";
|
|
289
|
-
readonly strict: true;
|
|
290
|
-
readonly skipImportCheck: true;
|
|
291
|
-
readonly polymorphicPropName: "as";
|
|
292
|
-
readonly additionalComponents: [];
|
|
293
|
-
readonly additionalHooks: {
|
|
294
|
-
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
295
|
-
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
296
|
-
};
|
|
297
|
-
};
|
|
298
|
-
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
299
|
-
readonly "react-x": {
|
|
300
|
-
readonly version: "detect";
|
|
301
|
-
readonly importSource: "react";
|
|
302
|
-
readonly strict: true;
|
|
303
|
-
readonly skipImportCheck: true;
|
|
304
|
-
readonly polymorphicPropName: "as";
|
|
305
|
-
readonly additionalComponents: [];
|
|
306
|
-
readonly additionalHooks: {
|
|
307
|
-
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
308
|
-
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
|
-
};
|
|
28
|
+
declare function getReactVersion(fallback: string): string;
|
|
312
29
|
|
|
313
30
|
/**
|
|
314
31
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
@@ -977,22 +694,309 @@ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `P
|
|
|
977
694
|
type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
978
695
|
|
|
979
696
|
/**
|
|
980
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
981
|
-
*/
|
|
982
|
-
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
983
|
-
|
|
697
|
+
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
698
|
+
*/
|
|
699
|
+
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
703
|
+
*/
|
|
704
|
+
type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
708
|
+
*/
|
|
709
|
+
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = {
|
|
710
|
+
[KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
declare const CustomComponentPropSchema: z.ZodMiniObject<{
|
|
714
|
+
/**
|
|
715
|
+
* The name of the prop in the user-defined component.
|
|
716
|
+
* @example
|
|
717
|
+
* "to"
|
|
718
|
+
*/
|
|
719
|
+
name: z.ZodMiniString<string>;
|
|
720
|
+
/**
|
|
721
|
+
* The name of the prop in the host component.
|
|
722
|
+
* @example
|
|
723
|
+
* "href"
|
|
724
|
+
*/
|
|
725
|
+
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
726
|
+
/**
|
|
727
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
728
|
+
* @internal
|
|
729
|
+
* @example
|
|
730
|
+
* `true`
|
|
731
|
+
*/
|
|
732
|
+
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
733
|
+
/**
|
|
734
|
+
* The default value of the prop in the user-defined component.
|
|
735
|
+
* @example
|
|
736
|
+
* `"/"`
|
|
737
|
+
*/
|
|
738
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
739
|
+
}, {}>;
|
|
740
|
+
/**
|
|
741
|
+
* @description
|
|
742
|
+
* This will provide some key information to the rule before checking for user-defined components.
|
|
743
|
+
* For example:
|
|
744
|
+
* Which prop is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
|
|
745
|
+
*/
|
|
746
|
+
declare const CustomComponentSchema: z.ZodMiniObject<{
|
|
747
|
+
/**
|
|
748
|
+
* The name of the user-defined component.
|
|
749
|
+
* @example
|
|
750
|
+
* "Link"
|
|
751
|
+
*/
|
|
752
|
+
name: z.ZodMiniString<string>;
|
|
753
|
+
/**
|
|
754
|
+
* The name of the host component that the user-defined component represents.
|
|
755
|
+
* @example
|
|
756
|
+
* "a"
|
|
757
|
+
*/
|
|
758
|
+
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
759
|
+
/**
|
|
760
|
+
* Attributes mapping between the user-defined component and the host component.
|
|
761
|
+
* @example
|
|
762
|
+
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
763
|
+
*/
|
|
764
|
+
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
765
|
+
/**
|
|
766
|
+
* The name of the prop in the user-defined component.
|
|
767
|
+
* @example
|
|
768
|
+
* "to"
|
|
769
|
+
*/
|
|
770
|
+
name: z.ZodMiniString<string>;
|
|
771
|
+
/**
|
|
772
|
+
* The name of the prop in the host component.
|
|
773
|
+
* @example
|
|
774
|
+
* "href"
|
|
775
|
+
*/
|
|
776
|
+
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
777
|
+
/**
|
|
778
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
779
|
+
* @internal
|
|
780
|
+
* @example
|
|
781
|
+
* `true`
|
|
782
|
+
*/
|
|
783
|
+
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
784
|
+
/**
|
|
785
|
+
* The default value of the prop in the user-defined component.
|
|
786
|
+
* @example
|
|
787
|
+
* `"/"`
|
|
788
|
+
*/
|
|
789
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
790
|
+
}, {}>>>;
|
|
791
|
+
/**
|
|
792
|
+
* The ESQuery selector to select the component precisely.
|
|
793
|
+
* @internal
|
|
794
|
+
* @example
|
|
795
|
+
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
796
|
+
*/
|
|
797
|
+
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
798
|
+
}, {}>;
|
|
799
|
+
declare const CustomHooksSchema: z.ZodMiniObject<{
|
|
800
|
+
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
801
|
+
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
802
|
+
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
803
|
+
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
804
|
+
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
805
|
+
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
806
|
+
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
807
|
+
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
808
|
+
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
809
|
+
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
810
|
+
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
811
|
+
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
812
|
+
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
813
|
+
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
814
|
+
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
815
|
+
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
816
|
+
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
817
|
+
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
818
|
+
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
819
|
+
}, {}>;
|
|
820
|
+
/**
|
|
821
|
+
* @internal
|
|
822
|
+
*/
|
|
823
|
+
declare const ESLintReactSettingsSchema: z.ZodMiniObject<{
|
|
824
|
+
/**
|
|
825
|
+
* The source where React is imported from.
|
|
826
|
+
* @description This allows to specify a custom import location for React when not using the official distribution.
|
|
827
|
+
* @default `"react"`
|
|
828
|
+
* @example `"@pika/react"`
|
|
829
|
+
*/
|
|
830
|
+
importSource: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
831
|
+
/**
|
|
832
|
+
* The identifier that's used for JSX Element creation.
|
|
833
|
+
* @default `"createElement"`
|
|
834
|
+
* @deprecated
|
|
835
|
+
*/
|
|
836
|
+
jsxPragma: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
837
|
+
/**
|
|
838
|
+
* The identifier that's used for JSX fragment elements.
|
|
839
|
+
* @description This should not be a member expression (i.e. use "Fragment" instead of "React.Fragment").
|
|
840
|
+
* @default `"Fragment"`
|
|
841
|
+
* @deprecated
|
|
842
|
+
*/
|
|
843
|
+
jsxPragmaFrag: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
844
|
+
/**
|
|
845
|
+
* The name of the prop that is used for polymorphic components.
|
|
846
|
+
* @description This is used to determine the type of the component.
|
|
847
|
+
* @example `"as"`
|
|
848
|
+
*/
|
|
849
|
+
polymorphicPropName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
850
|
+
/**
|
|
851
|
+
* @default `true`
|
|
852
|
+
* @internal
|
|
853
|
+
*/
|
|
854
|
+
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
855
|
+
/**
|
|
856
|
+
* Check both the shape and the import to determine if an API is from React.
|
|
857
|
+
* @default `true`
|
|
858
|
+
* @internal
|
|
859
|
+
*/
|
|
860
|
+
skipImportCheck: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
861
|
+
/**
|
|
862
|
+
* React version to use, "detect" means auto detect React version from the project's dependencies.
|
|
863
|
+
* If `importSource` is specified, an equivalent version of React should be provided here.
|
|
864
|
+
* @example `"18.3.1"`
|
|
865
|
+
* @default `"detect"`
|
|
866
|
+
*/
|
|
867
|
+
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
868
|
+
/**
|
|
869
|
+
* A object to define additional hooks that are equivalent to the built-in React Hooks.
|
|
870
|
+
* @description ESLint React will recognize these aliases as equivalent to the built-in hooks in all its rules.
|
|
871
|
+
* @example `{ useEffect: ["useIsomorphicLayoutEffect"] }`
|
|
872
|
+
*/
|
|
873
|
+
additionalHooks: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
874
|
+
use: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
875
|
+
useActionState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
876
|
+
useCallback: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
877
|
+
useContext: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
878
|
+
useDebugValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
879
|
+
useDeferredValue: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
880
|
+
useEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
881
|
+
useFormStatus: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
882
|
+
useId: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
883
|
+
useImperativeHandle: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
884
|
+
useInsertionEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
885
|
+
useLayoutEffect: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
886
|
+
useMemo: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
887
|
+
useOptimistic: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
888
|
+
useReducer: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
889
|
+
useRef: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
890
|
+
useState: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
891
|
+
useSyncExternalStore: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
892
|
+
useTransition: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
893
|
+
}, {}>>;
|
|
894
|
+
/**
|
|
895
|
+
* An array of user-defined components
|
|
896
|
+
* @description This is used to inform the ESLint React plugins how to treat these components during checks.
|
|
897
|
+
* @example `[{ name: "Link", as: "a", attributes: [{ name: "to", as: "href" }, { name: "rel", defaultValue: "noopener noreferrer" }] }]`
|
|
898
|
+
*/
|
|
899
|
+
additionalComponents: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
900
|
+
/**
|
|
901
|
+
* The name of the user-defined component.
|
|
902
|
+
* @example
|
|
903
|
+
* "Link"
|
|
904
|
+
*/
|
|
905
|
+
name: z.ZodMiniString<string>;
|
|
906
|
+
/**
|
|
907
|
+
* The name of the host component that the user-defined component represents.
|
|
908
|
+
* @example
|
|
909
|
+
* "a"
|
|
910
|
+
*/
|
|
911
|
+
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
912
|
+
/**
|
|
913
|
+
* Attributes mapping between the user-defined component and the host component.
|
|
914
|
+
* @example
|
|
915
|
+
* `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
|
|
916
|
+
*/
|
|
917
|
+
attributes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
918
|
+
/**
|
|
919
|
+
* The name of the prop in the user-defined component.
|
|
920
|
+
* @example
|
|
921
|
+
* "to"
|
|
922
|
+
*/
|
|
923
|
+
name: z.ZodMiniString<string>;
|
|
924
|
+
/**
|
|
925
|
+
* The name of the prop in the host component.
|
|
926
|
+
* @example
|
|
927
|
+
* "href"
|
|
928
|
+
*/
|
|
929
|
+
as: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
930
|
+
/**
|
|
931
|
+
* Whether the prop is controlled or not in the user-defined component.
|
|
932
|
+
* @internal
|
|
933
|
+
* @example
|
|
934
|
+
* `true`
|
|
935
|
+
*/
|
|
936
|
+
controlled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
937
|
+
/**
|
|
938
|
+
* The default value of the prop in the user-defined component.
|
|
939
|
+
* @example
|
|
940
|
+
* `"/"`
|
|
941
|
+
*/
|
|
942
|
+
defaultValue: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
943
|
+
}, {}>>>;
|
|
944
|
+
/**
|
|
945
|
+
* The ESQuery selector to select the component precisely.
|
|
946
|
+
* @internal
|
|
947
|
+
* @example
|
|
948
|
+
* `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
|
|
949
|
+
*/
|
|
950
|
+
selector: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
951
|
+
}, {}>>>;
|
|
952
|
+
}, {}>;
|
|
984
953
|
/**
|
|
985
|
-
|
|
986
|
-
*/
|
|
987
|
-
|
|
988
|
-
|
|
954
|
+
* @internal
|
|
955
|
+
*/
|
|
956
|
+
declare const ESLintSettingsSchema: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
957
|
+
"react-x": z.ZodMiniOptional<z.ZodMiniUnknown>;
|
|
958
|
+
}, {}>>;
|
|
959
|
+
type CustomComponent = z.infer<typeof CustomComponentSchema>;
|
|
960
|
+
type CustomComponentProp = z.infer<typeof CustomComponentPropSchema>;
|
|
961
|
+
type CustomHooks = z.infer<typeof CustomHooksSchema>;
|
|
962
|
+
type ESLintSettings = z.infer<typeof ESLintSettingsSchema>;
|
|
963
|
+
type ESLintReactSettings = z.infer<typeof ESLintReactSettingsSchema>;
|
|
964
|
+
declare function isESLintSettings(settings: unknown): settings is ESLintSettings;
|
|
965
|
+
declare function isESLintReactSettings(settings: unknown): settings is ESLintReactSettings;
|
|
989
966
|
/**
|
|
990
|
-
|
|
991
|
-
*/
|
|
992
|
-
|
|
993
|
-
|
|
967
|
+
* The default ESLint settings for "react-x".
|
|
968
|
+
*/
|
|
969
|
+
declare const DEFAULT_ESLINT_REACT_SETTINGS: {
|
|
970
|
+
readonly version: "detect";
|
|
971
|
+
readonly importSource: "react";
|
|
972
|
+
readonly strict: true;
|
|
973
|
+
readonly skipImportCheck: true;
|
|
974
|
+
readonly polymorphicPropName: "as";
|
|
975
|
+
readonly additionalComponents: [];
|
|
976
|
+
readonly additionalHooks: {
|
|
977
|
+
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
978
|
+
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
979
|
+
};
|
|
994
980
|
};
|
|
995
|
-
|
|
981
|
+
declare const DEFAULT_ESLINT_SETTINGS: {
|
|
982
|
+
readonly "react-x": {
|
|
983
|
+
readonly version: "detect";
|
|
984
|
+
readonly importSource: "react";
|
|
985
|
+
readonly strict: true;
|
|
986
|
+
readonly skipImportCheck: true;
|
|
987
|
+
readonly polymorphicPropName: "as";
|
|
988
|
+
readonly additionalComponents: [];
|
|
989
|
+
readonly additionalHooks: {
|
|
990
|
+
readonly useEffect: ["useIsomorphicLayoutEffect"];
|
|
991
|
+
readonly useLayoutEffect: ["useIsomorphicLayoutEffect"];
|
|
992
|
+
};
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
interface CustomComponentPropNormalized {
|
|
996
|
+
name: string;
|
|
997
|
+
as: string;
|
|
998
|
+
defaultValue?: string | _;
|
|
999
|
+
}
|
|
996
1000
|
interface CustomComponentNormalized {
|
|
997
1001
|
name: string;
|
|
998
1002
|
as: string;
|
|
@@ -1001,14 +1005,9 @@ interface CustomComponentNormalized {
|
|
|
1001
1005
|
test(s: string): boolean;
|
|
1002
1006
|
};
|
|
1003
1007
|
}
|
|
1004
|
-
interface CustomComponentPropNormalized {
|
|
1005
|
-
name: string;
|
|
1006
|
-
as: string;
|
|
1007
|
-
defaultValue?: string | _;
|
|
1008
|
-
}
|
|
1009
1008
|
interface ESLintReactSettingsNormalized {
|
|
1010
|
-
additionalComponents: CustomComponentNormalized[];
|
|
1011
1009
|
additionalHooks: CustomHooks;
|
|
1010
|
+
components: CustomComponentNormalized[];
|
|
1012
1011
|
importSource: string;
|
|
1013
1012
|
polymorphicPropName: string | _;
|
|
1014
1013
|
skipImportCheck: boolean;
|
|
@@ -1020,8 +1019,11 @@ declare const decodeESLintSettings: (settings: unknown) => ESLintSettings;
|
|
|
1020
1019
|
declare const coerceSettings: (settings: unknown) => PartialDeep<ESLintReactSettings>;
|
|
1021
1020
|
declare const decodeSettings: (settings: unknown) => ESLintReactSettings;
|
|
1022
1021
|
declare const normalizeSettings: ({ additionalComponents, additionalHooks, importSource, polymorphicPropName, skipImportCheck, strict, version, ...rest }: ESLintReactSettings) => {
|
|
1023
|
-
readonly
|
|
1022
|
+
readonly components: {
|
|
1024
1023
|
name: string;
|
|
1024
|
+
re: {
|
|
1025
|
+
test(s: string): boolean;
|
|
1026
|
+
};
|
|
1025
1027
|
as: string;
|
|
1026
1028
|
attributes: {
|
|
1027
1029
|
name: string;
|
|
@@ -1029,9 +1031,6 @@ declare const normalizeSettings: ({ additionalComponents, additionalHooks, impor
|
|
|
1029
1031
|
controlled?: boolean | undefined;
|
|
1030
1032
|
defaultValue?: string | undefined;
|
|
1031
1033
|
}[];
|
|
1032
|
-
re: {
|
|
1033
|
-
test(s: string): boolean;
|
|
1034
|
-
};
|
|
1035
1034
|
selector?: string | undefined;
|
|
1036
1035
|
}[];
|
|
1037
1036
|
readonly additionalHooks: {
|