@eslint-react/shared 1.5.27-next.3 → 1.5.27
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 +314 -29
- package/dist/index.mjs +286 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@typescript-eslint/utils');
|
|
4
|
-
var valibot = require('valibot');
|
|
5
4
|
|
|
6
5
|
// src/constants.ts
|
|
7
6
|
var NPM_SCOPE = "@eslint-react";
|
|
@@ -189,41 +188,327 @@ var getDocsUrl = (pluginName) => (ruleName) => {
|
|
|
189
188
|
return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
|
|
190
189
|
};
|
|
191
190
|
var createRuleForPlugin = (pluginName) => utils.ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
191
|
+
|
|
192
|
+
// ../../node_modules/.pnpm/valibot@0.36.0/node_modules/valibot/dist/index.js
|
|
193
|
+
var store;
|
|
194
|
+
function getGlobalConfig(config2) {
|
|
195
|
+
return {
|
|
196
|
+
lang: config2?.lang ?? store?.lang,
|
|
197
|
+
message: config2?.message,
|
|
198
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
199
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
var store2;
|
|
203
|
+
function getGlobalMessage(lang) {
|
|
204
|
+
return store2?.get(lang);
|
|
205
|
+
}
|
|
206
|
+
var store3;
|
|
207
|
+
function getSchemaMessage(lang) {
|
|
208
|
+
return store3?.get(lang);
|
|
209
|
+
}
|
|
210
|
+
var store4;
|
|
211
|
+
function getSpecificMessage(reference, lang) {
|
|
212
|
+
return store4?.get(reference)?.get(lang);
|
|
213
|
+
}
|
|
214
|
+
function _stringify(input) {
|
|
215
|
+
const type = typeof input;
|
|
216
|
+
if (type === "string") {
|
|
217
|
+
return `"${input}"`;
|
|
218
|
+
}
|
|
219
|
+
if (type === "number" || type === "bigint" || type === "boolean") {
|
|
220
|
+
return `${input}`;
|
|
221
|
+
}
|
|
222
|
+
if (type === "object" || type === "function") {
|
|
223
|
+
return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
224
|
+
}
|
|
225
|
+
return type;
|
|
226
|
+
}
|
|
227
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
228
|
+
const input = dataset.value;
|
|
229
|
+
const expected = context.expects ?? null;
|
|
230
|
+
const received = _stringify(input);
|
|
231
|
+
const issue = {
|
|
232
|
+
kind: context.kind,
|
|
233
|
+
type: context.type,
|
|
234
|
+
input,
|
|
235
|
+
expected,
|
|
236
|
+
received,
|
|
237
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
238
|
+
// @ts-expect-error
|
|
239
|
+
requirement: context.requirement,
|
|
240
|
+
path: other?.path,
|
|
241
|
+
issues: other?.issues,
|
|
242
|
+
lang: config2.lang,
|
|
243
|
+
abortEarly: config2.abortEarly,
|
|
244
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
245
|
+
};
|
|
246
|
+
const isSchema = context.kind === "schema";
|
|
247
|
+
const message = // @ts-expect-error
|
|
248
|
+
context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
|
|
249
|
+
if (message) {
|
|
250
|
+
issue.message = typeof message === "function" ? message(issue) : message;
|
|
251
|
+
}
|
|
252
|
+
if (isSchema) {
|
|
253
|
+
dataset.typed = false;
|
|
254
|
+
}
|
|
255
|
+
if (dataset.issues) {
|
|
256
|
+
dataset.issues.push(issue);
|
|
257
|
+
} else {
|
|
258
|
+
dataset.issues = [issue];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
var ValiError = class extends Error {
|
|
262
|
+
/**
|
|
263
|
+
* The error issues.
|
|
264
|
+
*/
|
|
265
|
+
issues;
|
|
266
|
+
/**
|
|
267
|
+
* Creates a Valibot error with useful information.
|
|
268
|
+
*
|
|
269
|
+
* @param issues The error issues.
|
|
270
|
+
*/
|
|
271
|
+
constructor(issues) {
|
|
272
|
+
super(issues[0].message);
|
|
273
|
+
this.name = "ValiError";
|
|
274
|
+
this.issues = issues;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
function getDefault(schema, dataset, config2) {
|
|
278
|
+
return typeof schema.default === "function" ? (
|
|
279
|
+
// @ts-expect-error
|
|
280
|
+
schema.default(dataset, config2)
|
|
281
|
+
) : (
|
|
282
|
+
// @ts-expect-error
|
|
283
|
+
schema.default
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function array(item, message) {
|
|
287
|
+
return {
|
|
288
|
+
kind: "schema",
|
|
289
|
+
type: "array",
|
|
290
|
+
reference: array,
|
|
291
|
+
expects: "Array",
|
|
292
|
+
async: false,
|
|
293
|
+
item,
|
|
294
|
+
message,
|
|
295
|
+
_run(dataset, config2) {
|
|
296
|
+
const input = dataset.value;
|
|
297
|
+
if (Array.isArray(input)) {
|
|
298
|
+
dataset.typed = true;
|
|
299
|
+
dataset.value = [];
|
|
300
|
+
for (let key = 0; key < input.length; key++) {
|
|
301
|
+
const value2 = input[key];
|
|
302
|
+
const itemDataset = this.item._run({ typed: false, value: value2 }, config2);
|
|
303
|
+
if (itemDataset.issues) {
|
|
304
|
+
const pathItem = {
|
|
305
|
+
type: "array",
|
|
306
|
+
origin: "value",
|
|
307
|
+
input,
|
|
308
|
+
key,
|
|
309
|
+
value: value2
|
|
310
|
+
};
|
|
311
|
+
for (const issue of itemDataset.issues) {
|
|
312
|
+
if (issue.path) {
|
|
313
|
+
issue.path.unshift(pathItem);
|
|
314
|
+
} else {
|
|
315
|
+
issue.path = [pathItem];
|
|
316
|
+
}
|
|
317
|
+
dataset.issues?.push(issue);
|
|
318
|
+
}
|
|
319
|
+
if (!dataset.issues) {
|
|
320
|
+
dataset.issues = itemDataset.issues;
|
|
321
|
+
}
|
|
322
|
+
if (config2.abortEarly) {
|
|
323
|
+
dataset.typed = false;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (!itemDataset.typed) {
|
|
328
|
+
dataset.typed = false;
|
|
329
|
+
}
|
|
330
|
+
dataset.value.push(itemDataset.value);
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
_addIssue(this, "type", dataset, config2);
|
|
334
|
+
}
|
|
335
|
+
return dataset;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function boolean(message) {
|
|
340
|
+
return {
|
|
341
|
+
kind: "schema",
|
|
342
|
+
type: "boolean",
|
|
343
|
+
reference: boolean,
|
|
344
|
+
expects: "boolean",
|
|
345
|
+
async: false,
|
|
346
|
+
message,
|
|
347
|
+
_run(dataset, config2) {
|
|
348
|
+
if (typeof dataset.value === "boolean") {
|
|
349
|
+
dataset.typed = true;
|
|
350
|
+
} else {
|
|
351
|
+
_addIssue(this, "type", dataset, config2);
|
|
352
|
+
}
|
|
353
|
+
return dataset;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function object(entries, message) {
|
|
358
|
+
return {
|
|
359
|
+
kind: "schema",
|
|
360
|
+
type: "object",
|
|
361
|
+
reference: object,
|
|
362
|
+
expects: "Object",
|
|
363
|
+
async: false,
|
|
364
|
+
entries,
|
|
365
|
+
message,
|
|
366
|
+
_run(dataset, config2) {
|
|
367
|
+
const input = dataset.value;
|
|
368
|
+
if (input && typeof input === "object") {
|
|
369
|
+
dataset.typed = true;
|
|
370
|
+
dataset.value = {};
|
|
371
|
+
for (const key in this.entries) {
|
|
372
|
+
const value2 = input[key];
|
|
373
|
+
const valueDataset = this.entries[key]._run(
|
|
374
|
+
{ typed: false, value: value2 },
|
|
375
|
+
config2
|
|
376
|
+
);
|
|
377
|
+
if (valueDataset.issues) {
|
|
378
|
+
const pathItem = {
|
|
379
|
+
type: "object",
|
|
380
|
+
origin: "value",
|
|
381
|
+
input,
|
|
382
|
+
key,
|
|
383
|
+
value: value2
|
|
384
|
+
};
|
|
385
|
+
for (const issue of valueDataset.issues) {
|
|
386
|
+
if (issue.path) {
|
|
387
|
+
issue.path.unshift(pathItem);
|
|
388
|
+
} else {
|
|
389
|
+
issue.path = [pathItem];
|
|
390
|
+
}
|
|
391
|
+
dataset.issues?.push(issue);
|
|
392
|
+
}
|
|
393
|
+
if (!dataset.issues) {
|
|
394
|
+
dataset.issues = valueDataset.issues;
|
|
395
|
+
}
|
|
396
|
+
if (config2.abortEarly) {
|
|
397
|
+
dataset.typed = false;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (!valueDataset.typed) {
|
|
402
|
+
dataset.typed = false;
|
|
403
|
+
}
|
|
404
|
+
if (valueDataset.value !== void 0 || key in input) {
|
|
405
|
+
dataset.value[key] = valueDataset.value;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
_addIssue(this, "type", dataset, config2);
|
|
410
|
+
}
|
|
411
|
+
return dataset;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function optional(wrapped, ...args) {
|
|
416
|
+
const schema = {
|
|
417
|
+
kind: "schema",
|
|
418
|
+
type: "optional",
|
|
419
|
+
reference: optional,
|
|
420
|
+
expects: `${wrapped.expects} | undefined`,
|
|
421
|
+
async: false,
|
|
422
|
+
wrapped,
|
|
423
|
+
_run(dataset, config2) {
|
|
424
|
+
if (dataset.value === void 0) {
|
|
425
|
+
if ("default" in this) {
|
|
426
|
+
dataset.value = getDefault(
|
|
427
|
+
this,
|
|
428
|
+
dataset,
|
|
429
|
+
config2
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
if (dataset.value === void 0) {
|
|
433
|
+
dataset.typed = true;
|
|
434
|
+
return dataset;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return this.wrapped._run(dataset, config2);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
if (0 in args) {
|
|
441
|
+
schema.default = args[0];
|
|
442
|
+
}
|
|
443
|
+
return schema;
|
|
444
|
+
}
|
|
445
|
+
function string(message) {
|
|
446
|
+
return {
|
|
447
|
+
kind: "schema",
|
|
448
|
+
type: "string",
|
|
449
|
+
reference: string,
|
|
450
|
+
expects: "string",
|
|
451
|
+
async: false,
|
|
452
|
+
message,
|
|
453
|
+
_run(dataset, config2) {
|
|
454
|
+
if (typeof dataset.value === "string") {
|
|
455
|
+
dataset.typed = true;
|
|
456
|
+
} else {
|
|
457
|
+
_addIssue(this, "type", dataset, config2);
|
|
458
|
+
}
|
|
459
|
+
return dataset;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function parse(schema, input, config2) {
|
|
464
|
+
const dataset = schema._run(
|
|
465
|
+
{ typed: false, value: input },
|
|
466
|
+
getGlobalConfig(config2)
|
|
467
|
+
);
|
|
468
|
+
if (dataset.issues) {
|
|
469
|
+
throw new ValiError(dataset.issues);
|
|
470
|
+
}
|
|
471
|
+
return dataset.value;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// src/schemas.ts
|
|
475
|
+
var ESLintReactSettingsSchema = object({
|
|
476
|
+
additionalHooks: optional(object({
|
|
477
|
+
use: optional(string()),
|
|
478
|
+
useCallback: optional(array(string())),
|
|
479
|
+
useContext: optional(array(string())),
|
|
480
|
+
useDebugValue: optional(array(string())),
|
|
481
|
+
useDeferredValue: optional(array(string())),
|
|
482
|
+
useEffect: optional(array(string())),
|
|
483
|
+
useId: optional(array(string())),
|
|
484
|
+
useImperativeHandle: optional(array(string())),
|
|
485
|
+
useInsertionEffect: optional(array(string())),
|
|
486
|
+
useLayoutEffect: optional(array(string())),
|
|
487
|
+
useMemo: optional(array(string())),
|
|
488
|
+
useOptimistic: optional(array(string())),
|
|
489
|
+
useReducer: optional(array(string())),
|
|
490
|
+
useRef: optional(array(string())),
|
|
491
|
+
useState: optional(array(string())),
|
|
492
|
+
useSyncExternalStore: optional(array(string())),
|
|
493
|
+
useTransition: optional(array(string()))
|
|
211
494
|
})),
|
|
212
|
-
importSource:
|
|
213
|
-
jsxPragma:
|
|
214
|
-
jsxPragmaFrag:
|
|
215
|
-
strict:
|
|
216
|
-
version:
|
|
495
|
+
importSource: optional(string()),
|
|
496
|
+
jsxPragma: optional(string()),
|
|
497
|
+
jsxPragmaFrag: optional(string()),
|
|
498
|
+
strict: optional(boolean()),
|
|
499
|
+
version: optional(string())
|
|
217
500
|
});
|
|
218
|
-
var ESLintSettingsSchema =
|
|
219
|
-
"react-x":
|
|
501
|
+
var ESLintSettingsSchema = object({
|
|
502
|
+
"react-x": optional(ESLintReactSettingsSchema),
|
|
220
503
|
/**
|
|
221
504
|
* @deprecated
|
|
222
505
|
*/
|
|
223
|
-
reactOptions:
|
|
506
|
+
reactOptions: optional(ESLintReactSettingsSchema)
|
|
224
507
|
});
|
|
508
|
+
|
|
509
|
+
// src/settings.ts
|
|
225
510
|
function getESLintReactSettings(data) {
|
|
226
|
-
const settings =
|
|
511
|
+
const settings = parse(ESLintSettingsSchema, data);
|
|
227
512
|
return settings["react-x"] ?? settings.reactOptions ?? {};
|
|
228
513
|
}
|
|
229
514
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
import { object, optional, string, array, boolean, parse } from 'valibot';
|
|
3
2
|
|
|
4
3
|
// src/constants.ts
|
|
5
4
|
var NPM_SCOPE = "@eslint-react";
|
|
@@ -187,6 +186,290 @@ var getDocsUrl = (pluginName) => (ruleName) => {
|
|
|
187
186
|
return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
|
|
188
187
|
};
|
|
189
188
|
var createRuleForPlugin = (pluginName) => ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
189
|
+
|
|
190
|
+
// ../../node_modules/.pnpm/valibot@0.36.0/node_modules/valibot/dist/index.js
|
|
191
|
+
var store;
|
|
192
|
+
function getGlobalConfig(config2) {
|
|
193
|
+
return {
|
|
194
|
+
lang: config2?.lang ?? store?.lang,
|
|
195
|
+
message: config2?.message,
|
|
196
|
+
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
197
|
+
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
var store2;
|
|
201
|
+
function getGlobalMessage(lang) {
|
|
202
|
+
return store2?.get(lang);
|
|
203
|
+
}
|
|
204
|
+
var store3;
|
|
205
|
+
function getSchemaMessage(lang) {
|
|
206
|
+
return store3?.get(lang);
|
|
207
|
+
}
|
|
208
|
+
var store4;
|
|
209
|
+
function getSpecificMessage(reference, lang) {
|
|
210
|
+
return store4?.get(reference)?.get(lang);
|
|
211
|
+
}
|
|
212
|
+
function _stringify(input) {
|
|
213
|
+
const type = typeof input;
|
|
214
|
+
if (type === "string") {
|
|
215
|
+
return `"${input}"`;
|
|
216
|
+
}
|
|
217
|
+
if (type === "number" || type === "bigint" || type === "boolean") {
|
|
218
|
+
return `${input}`;
|
|
219
|
+
}
|
|
220
|
+
if (type === "object" || type === "function") {
|
|
221
|
+
return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
222
|
+
}
|
|
223
|
+
return type;
|
|
224
|
+
}
|
|
225
|
+
function _addIssue(context, label, dataset, config2, other) {
|
|
226
|
+
const input = dataset.value;
|
|
227
|
+
const expected = context.expects ?? null;
|
|
228
|
+
const received = _stringify(input);
|
|
229
|
+
const issue = {
|
|
230
|
+
kind: context.kind,
|
|
231
|
+
type: context.type,
|
|
232
|
+
input,
|
|
233
|
+
expected,
|
|
234
|
+
received,
|
|
235
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
236
|
+
// @ts-expect-error
|
|
237
|
+
requirement: context.requirement,
|
|
238
|
+
path: other?.path,
|
|
239
|
+
issues: other?.issues,
|
|
240
|
+
lang: config2.lang,
|
|
241
|
+
abortEarly: config2.abortEarly,
|
|
242
|
+
abortPipeEarly: config2.abortPipeEarly
|
|
243
|
+
};
|
|
244
|
+
const isSchema = context.kind === "schema";
|
|
245
|
+
const message = // @ts-expect-error
|
|
246
|
+
context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
|
|
247
|
+
if (message) {
|
|
248
|
+
issue.message = typeof message === "function" ? message(issue) : message;
|
|
249
|
+
}
|
|
250
|
+
if (isSchema) {
|
|
251
|
+
dataset.typed = false;
|
|
252
|
+
}
|
|
253
|
+
if (dataset.issues) {
|
|
254
|
+
dataset.issues.push(issue);
|
|
255
|
+
} else {
|
|
256
|
+
dataset.issues = [issue];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
var ValiError = class extends Error {
|
|
260
|
+
/**
|
|
261
|
+
* The error issues.
|
|
262
|
+
*/
|
|
263
|
+
issues;
|
|
264
|
+
/**
|
|
265
|
+
* Creates a Valibot error with useful information.
|
|
266
|
+
*
|
|
267
|
+
* @param issues The error issues.
|
|
268
|
+
*/
|
|
269
|
+
constructor(issues) {
|
|
270
|
+
super(issues[0].message);
|
|
271
|
+
this.name = "ValiError";
|
|
272
|
+
this.issues = issues;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
function getDefault(schema, dataset, config2) {
|
|
276
|
+
return typeof schema.default === "function" ? (
|
|
277
|
+
// @ts-expect-error
|
|
278
|
+
schema.default(dataset, config2)
|
|
279
|
+
) : (
|
|
280
|
+
// @ts-expect-error
|
|
281
|
+
schema.default
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
function array(item, message) {
|
|
285
|
+
return {
|
|
286
|
+
kind: "schema",
|
|
287
|
+
type: "array",
|
|
288
|
+
reference: array,
|
|
289
|
+
expects: "Array",
|
|
290
|
+
async: false,
|
|
291
|
+
item,
|
|
292
|
+
message,
|
|
293
|
+
_run(dataset, config2) {
|
|
294
|
+
const input = dataset.value;
|
|
295
|
+
if (Array.isArray(input)) {
|
|
296
|
+
dataset.typed = true;
|
|
297
|
+
dataset.value = [];
|
|
298
|
+
for (let key = 0; key < input.length; key++) {
|
|
299
|
+
const value2 = input[key];
|
|
300
|
+
const itemDataset = this.item._run({ typed: false, value: value2 }, config2);
|
|
301
|
+
if (itemDataset.issues) {
|
|
302
|
+
const pathItem = {
|
|
303
|
+
type: "array",
|
|
304
|
+
origin: "value",
|
|
305
|
+
input,
|
|
306
|
+
key,
|
|
307
|
+
value: value2
|
|
308
|
+
};
|
|
309
|
+
for (const issue of itemDataset.issues) {
|
|
310
|
+
if (issue.path) {
|
|
311
|
+
issue.path.unshift(pathItem);
|
|
312
|
+
} else {
|
|
313
|
+
issue.path = [pathItem];
|
|
314
|
+
}
|
|
315
|
+
dataset.issues?.push(issue);
|
|
316
|
+
}
|
|
317
|
+
if (!dataset.issues) {
|
|
318
|
+
dataset.issues = itemDataset.issues;
|
|
319
|
+
}
|
|
320
|
+
if (config2.abortEarly) {
|
|
321
|
+
dataset.typed = false;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (!itemDataset.typed) {
|
|
326
|
+
dataset.typed = false;
|
|
327
|
+
}
|
|
328
|
+
dataset.value.push(itemDataset.value);
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
_addIssue(this, "type", dataset, config2);
|
|
332
|
+
}
|
|
333
|
+
return dataset;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function boolean(message) {
|
|
338
|
+
return {
|
|
339
|
+
kind: "schema",
|
|
340
|
+
type: "boolean",
|
|
341
|
+
reference: boolean,
|
|
342
|
+
expects: "boolean",
|
|
343
|
+
async: false,
|
|
344
|
+
message,
|
|
345
|
+
_run(dataset, config2) {
|
|
346
|
+
if (typeof dataset.value === "boolean") {
|
|
347
|
+
dataset.typed = true;
|
|
348
|
+
} else {
|
|
349
|
+
_addIssue(this, "type", dataset, config2);
|
|
350
|
+
}
|
|
351
|
+
return dataset;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function object(entries, message) {
|
|
356
|
+
return {
|
|
357
|
+
kind: "schema",
|
|
358
|
+
type: "object",
|
|
359
|
+
reference: object,
|
|
360
|
+
expects: "Object",
|
|
361
|
+
async: false,
|
|
362
|
+
entries,
|
|
363
|
+
message,
|
|
364
|
+
_run(dataset, config2) {
|
|
365
|
+
const input = dataset.value;
|
|
366
|
+
if (input && typeof input === "object") {
|
|
367
|
+
dataset.typed = true;
|
|
368
|
+
dataset.value = {};
|
|
369
|
+
for (const key in this.entries) {
|
|
370
|
+
const value2 = input[key];
|
|
371
|
+
const valueDataset = this.entries[key]._run(
|
|
372
|
+
{ typed: false, value: value2 },
|
|
373
|
+
config2
|
|
374
|
+
);
|
|
375
|
+
if (valueDataset.issues) {
|
|
376
|
+
const pathItem = {
|
|
377
|
+
type: "object",
|
|
378
|
+
origin: "value",
|
|
379
|
+
input,
|
|
380
|
+
key,
|
|
381
|
+
value: value2
|
|
382
|
+
};
|
|
383
|
+
for (const issue of valueDataset.issues) {
|
|
384
|
+
if (issue.path) {
|
|
385
|
+
issue.path.unshift(pathItem);
|
|
386
|
+
} else {
|
|
387
|
+
issue.path = [pathItem];
|
|
388
|
+
}
|
|
389
|
+
dataset.issues?.push(issue);
|
|
390
|
+
}
|
|
391
|
+
if (!dataset.issues) {
|
|
392
|
+
dataset.issues = valueDataset.issues;
|
|
393
|
+
}
|
|
394
|
+
if (config2.abortEarly) {
|
|
395
|
+
dataset.typed = false;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (!valueDataset.typed) {
|
|
400
|
+
dataset.typed = false;
|
|
401
|
+
}
|
|
402
|
+
if (valueDataset.value !== void 0 || key in input) {
|
|
403
|
+
dataset.value[key] = valueDataset.value;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
_addIssue(this, "type", dataset, config2);
|
|
408
|
+
}
|
|
409
|
+
return dataset;
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function optional(wrapped, ...args) {
|
|
414
|
+
const schema = {
|
|
415
|
+
kind: "schema",
|
|
416
|
+
type: "optional",
|
|
417
|
+
reference: optional,
|
|
418
|
+
expects: `${wrapped.expects} | undefined`,
|
|
419
|
+
async: false,
|
|
420
|
+
wrapped,
|
|
421
|
+
_run(dataset, config2) {
|
|
422
|
+
if (dataset.value === void 0) {
|
|
423
|
+
if ("default" in this) {
|
|
424
|
+
dataset.value = getDefault(
|
|
425
|
+
this,
|
|
426
|
+
dataset,
|
|
427
|
+
config2
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
if (dataset.value === void 0) {
|
|
431
|
+
dataset.typed = true;
|
|
432
|
+
return dataset;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return this.wrapped._run(dataset, config2);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
if (0 in args) {
|
|
439
|
+
schema.default = args[0];
|
|
440
|
+
}
|
|
441
|
+
return schema;
|
|
442
|
+
}
|
|
443
|
+
function string(message) {
|
|
444
|
+
return {
|
|
445
|
+
kind: "schema",
|
|
446
|
+
type: "string",
|
|
447
|
+
reference: string,
|
|
448
|
+
expects: "string",
|
|
449
|
+
async: false,
|
|
450
|
+
message,
|
|
451
|
+
_run(dataset, config2) {
|
|
452
|
+
if (typeof dataset.value === "string") {
|
|
453
|
+
dataset.typed = true;
|
|
454
|
+
} else {
|
|
455
|
+
_addIssue(this, "type", dataset, config2);
|
|
456
|
+
}
|
|
457
|
+
return dataset;
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function parse(schema, input, config2) {
|
|
462
|
+
const dataset = schema._run(
|
|
463
|
+
{ typed: false, value: input },
|
|
464
|
+
getGlobalConfig(config2)
|
|
465
|
+
);
|
|
466
|
+
if (dataset.issues) {
|
|
467
|
+
throw new ValiError(dataset.issues);
|
|
468
|
+
}
|
|
469
|
+
return dataset.value;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// src/schemas.ts
|
|
190
473
|
var ESLintReactSettingsSchema = object({
|
|
191
474
|
additionalHooks: optional(object({
|
|
192
475
|
use: optional(string()),
|
|
@@ -220,6 +503,8 @@ var ESLintSettingsSchema = object({
|
|
|
220
503
|
*/
|
|
221
504
|
reactOptions: optional(ESLintReactSettingsSchema)
|
|
222
505
|
});
|
|
506
|
+
|
|
507
|
+
// src/settings.ts
|
|
223
508
|
function getESLintReactSettings(data) {
|
|
224
509
|
const settings = parse(ESLintSettingsSchema, data);
|
|
225
510
|
return settings["react-x"] ?? settings.reactOptions ?? {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.5.27
|
|
3
|
+
"version": "1.5.27",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/utils": "^7.16.
|
|
39
|
-
"valibot": "^0.36.0"
|
|
38
|
+
"@typescript-eslint/utils": "^7.16.1"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"tsup": "8.1.0",
|
|
43
|
-
"type-fest": "4.21.0"
|
|
42
|
+
"type-fest": "4.21.0",
|
|
43
|
+
"valibot": "0.36.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsup",
|