@eslint-react/shared 1.6.0-next.1 → 1.6.0-next.3

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 CHANGED
@@ -82,51 +82,7 @@ declare const CustomAttributeSchema: valibot.ObjectSchema<{
82
82
  * Which attribute is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
83
83
  * Which attributes are used as `children` props for a user-defined `Button` component to receive children of that component.
84
84
  */
85
- declare const CustomComponentSchema: valibot.UnionSchema<[valibot.ObjectSchema<{
86
- /**
87
- * The name of the user-defined component.
88
- * @example
89
- * "Link"
90
- */
91
- readonly name: valibot.StringSchema<undefined>;
92
- /**
93
- * The name of the built-in component that the user-defined component represents.
94
- * @example
95
- * "a"
96
- */
97
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
98
- /**
99
- * Pre-defined attributes that are used in the user-defined component.
100
- * @example
101
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
102
- */
103
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
104
- /**
105
- * The name of the attribute in the user-defined component.
106
- * @example
107
- * "to"
108
- */
109
- readonly name: valibot.StringSchema<undefined>;
110
- /**
111
- * The name of the attribute in the built-in component.
112
- * @example
113
- * "href"
114
- */
115
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
116
- /**
117
- * Whether the attribute is controlled or not in the user-defined component.
118
- * @example
119
- * `true`
120
- */
121
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
122
- /**
123
- * The default value of the attribute in the user-defined component.
124
- * @example
125
- * `"/"`
126
- */
127
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
128
- }, undefined>, undefined>, never>;
129
- }, undefined>, valibot.ObjectSchema<{
85
+ declare const CustomComponentSchema: valibot.ObjectSchema<{
130
86
  /**
131
87
  * The name of the user-defined component.
132
88
  * @example
@@ -136,15 +92,15 @@ declare const CustomComponentSchema: valibot.UnionSchema<[valibot.ObjectSchema<{
136
92
  /**
137
93
  * The ESQuery selector to select the component precisely.
138
94
  * @example
139
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
95
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
140
96
  */
141
- readonly selector: valibot.StringSchema<undefined>;
97
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
142
98
  /**
143
99
  * The name of the built-in component that the user-defined component represents.
144
100
  * @example
145
101
  * "a"
146
102
  */
147
- readonly as: valibot.StringSchema<undefined>;
103
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
148
104
  /**
149
105
  * Pre-defined attributes that are used in the user-defined component.
150
106
  * @example
@@ -175,8 +131,8 @@ declare const CustomComponentSchema: valibot.UnionSchema<[valibot.ObjectSchema<{
175
131
  * `"/"`
176
132
  */
177
133
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
178
- }, undefined>, undefined>, never>;
179
- }, undefined>], undefined>;
134
+ }, undefined>, undefined>, readonly []>;
135
+ }, undefined>;
180
136
  /**
181
137
  * @internal
182
138
  */
@@ -186,51 +142,7 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
186
142
  readonly jsxPragmaFrag: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
187
143
  readonly strict: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
188
144
  readonly version: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
189
- readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.UnionSchema<[valibot.ObjectSchema<{
190
- /**
191
- * The name of the user-defined component.
192
- * @example
193
- * "Link"
194
- */
195
- readonly name: valibot.StringSchema<undefined>;
196
- /**
197
- * The name of the built-in component that the user-defined component represents.
198
- * @example
199
- * "a"
200
- */
201
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
202
- /**
203
- * Pre-defined attributes that are used in the user-defined component.
204
- * @example
205
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
206
- */
207
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
208
- /**
209
- * The name of the attribute in the user-defined component.
210
- * @example
211
- * "to"
212
- */
213
- readonly name: valibot.StringSchema<undefined>;
214
- /**
215
- * The name of the attribute in the built-in component.
216
- * @example
217
- * "href"
218
- */
219
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
220
- /**
221
- * Whether the attribute is controlled or not in the user-defined component.
222
- * @example
223
- * `true`
224
- */
225
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
226
- /**
227
- * The default value of the attribute in the user-defined component.
228
- * @example
229
- * `"/"`
230
- */
231
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
232
- }, undefined>, undefined>, never>;
233
- }, undefined>, valibot.ObjectSchema<{
145
+ readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
234
146
  /**
235
147
  * The name of the user-defined component.
236
148
  * @example
@@ -240,15 +152,15 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
240
152
  /**
241
153
  * The ESQuery selector to select the component precisely.
242
154
  * @example
243
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
155
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
244
156
  */
245
- readonly selector: valibot.StringSchema<undefined>;
157
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
246
158
  /**
247
159
  * The name of the built-in component that the user-defined component represents.
248
160
  * @example
249
161
  * "a"
250
162
  */
251
- readonly as: valibot.StringSchema<undefined>;
163
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
252
164
  /**
253
165
  * Pre-defined attributes that are used in the user-defined component.
254
166
  * @example
@@ -279,8 +191,8 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
279
191
  * `"/"`
280
192
  */
281
193
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
282
- }, undefined>, undefined>, never>;
283
- }, undefined>], undefined>, undefined>, never>;
194
+ }, undefined>, undefined>, readonly []>;
195
+ }, undefined>, undefined>, readonly []>;
284
196
  readonly additionalHooks: valibot.OptionalSchema<valibot.ObjectSchema<{
285
197
  readonly use: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
286
198
  readonly useActionState: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
@@ -312,51 +224,7 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
312
224
  readonly jsxPragmaFrag: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
313
225
  readonly strict: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
314
226
  readonly version: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
315
- readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.UnionSchema<[valibot.ObjectSchema<{
316
- /**
317
- * The name of the user-defined component.
318
- * @example
319
- * "Link"
320
- */
321
- readonly name: valibot.StringSchema<undefined>;
322
- /**
323
- * The name of the built-in component that the user-defined component represents.
324
- * @example
325
- * "a"
326
- */
327
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
328
- /**
329
- * Pre-defined attributes that are used in the user-defined component.
330
- * @example
331
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
332
- */
333
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
334
- /**
335
- * The name of the attribute in the user-defined component.
336
- * @example
337
- * "to"
338
- */
339
- readonly name: valibot.StringSchema<undefined>;
340
- /**
341
- * The name of the attribute in the built-in component.
342
- * @example
343
- * "href"
344
- */
345
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
346
- /**
347
- * Whether the attribute is controlled or not in the user-defined component.
348
- * @example
349
- * `true`
350
- */
351
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
352
- /**
353
- * The default value of the attribute in the user-defined component.
354
- * @example
355
- * `"/"`
356
- */
357
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
358
- }, undefined>, undefined>, never>;
359
- }, undefined>, valibot.ObjectSchema<{
227
+ readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
360
228
  /**
361
229
  * The name of the user-defined component.
362
230
  * @example
@@ -366,15 +234,15 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
366
234
  /**
367
235
  * The ESQuery selector to select the component precisely.
368
236
  * @example
369
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
237
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
370
238
  */
371
- readonly selector: valibot.StringSchema<undefined>;
239
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
372
240
  /**
373
241
  * The name of the built-in component that the user-defined component represents.
374
242
  * @example
375
243
  * "a"
376
244
  */
377
- readonly as: valibot.StringSchema<undefined>;
245
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
378
246
  /**
379
247
  * Pre-defined attributes that are used in the user-defined component.
380
248
  * @example
@@ -405,8 +273,8 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
405
273
  * `"/"`
406
274
  */
407
275
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
408
- }, undefined>, undefined>, never>;
409
- }, undefined>], undefined>, undefined>, never>;
276
+ }, undefined>, undefined>, readonly []>;
277
+ }, undefined>, undefined>, readonly []>;
410
278
  readonly additionalHooks: valibot.OptionalSchema<valibot.ObjectSchema<{
411
279
  readonly use: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
412
280
  readonly useActionState: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
@@ -438,51 +306,7 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
438
306
  readonly jsxPragmaFrag: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
439
307
  readonly strict: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
440
308
  readonly version: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
441
- readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.UnionSchema<[valibot.ObjectSchema<{
442
- /**
443
- * The name of the user-defined component.
444
- * @example
445
- * "Link"
446
- */
447
- readonly name: valibot.StringSchema<undefined>;
448
- /**
449
- * The name of the built-in component that the user-defined component represents.
450
- * @example
451
- * "a"
452
- */
453
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
454
- /**
455
- * Pre-defined attributes that are used in the user-defined component.
456
- * @example
457
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
458
- */
459
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
460
- /**
461
- * The name of the attribute in the user-defined component.
462
- * @example
463
- * "to"
464
- */
465
- readonly name: valibot.StringSchema<undefined>;
466
- /**
467
- * The name of the attribute in the built-in component.
468
- * @example
469
- * "href"
470
- */
471
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
472
- /**
473
- * Whether the attribute is controlled or not in the user-defined component.
474
- * @example
475
- * `true`
476
- */
477
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
478
- /**
479
- * The default value of the attribute in the user-defined component.
480
- * @example
481
- * `"/"`
482
- */
483
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
484
- }, undefined>, undefined>, never>;
485
- }, undefined>, valibot.ObjectSchema<{
309
+ readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
486
310
  /**
487
311
  * The name of the user-defined component.
488
312
  * @example
@@ -492,15 +316,15 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
492
316
  /**
493
317
  * The ESQuery selector to select the component precisely.
494
318
  * @example
495
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
319
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
496
320
  */
497
- readonly selector: valibot.StringSchema<undefined>;
321
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
498
322
  /**
499
323
  * The name of the built-in component that the user-defined component represents.
500
324
  * @example
501
325
  * "a"
502
326
  */
503
- readonly as: valibot.StringSchema<undefined>;
327
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
504
328
  /**
505
329
  * Pre-defined attributes that are used in the user-defined component.
506
330
  * @example
@@ -531,8 +355,8 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
531
355
  * `"/"`
532
356
  */
533
357
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
534
- }, undefined>, undefined>, never>;
535
- }, undefined>], undefined>, undefined>, never>;
358
+ }, undefined>, undefined>, readonly []>;
359
+ }, undefined>, undefined>, readonly []>;
536
360
  readonly additionalHooks: valibot.OptionalSchema<valibot.ObjectSchema<{
537
361
  readonly use: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
538
362
  readonly useActionState: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
@@ -561,8 +385,18 @@ type CustomComponent = InferOutput<typeof CustomComponentSchema>;
561
385
  type ESLintReactSettings = InferOutput<typeof ESLintReactSettingsSchema>;
562
386
  type ESLintSettings = InferOutput<typeof ESLintSettingsSchema>;
563
387
 
388
+ interface CustomComponentExpanded extends CustomComponent {
389
+ attributes: {
390
+ name: string;
391
+ as: string;
392
+ }[];
393
+ re: RegExp;
394
+ }
395
+ interface ESLintReactSettingsExpanded extends ESLintReactSettings {
396
+ additionalComponents: CustomComponentExpanded[];
397
+ }
564
398
  declare function decodeSettings(data: unknown): ESLintReactSettings;
565
- declare const expandSettings: micro_memoize.Memoized<(settings: ESLintReactSettings) => ESLintReactSettings>;
399
+ declare const expandSettings: micro_memoize.Memoized<(settings: ESLintReactSettings) => ESLintReactSettingsExpanded>;
566
400
  declare const DEFAULT_ESLINT_REACT_SETTINGS: ESLintReactSettings;
567
401
 
568
- export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, NPM_SCOPE, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, expandSettings };
402
+ export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentExpanded, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsExpanded, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, NPM_SCOPE, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, expandSettings };
package/dist/index.d.ts CHANGED
@@ -82,51 +82,7 @@ declare const CustomAttributeSchema: valibot.ObjectSchema<{
82
82
  * Which attribute is used as the `href` prop for the user-defined `Link` component that represents the built-in `a` element.
83
83
  * Which attributes are used as `children` props for a user-defined `Button` component to receive children of that component.
84
84
  */
85
- declare const CustomComponentSchema: valibot.UnionSchema<[valibot.ObjectSchema<{
86
- /**
87
- * The name of the user-defined component.
88
- * @example
89
- * "Link"
90
- */
91
- readonly name: valibot.StringSchema<undefined>;
92
- /**
93
- * The name of the built-in component that the user-defined component represents.
94
- * @example
95
- * "a"
96
- */
97
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
98
- /**
99
- * Pre-defined attributes that are used in the user-defined component.
100
- * @example
101
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
102
- */
103
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
104
- /**
105
- * The name of the attribute in the user-defined component.
106
- * @example
107
- * "to"
108
- */
109
- readonly name: valibot.StringSchema<undefined>;
110
- /**
111
- * The name of the attribute in the built-in component.
112
- * @example
113
- * "href"
114
- */
115
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
116
- /**
117
- * Whether the attribute is controlled or not in the user-defined component.
118
- * @example
119
- * `true`
120
- */
121
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
122
- /**
123
- * The default value of the attribute in the user-defined component.
124
- * @example
125
- * `"/"`
126
- */
127
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
128
- }, undefined>, undefined>, never>;
129
- }, undefined>, valibot.ObjectSchema<{
85
+ declare const CustomComponentSchema: valibot.ObjectSchema<{
130
86
  /**
131
87
  * The name of the user-defined component.
132
88
  * @example
@@ -136,15 +92,15 @@ declare const CustomComponentSchema: valibot.UnionSchema<[valibot.ObjectSchema<{
136
92
  /**
137
93
  * The ESQuery selector to select the component precisely.
138
94
  * @example
139
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
95
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
140
96
  */
141
- readonly selector: valibot.StringSchema<undefined>;
97
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
142
98
  /**
143
99
  * The name of the built-in component that the user-defined component represents.
144
100
  * @example
145
101
  * "a"
146
102
  */
147
- readonly as: valibot.StringSchema<undefined>;
103
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
148
104
  /**
149
105
  * Pre-defined attributes that are used in the user-defined component.
150
106
  * @example
@@ -175,8 +131,8 @@ declare const CustomComponentSchema: valibot.UnionSchema<[valibot.ObjectSchema<{
175
131
  * `"/"`
176
132
  */
177
133
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
178
- }, undefined>, undefined>, never>;
179
- }, undefined>], undefined>;
134
+ }, undefined>, undefined>, readonly []>;
135
+ }, undefined>;
180
136
  /**
181
137
  * @internal
182
138
  */
@@ -186,51 +142,7 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
186
142
  readonly jsxPragmaFrag: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
187
143
  readonly strict: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
188
144
  readonly version: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
189
- readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.UnionSchema<[valibot.ObjectSchema<{
190
- /**
191
- * The name of the user-defined component.
192
- * @example
193
- * "Link"
194
- */
195
- readonly name: valibot.StringSchema<undefined>;
196
- /**
197
- * The name of the built-in component that the user-defined component represents.
198
- * @example
199
- * "a"
200
- */
201
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
202
- /**
203
- * Pre-defined attributes that are used in the user-defined component.
204
- * @example
205
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
206
- */
207
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
208
- /**
209
- * The name of the attribute in the user-defined component.
210
- * @example
211
- * "to"
212
- */
213
- readonly name: valibot.StringSchema<undefined>;
214
- /**
215
- * The name of the attribute in the built-in component.
216
- * @example
217
- * "href"
218
- */
219
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
220
- /**
221
- * Whether the attribute is controlled or not in the user-defined component.
222
- * @example
223
- * `true`
224
- */
225
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
226
- /**
227
- * The default value of the attribute in the user-defined component.
228
- * @example
229
- * `"/"`
230
- */
231
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
232
- }, undefined>, undefined>, never>;
233
- }, undefined>, valibot.ObjectSchema<{
145
+ readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
234
146
  /**
235
147
  * The name of the user-defined component.
236
148
  * @example
@@ -240,15 +152,15 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
240
152
  /**
241
153
  * The ESQuery selector to select the component precisely.
242
154
  * @example
243
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
155
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
244
156
  */
245
- readonly selector: valibot.StringSchema<undefined>;
157
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
246
158
  /**
247
159
  * The name of the built-in component that the user-defined component represents.
248
160
  * @example
249
161
  * "a"
250
162
  */
251
- readonly as: valibot.StringSchema<undefined>;
163
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
252
164
  /**
253
165
  * Pre-defined attributes that are used in the user-defined component.
254
166
  * @example
@@ -279,8 +191,8 @@ declare const ESLintReactSettingsSchema: valibot.ObjectSchema<{
279
191
  * `"/"`
280
192
  */
281
193
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
282
- }, undefined>, undefined>, never>;
283
- }, undefined>], undefined>, undefined>, never>;
194
+ }, undefined>, undefined>, readonly []>;
195
+ }, undefined>, undefined>, readonly []>;
284
196
  readonly additionalHooks: valibot.OptionalSchema<valibot.ObjectSchema<{
285
197
  readonly use: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
286
198
  readonly useActionState: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
@@ -312,51 +224,7 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
312
224
  readonly jsxPragmaFrag: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
313
225
  readonly strict: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
314
226
  readonly version: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
315
- readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.UnionSchema<[valibot.ObjectSchema<{
316
- /**
317
- * The name of the user-defined component.
318
- * @example
319
- * "Link"
320
- */
321
- readonly name: valibot.StringSchema<undefined>;
322
- /**
323
- * The name of the built-in component that the user-defined component represents.
324
- * @example
325
- * "a"
326
- */
327
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
328
- /**
329
- * Pre-defined attributes that are used in the user-defined component.
330
- * @example
331
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
332
- */
333
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
334
- /**
335
- * The name of the attribute in the user-defined component.
336
- * @example
337
- * "to"
338
- */
339
- readonly name: valibot.StringSchema<undefined>;
340
- /**
341
- * The name of the attribute in the built-in component.
342
- * @example
343
- * "href"
344
- */
345
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
346
- /**
347
- * Whether the attribute is controlled or not in the user-defined component.
348
- * @example
349
- * `true`
350
- */
351
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
352
- /**
353
- * The default value of the attribute in the user-defined component.
354
- * @example
355
- * `"/"`
356
- */
357
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
358
- }, undefined>, undefined>, never>;
359
- }, undefined>, valibot.ObjectSchema<{
227
+ readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
360
228
  /**
361
229
  * The name of the user-defined component.
362
230
  * @example
@@ -366,15 +234,15 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
366
234
  /**
367
235
  * The ESQuery selector to select the component precisely.
368
236
  * @example
369
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
237
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
370
238
  */
371
- readonly selector: valibot.StringSchema<undefined>;
239
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
372
240
  /**
373
241
  * The name of the built-in component that the user-defined component represents.
374
242
  * @example
375
243
  * "a"
376
244
  */
377
- readonly as: valibot.StringSchema<undefined>;
245
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
378
246
  /**
379
247
  * Pre-defined attributes that are used in the user-defined component.
380
248
  * @example
@@ -405,8 +273,8 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
405
273
  * `"/"`
406
274
  */
407
275
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
408
- }, undefined>, undefined>, never>;
409
- }, undefined>], undefined>, undefined>, never>;
276
+ }, undefined>, undefined>, readonly []>;
277
+ }, undefined>, undefined>, readonly []>;
410
278
  readonly additionalHooks: valibot.OptionalSchema<valibot.ObjectSchema<{
411
279
  readonly use: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
412
280
  readonly useActionState: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
@@ -438,51 +306,7 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
438
306
  readonly jsxPragmaFrag: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
439
307
  readonly strict: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
440
308
  readonly version: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
441
- readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.UnionSchema<[valibot.ObjectSchema<{
442
- /**
443
- * The name of the user-defined component.
444
- * @example
445
- * "Link"
446
- */
447
- readonly name: valibot.StringSchema<undefined>;
448
- /**
449
- * The name of the built-in component that the user-defined component represents.
450
- * @example
451
- * "a"
452
- */
453
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
454
- /**
455
- * Pre-defined attributes that are used in the user-defined component.
456
- * @example
457
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
458
- */
459
- readonly attributes: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
460
- /**
461
- * The name of the attribute in the user-defined component.
462
- * @example
463
- * "to"
464
- */
465
- readonly name: valibot.StringSchema<undefined>;
466
- /**
467
- * The name of the attribute in the built-in component.
468
- * @example
469
- * "href"
470
- */
471
- readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
472
- /**
473
- * Whether the attribute is controlled or not in the user-defined component.
474
- * @example
475
- * `true`
476
- */
477
- readonly controlled: valibot.OptionalSchema<valibot.BooleanSchema<undefined>, never>;
478
- /**
479
- * The default value of the attribute in the user-defined component.
480
- * @example
481
- * `"/"`
482
- */
483
- readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
484
- }, undefined>, undefined>, never>;
485
- }, undefined>, valibot.ObjectSchema<{
309
+ readonly additionalComponents: valibot.OptionalSchema<valibot.ArraySchema<valibot.ObjectSchema<{
486
310
  /**
487
311
  * The name of the user-defined component.
488
312
  * @example
@@ -492,15 +316,15 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
492
316
  /**
493
317
  * The ESQuery selector to select the component precisely.
494
318
  * @example
495
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
319
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
496
320
  */
497
- readonly selector: valibot.StringSchema<undefined>;
321
+ readonly selector: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
498
322
  /**
499
323
  * The name of the built-in component that the user-defined component represents.
500
324
  * @example
501
325
  * "a"
502
326
  */
503
- readonly as: valibot.StringSchema<undefined>;
327
+ readonly as: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
504
328
  /**
505
329
  * Pre-defined attributes that are used in the user-defined component.
506
330
  * @example
@@ -531,8 +355,8 @@ declare const ESLintSettingsSchema: valibot.OptionalSchema<valibot.ObjectSchema<
531
355
  * `"/"`
532
356
  */
533
357
  readonly defaultValue: valibot.OptionalSchema<valibot.StringSchema<undefined>, never>;
534
- }, undefined>, undefined>, never>;
535
- }, undefined>], undefined>, undefined>, never>;
358
+ }, undefined>, undefined>, readonly []>;
359
+ }, undefined>, undefined>, readonly []>;
536
360
  readonly additionalHooks: valibot.OptionalSchema<valibot.ObjectSchema<{
537
361
  readonly use: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
538
362
  readonly useActionState: valibot.OptionalSchema<valibot.ArraySchema<valibot.StringSchema<undefined>, undefined>, never>;
@@ -561,8 +385,18 @@ type CustomComponent = InferOutput<typeof CustomComponentSchema>;
561
385
  type ESLintReactSettings = InferOutput<typeof ESLintReactSettingsSchema>;
562
386
  type ESLintSettings = InferOutput<typeof ESLintSettingsSchema>;
563
387
 
388
+ interface CustomComponentExpanded extends CustomComponent {
389
+ attributes: {
390
+ name: string;
391
+ as: string;
392
+ }[];
393
+ re: RegExp;
394
+ }
395
+ interface ESLintReactSettingsExpanded extends ESLintReactSettings {
396
+ additionalComponents: CustomComponentExpanded[];
397
+ }
564
398
  declare function decodeSettings(data: unknown): ESLintReactSettings;
565
- declare const expandSettings: micro_memoize.Memoized<(settings: ESLintReactSettings) => ESLintReactSettings>;
399
+ declare const expandSettings: micro_memoize.Memoized<(settings: ESLintReactSettings) => ESLintReactSettingsExpanded>;
566
400
  declare const DEFAULT_ESLINT_REACT_SETTINGS: ESLintReactSettings;
567
401
 
568
- export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, NPM_SCOPE, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, expandSettings };
402
+ export { type CustomAttribute, CustomAttributeSchema, type CustomComponent, type CustomComponentExpanded, CustomComponentSchema, type CustomHook, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, type ESLintReactSettings, type ESLintReactSettingsExpanded, ESLintReactSettingsSchema, type ESLintSettings, ESLintSettingsSchema, GITHUB_URL, HOST_HTML_COMPONENT_TYPES, HOST_SVG_COMPONENT_TYPES, NPM_SCOPE, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, expandSettings };
package/dist/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@typescript-eslint/utils');
4
+ var pm = require('picomatch');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var pm__default = /*#__PURE__*/_interopDefault(pm);
4
9
 
5
10
  // src/constants.ts
6
11
  var NPM_SCOPE = "@eslint-react";
@@ -225,9 +230,9 @@ function _stringify(input) {
225
230
  return type;
226
231
  }
227
232
  function _addIssue(context, label, dataset, config2, other) {
228
- const input = other && "input" in other ? other.input : dataset.value;
229
- const expected = other?.expected ?? context.expects ?? null;
230
- const received = other?.received ?? _stringify(input);
233
+ const input = dataset.value;
234
+ const expected = context.expects ?? null;
235
+ const received = _stringify(input);
231
236
  const issue = {
232
237
  kind: context.kind,
233
238
  type: context.type,
@@ -244,7 +249,7 @@ function _addIssue(context, label, dataset, config2, other) {
244
249
  abortPipeEarly: config2.abortPipeEarly
245
250
  };
246
251
  const isSchema = context.kind === "schema";
247
- const message = other?.message ?? // @ts-expect-error
252
+ const message = // @ts-expect-error
248
253
  context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
249
254
  if (message) {
250
255
  issue.message = typeof message === "function" ? message(issue) : message;
@@ -460,78 +465,6 @@ function string(message) {
460
465
  }
461
466
  };
462
467
  }
463
- function _subIssues(datasets) {
464
- let issues;
465
- if (datasets) {
466
- for (const dataset of datasets) {
467
- if (issues) {
468
- issues.push(...dataset.issues);
469
- } else {
470
- issues = dataset.issues;
471
- }
472
- }
473
- }
474
- return issues;
475
- }
476
- function union(options, message) {
477
- return {
478
- kind: "schema",
479
- type: "union",
480
- reference: union,
481
- expects: [...new Set(options.map((option) => option.expects))].join(" | ") || "never",
482
- async: false,
483
- options,
484
- message,
485
- _run(dataset, config2) {
486
- let validDataset;
487
- let typedDatasets;
488
- let untypedDatasets;
489
- for (const schema of this.options) {
490
- const optionDataset = schema._run(
491
- { typed: false, value: dataset.value },
492
- config2
493
- );
494
- if (optionDataset.typed) {
495
- if (optionDataset.issues) {
496
- if (typedDatasets) {
497
- typedDatasets.push(optionDataset);
498
- } else {
499
- typedDatasets = [optionDataset];
500
- }
501
- } else {
502
- validDataset = optionDataset;
503
- break;
504
- }
505
- } else {
506
- if (untypedDatasets) {
507
- untypedDatasets.push(optionDataset);
508
- } else {
509
- untypedDatasets = [optionDataset];
510
- }
511
- }
512
- }
513
- if (validDataset) {
514
- return validDataset;
515
- }
516
- if (typedDatasets) {
517
- if (typedDatasets.length === 1) {
518
- return typedDatasets[0];
519
- }
520
- _addIssue(this, "type", dataset, config2, {
521
- issues: _subIssues(typedDatasets)
522
- });
523
- dataset.typed = true;
524
- } else if (untypedDatasets?.length === 1) {
525
- return untypedDatasets[0];
526
- } else {
527
- _addIssue(this, "type", dataset, config2, {
528
- issues: _subIssues(untypedDatasets)
529
- });
530
- }
531
- return dataset;
532
- }
533
- };
534
- }
535
468
  function parse(schema, input, config2) {
536
469
  const dataset = schema._run(
537
470
  { typed: false, value: input },
@@ -573,61 +506,39 @@ var CustomAttributeSchema = object({
573
506
  */
574
507
  defaultValue: optional(string())
575
508
  });
576
- var CustomComponentSchema = union([
577
- object({
578
- /**
579
- * The name of the user-defined component.
580
- * @example
581
- * "Link"
582
- */
583
- name: string(),
584
- /**
585
- * The name of the built-in component that the user-defined component represents.
586
- * @example
587
- * "a"
588
- */
589
- as: optional(string()),
590
- /**
591
- * Pre-defined attributes that are used in the user-defined component.
592
- * @example
593
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
594
- */
595
- attributes: optional(array(CustomAttributeSchema))
596
- }),
597
- object({
598
- /**
599
- * The name of the user-defined component.
600
- * @example
601
- * "Link"
602
- */
603
- name: string(),
604
- /**
605
- * The ESQuery selector to select the component precisely.
606
- * @example
607
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
608
- */
609
- selector: string(),
610
- /**
611
- * The name of the built-in component that the user-defined component represents.
612
- * @example
613
- * "a"
614
- */
615
- as: string(),
616
- /**
617
- * Pre-defined attributes that are used in the user-defined component.
618
- * @example
619
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
620
- */
621
- attributes: optional(array(CustomAttributeSchema))
622
- })
623
- ]);
509
+ var CustomComponentSchema = object({
510
+ /**
511
+ * The name of the user-defined component.
512
+ * @example
513
+ * "Link"
514
+ */
515
+ name: string(),
516
+ /**
517
+ * The ESQuery selector to select the component precisely.
518
+ * @example
519
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
520
+ */
521
+ selector: optional(string()),
522
+ /**
523
+ * The name of the built-in component that the user-defined component represents.
524
+ * @example
525
+ * "a"
526
+ */
527
+ as: optional(string()),
528
+ /**
529
+ * Pre-defined attributes that are used in the user-defined component.
530
+ * @example
531
+ * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
532
+ */
533
+ attributes: optional(array(CustomAttributeSchema), [])
534
+ });
624
535
  var ESLintReactSettingsSchema = object({
625
536
  importSource: optional(string()),
626
537
  jsxPragma: optional(string()),
627
538
  jsxPragmaFrag: optional(string()),
628
539
  strict: optional(boolean()),
629
540
  version: optional(string()),
630
- additionalComponents: optional(array(CustomComponentSchema)),
541
+ additionalComponents: optional(array(CustomComponentSchema), []),
631
542
  additionalHooks: optional(object({
632
543
  use: optional(array(string())),
633
544
  useActionState: optional(array(string())),
@@ -944,13 +855,10 @@ function createMemoizedFunction(fn, options) {
944
855
  memoized.options = normalizedOptions;
945
856
  return memoized;
946
857
  }
947
-
948
- // src/settings.ts
949
858
  function decodeSettings(data) {
950
859
  return parse(ESLintSettingsSchema, data)["react-x"] ?? {};
951
860
  }
952
861
  var expandSettings = createMemoizedFunction((settings) => {
953
- if (Object.keys(settings).length === 0) return {};
954
862
  return {
955
863
  ...settings,
956
864
  additionalComponents: settings.additionalComponents?.map((component) => ({
@@ -958,7 +866,8 @@ var expandSettings = createMemoizedFunction((settings) => {
958
866
  attributes: component.attributes?.map((attr) => ({
959
867
  ...attr,
960
868
  as: attr.as ?? attr.name
961
- })) ?? []
869
+ })) ?? [],
870
+ re: pm__default.default.toRegex(pm__default.default.parse(component.name).output)
962
871
  })) ?? []
963
872
  };
964
873
  }, { isDeepEqual: false });
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import pm from 'picomatch';
2
3
 
3
4
  // src/constants.ts
4
5
  var NPM_SCOPE = "@eslint-react";
@@ -223,9 +224,9 @@ function _stringify(input) {
223
224
  return type;
224
225
  }
225
226
  function _addIssue(context, label, dataset, config2, other) {
226
- const input = other && "input" in other ? other.input : dataset.value;
227
- const expected = other?.expected ?? context.expects ?? null;
228
- const received = other?.received ?? _stringify(input);
227
+ const input = dataset.value;
228
+ const expected = context.expects ?? null;
229
+ const received = _stringify(input);
229
230
  const issue = {
230
231
  kind: context.kind,
231
232
  type: context.type,
@@ -242,7 +243,7 @@ function _addIssue(context, label, dataset, config2, other) {
242
243
  abortPipeEarly: config2.abortPipeEarly
243
244
  };
244
245
  const isSchema = context.kind === "schema";
245
- const message = other?.message ?? // @ts-expect-error
246
+ const message = // @ts-expect-error
246
247
  context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
247
248
  if (message) {
248
249
  issue.message = typeof message === "function" ? message(issue) : message;
@@ -458,78 +459,6 @@ function string(message) {
458
459
  }
459
460
  };
460
461
  }
461
- function _subIssues(datasets) {
462
- let issues;
463
- if (datasets) {
464
- for (const dataset of datasets) {
465
- if (issues) {
466
- issues.push(...dataset.issues);
467
- } else {
468
- issues = dataset.issues;
469
- }
470
- }
471
- }
472
- return issues;
473
- }
474
- function union(options, message) {
475
- return {
476
- kind: "schema",
477
- type: "union",
478
- reference: union,
479
- expects: [...new Set(options.map((option) => option.expects))].join(" | ") || "never",
480
- async: false,
481
- options,
482
- message,
483
- _run(dataset, config2) {
484
- let validDataset;
485
- let typedDatasets;
486
- let untypedDatasets;
487
- for (const schema of this.options) {
488
- const optionDataset = schema._run(
489
- { typed: false, value: dataset.value },
490
- config2
491
- );
492
- if (optionDataset.typed) {
493
- if (optionDataset.issues) {
494
- if (typedDatasets) {
495
- typedDatasets.push(optionDataset);
496
- } else {
497
- typedDatasets = [optionDataset];
498
- }
499
- } else {
500
- validDataset = optionDataset;
501
- break;
502
- }
503
- } else {
504
- if (untypedDatasets) {
505
- untypedDatasets.push(optionDataset);
506
- } else {
507
- untypedDatasets = [optionDataset];
508
- }
509
- }
510
- }
511
- if (validDataset) {
512
- return validDataset;
513
- }
514
- if (typedDatasets) {
515
- if (typedDatasets.length === 1) {
516
- return typedDatasets[0];
517
- }
518
- _addIssue(this, "type", dataset, config2, {
519
- issues: _subIssues(typedDatasets)
520
- });
521
- dataset.typed = true;
522
- } else if (untypedDatasets?.length === 1) {
523
- return untypedDatasets[0];
524
- } else {
525
- _addIssue(this, "type", dataset, config2, {
526
- issues: _subIssues(untypedDatasets)
527
- });
528
- }
529
- return dataset;
530
- }
531
- };
532
- }
533
462
  function parse(schema, input, config2) {
534
463
  const dataset = schema._run(
535
464
  { typed: false, value: input },
@@ -571,61 +500,39 @@ var CustomAttributeSchema = object({
571
500
  */
572
501
  defaultValue: optional(string())
573
502
  });
574
- var CustomComponentSchema = union([
575
- object({
576
- /**
577
- * The name of the user-defined component.
578
- * @example
579
- * "Link"
580
- */
581
- name: string(),
582
- /**
583
- * The name of the built-in component that the user-defined component represents.
584
- * @example
585
- * "a"
586
- */
587
- as: optional(string()),
588
- /**
589
- * Pre-defined attributes that are used in the user-defined component.
590
- * @example
591
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
592
- */
593
- attributes: optional(array(CustomAttributeSchema))
594
- }),
595
- object({
596
- /**
597
- * The name of the user-defined component.
598
- * @example
599
- * "Link"
600
- */
601
- name: string(),
602
- /**
603
- * The ESQuery selector to select the component precisely.
604
- * @example
605
- * `:has(JSXAttribute[name.name='component'][value.value='a'])`
606
- */
607
- selector: string(),
608
- /**
609
- * The name of the built-in component that the user-defined component represents.
610
- * @example
611
- * "a"
612
- */
613
- as: string(),
614
- /**
615
- * Pre-defined attributes that are used in the user-defined component.
616
- * @example
617
- * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
618
- */
619
- attributes: optional(array(CustomAttributeSchema))
620
- })
621
- ]);
503
+ var CustomComponentSchema = object({
504
+ /**
505
+ * The name of the user-defined component.
506
+ * @example
507
+ * "Link"
508
+ */
509
+ name: string(),
510
+ /**
511
+ * The ESQuery selector to select the component precisely.
512
+ * @example
513
+ * `JSXElement:has(JSXAttribute[name.name='component'][value.value='a'])`
514
+ */
515
+ selector: optional(string()),
516
+ /**
517
+ * The name of the built-in component that the user-defined component represents.
518
+ * @example
519
+ * "a"
520
+ */
521
+ as: optional(string()),
522
+ /**
523
+ * Pre-defined attributes that are used in the user-defined component.
524
+ * @example
525
+ * `Link` component has a `to` attribute that represents the `href` attribute in the built-in `a` element with a default value of `"/"`.
526
+ */
527
+ attributes: optional(array(CustomAttributeSchema), [])
528
+ });
622
529
  var ESLintReactSettingsSchema = object({
623
530
  importSource: optional(string()),
624
531
  jsxPragma: optional(string()),
625
532
  jsxPragmaFrag: optional(string()),
626
533
  strict: optional(boolean()),
627
534
  version: optional(string()),
628
- additionalComponents: optional(array(CustomComponentSchema)),
535
+ additionalComponents: optional(array(CustomComponentSchema), []),
629
536
  additionalHooks: optional(object({
630
537
  use: optional(array(string())),
631
538
  useActionState: optional(array(string())),
@@ -942,13 +849,10 @@ function createMemoizedFunction(fn, options) {
942
849
  memoized.options = normalizedOptions;
943
850
  return memoized;
944
851
  }
945
-
946
- // src/settings.ts
947
852
  function decodeSettings(data) {
948
853
  return parse(ESLintSettingsSchema, data)["react-x"] ?? {};
949
854
  }
950
855
  var expandSettings = createMemoizedFunction((settings) => {
951
- if (Object.keys(settings).length === 0) return {};
952
856
  return {
953
857
  ...settings,
954
858
  additionalComponents: settings.additionalComponents?.map((component) => ({
@@ -956,7 +860,8 @@ var expandSettings = createMemoizedFunction((settings) => {
956
860
  attributes: component.attributes?.map((attr) => ({
957
861
  ...attr,
958
862
  as: attr.as ?? attr.name
959
- })) ?? []
863
+ })) ?? [],
864
+ re: pm.toRegex(pm.parse(component.name).output)
960
865
  })) ?? []
961
866
  };
962
867
  }, { isDeepEqual: false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.6.0-next.1",
3
+ "version": "1.6.0-next.3",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/rel1cx/eslint-react",
6
6
  "bugs": {
@@ -35,9 +35,11 @@
35
35
  "./package.json"
36
36
  ],
37
37
  "dependencies": {
38
- "@typescript-eslint/utils": "^7.17.0"
38
+ "@typescript-eslint/utils": "^7.17.0",
39
+ "picomatch": "^4.0.2"
39
40
  },
40
41
  "devDependencies": {
42
+ "@types/picomatch": "^3.0.0",
41
43
  "micro-memoize": "4.1.2",
42
44
  "tsup": "8.2.3",
43
45
  "type-fest": "4.23.0",