@eslint-react/shared 1.17.0 → 1.17.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  var utils = require('@typescript-eslint/utils');
4
4
  var tools = require('@eslint-react/tools');
5
+ var localPkg = require('local-pkg');
5
6
  var pm = require('picomatch');
7
+ var tsPattern = require('ts-pattern');
6
8
 
7
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
10
 
@@ -213,6 +215,8 @@ var getDocsUrl = (pluginName) => (ruleName) => {
213
215
  return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
214
216
  };
215
217
  var createRuleForPlugin = (pluginName) => utils.ESLintUtils.RuleCreator(getDocsUrl(pluginName));
218
+
219
+ // ../../node_modules/.pnpm/valibot@1.0.0-beta.8_typescript@5.6.3/node_modules/valibot/dist/index.js
216
220
  var store;
217
221
  function getGlobalConfig(config2) {
218
222
  return {
@@ -282,6 +286,15 @@ function _addIssue(context, label, dataset, config2, other) {
282
286
  dataset.issues = [issue];
283
287
  }
284
288
  }
289
+ function _getStandardProps(context) {
290
+ return {
291
+ version: 1,
292
+ vendor: "valibot",
293
+ validate(value2) {
294
+ return context["~run"]({ value: value2 }, getGlobalConfig());
295
+ }
296
+ };
297
+ }
285
298
  var ValiError = class extends Error {
286
299
  /**
287
300
  * The error issues.
@@ -316,14 +329,17 @@ function array(item, message) {
316
329
  async: false,
317
330
  item,
318
331
  message,
319
- _run(dataset, config2) {
332
+ get "~standard"() {
333
+ return _getStandardProps(this);
334
+ },
335
+ "~run"(dataset, config2) {
320
336
  const input = dataset.value;
321
337
  if (Array.isArray(input)) {
322
338
  dataset.typed = true;
323
339
  dataset.value = [];
324
340
  for (let key = 0; key < input.length; key++) {
325
341
  const value2 = input[key];
326
- const itemDataset = this.item._run({ typed: false, value: value2 }, config2);
342
+ const itemDataset = this.item["~run"]({ value: value2 }, config2);
327
343
  if (itemDataset.issues) {
328
344
  const pathItem = {
329
345
  type: "array",
@@ -368,7 +384,10 @@ function boolean(message) {
368
384
  expects: "boolean",
369
385
  async: false,
370
386
  message,
371
- _run(dataset, config2) {
387
+ get "~standard"() {
388
+ return _getStandardProps(this);
389
+ },
390
+ "~run"(dataset, config2) {
372
391
  if (typeof dataset.value === "boolean") {
373
392
  dataset.typed = true;
374
393
  } else {
@@ -387,7 +406,10 @@ function instance(class_, message) {
387
406
  async: false,
388
407
  class: class_,
389
408
  message,
390
- _run(dataset, config2) {
409
+ get "~standard"() {
410
+ return _getStandardProps(this);
411
+ },
412
+ "~run"(dataset, config2) {
391
413
  if (dataset.value instanceof this.class) {
392
414
  dataset.typed = true;
393
415
  } else {
@@ -406,17 +428,17 @@ function object(entries, message) {
406
428
  async: false,
407
429
  entries,
408
430
  message,
409
- _run(dataset, config2) {
431
+ get "~standard"() {
432
+ return _getStandardProps(this);
433
+ },
434
+ "~run"(dataset, config2) {
410
435
  const input = dataset.value;
411
436
  if (input && typeof input === "object") {
412
437
  dataset.typed = true;
413
438
  dataset.value = {};
414
439
  for (const key in this.entries) {
415
440
  const value2 = input[key];
416
- const valueDataset = this.entries[key]._run(
417
- { typed: false, value: value2 },
418
- config2
419
- );
441
+ const valueDataset = this.entries[key]["~run"]({ value: value2 }, config2);
420
442
  if (valueDataset.issues) {
421
443
  const pathItem = {
422
444
  type: "object",
@@ -455,35 +477,31 @@ function object(entries, message) {
455
477
  }
456
478
  };
457
479
  }
458
- function optional(wrapped, ...args) {
459
- const schema = {
480
+ function optional(wrapped, default_) {
481
+ return {
460
482
  kind: "schema",
461
483
  type: "optional",
462
484
  reference: optional,
463
485
  expects: `(${wrapped.expects} | undefined)`,
464
486
  async: false,
465
487
  wrapped,
466
- _run(dataset, config2) {
488
+ default: default_,
489
+ get "~standard"() {
490
+ return _getStandardProps(this);
491
+ },
492
+ "~run"(dataset, config2) {
467
493
  if (dataset.value === void 0) {
468
- if ("default" in this) {
469
- dataset.value = getDefault(
470
- this,
471
- dataset,
472
- config2
473
- );
494
+ if (this.default !== void 0) {
495
+ dataset.value = getDefault(this, dataset, config2);
474
496
  }
475
497
  if (dataset.value === void 0) {
476
498
  dataset.typed = true;
477
499
  return dataset;
478
500
  }
479
501
  }
480
- return this.wrapped._run(dataset, config2);
502
+ return this.wrapped["~run"](dataset, config2);
481
503
  }
482
504
  };
483
- if (0 in args) {
484
- schema.default = args[0];
485
- }
486
- return schema;
487
505
  }
488
506
  function string(message) {
489
507
  return {
@@ -493,7 +511,10 @@ function string(message) {
493
511
  expects: "string",
494
512
  async: false,
495
513
  message,
496
- _run(dataset, config2) {
514
+ get "~standard"() {
515
+ return _getStandardProps(this);
516
+ },
517
+ "~run"(dataset, config2) {
497
518
  if (typeof dataset.value === "string") {
498
519
  dataset.typed = true;
499
520
  } else {
@@ -504,10 +525,7 @@ function string(message) {
504
525
  };
505
526
  }
506
527
  function parse(schema, input, config2) {
507
- const dataset = schema._run(
508
- { typed: false, value: input },
509
- getGlobalConfig(config2)
510
- );
528
+ const dataset = schema["~run"]({ value: input }, getGlobalConfig(config2));
511
529
  if (dataset.issues) {
512
530
  throw new ValiError(dataset.issues);
513
531
  }
@@ -1332,7 +1350,8 @@ var normalizeSettings = createMemoizedFunction((settings) => {
1332
1350
  if (!name || !as || selector || attributes.length > 0) return acc;
1333
1351
  if (!/^[\w-]+$/u.test(name)) return acc;
1334
1352
  return acc.set(name, as);
1335
- }, /* @__PURE__ */ new Map())
1353
+ }, /* @__PURE__ */ new Map()),
1354
+ version: tsPattern.match(settings.version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => localPkg.getPackageInfoSync("react")?.version).otherwise(tools.F.identity) ?? "18.3.1"
1336
1355
  });
1337
1356
  }, { isEqual: shallowEqual });
1338
1357
  var defineSettings = tools.F.identity;
package/dist/index.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
2
  import { F, Data } from '@eslint-react/tools';
3
+ import { getPackageInfoSync } from 'local-pkg';
3
4
  import pm from 'picomatch';
5
+ import { match, P } from 'ts-pattern';
4
6
 
5
7
  // src/constants.ts
6
8
  var NPM_SCOPE = "@eslint-react";
@@ -207,6 +209,8 @@ var getDocsUrl = (pluginName) => (ruleName) => {
207
209
  return `${WEBSITE_URL}/docs/rules/${pluginName}-${ruleName}`;
208
210
  };
209
211
  var createRuleForPlugin = (pluginName) => ESLintUtils.RuleCreator(getDocsUrl(pluginName));
212
+
213
+ // ../../node_modules/.pnpm/valibot@1.0.0-beta.8_typescript@5.6.3/node_modules/valibot/dist/index.js
210
214
  var store;
211
215
  function getGlobalConfig(config2) {
212
216
  return {
@@ -276,6 +280,15 @@ function _addIssue(context, label, dataset, config2, other) {
276
280
  dataset.issues = [issue];
277
281
  }
278
282
  }
283
+ function _getStandardProps(context) {
284
+ return {
285
+ version: 1,
286
+ vendor: "valibot",
287
+ validate(value2) {
288
+ return context["~run"]({ value: value2 }, getGlobalConfig());
289
+ }
290
+ };
291
+ }
279
292
  var ValiError = class extends Error {
280
293
  /**
281
294
  * The error issues.
@@ -310,14 +323,17 @@ function array(item, message) {
310
323
  async: false,
311
324
  item,
312
325
  message,
313
- _run(dataset, config2) {
326
+ get "~standard"() {
327
+ return _getStandardProps(this);
328
+ },
329
+ "~run"(dataset, config2) {
314
330
  const input = dataset.value;
315
331
  if (Array.isArray(input)) {
316
332
  dataset.typed = true;
317
333
  dataset.value = [];
318
334
  for (let key = 0; key < input.length; key++) {
319
335
  const value2 = input[key];
320
- const itemDataset = this.item._run({ typed: false, value: value2 }, config2);
336
+ const itemDataset = this.item["~run"]({ value: value2 }, config2);
321
337
  if (itemDataset.issues) {
322
338
  const pathItem = {
323
339
  type: "array",
@@ -362,7 +378,10 @@ function boolean(message) {
362
378
  expects: "boolean",
363
379
  async: false,
364
380
  message,
365
- _run(dataset, config2) {
381
+ get "~standard"() {
382
+ return _getStandardProps(this);
383
+ },
384
+ "~run"(dataset, config2) {
366
385
  if (typeof dataset.value === "boolean") {
367
386
  dataset.typed = true;
368
387
  } else {
@@ -381,7 +400,10 @@ function instance(class_, message) {
381
400
  async: false,
382
401
  class: class_,
383
402
  message,
384
- _run(dataset, config2) {
403
+ get "~standard"() {
404
+ return _getStandardProps(this);
405
+ },
406
+ "~run"(dataset, config2) {
385
407
  if (dataset.value instanceof this.class) {
386
408
  dataset.typed = true;
387
409
  } else {
@@ -400,17 +422,17 @@ function object(entries, message) {
400
422
  async: false,
401
423
  entries,
402
424
  message,
403
- _run(dataset, config2) {
425
+ get "~standard"() {
426
+ return _getStandardProps(this);
427
+ },
428
+ "~run"(dataset, config2) {
404
429
  const input = dataset.value;
405
430
  if (input && typeof input === "object") {
406
431
  dataset.typed = true;
407
432
  dataset.value = {};
408
433
  for (const key in this.entries) {
409
434
  const value2 = input[key];
410
- const valueDataset = this.entries[key]._run(
411
- { typed: false, value: value2 },
412
- config2
413
- );
435
+ const valueDataset = this.entries[key]["~run"]({ value: value2 }, config2);
414
436
  if (valueDataset.issues) {
415
437
  const pathItem = {
416
438
  type: "object",
@@ -449,35 +471,31 @@ function object(entries, message) {
449
471
  }
450
472
  };
451
473
  }
452
- function optional(wrapped, ...args) {
453
- const schema = {
474
+ function optional(wrapped, default_) {
475
+ return {
454
476
  kind: "schema",
455
477
  type: "optional",
456
478
  reference: optional,
457
479
  expects: `(${wrapped.expects} | undefined)`,
458
480
  async: false,
459
481
  wrapped,
460
- _run(dataset, config2) {
482
+ default: default_,
483
+ get "~standard"() {
484
+ return _getStandardProps(this);
485
+ },
486
+ "~run"(dataset, config2) {
461
487
  if (dataset.value === void 0) {
462
- if ("default" in this) {
463
- dataset.value = getDefault(
464
- this,
465
- dataset,
466
- config2
467
- );
488
+ if (this.default !== void 0) {
489
+ dataset.value = getDefault(this, dataset, config2);
468
490
  }
469
491
  if (dataset.value === void 0) {
470
492
  dataset.typed = true;
471
493
  return dataset;
472
494
  }
473
495
  }
474
- return this.wrapped._run(dataset, config2);
496
+ return this.wrapped["~run"](dataset, config2);
475
497
  }
476
498
  };
477
- if (0 in args) {
478
- schema.default = args[0];
479
- }
480
- return schema;
481
499
  }
482
500
  function string(message) {
483
501
  return {
@@ -487,7 +505,10 @@ function string(message) {
487
505
  expects: "string",
488
506
  async: false,
489
507
  message,
490
- _run(dataset, config2) {
508
+ get "~standard"() {
509
+ return _getStandardProps(this);
510
+ },
511
+ "~run"(dataset, config2) {
491
512
  if (typeof dataset.value === "string") {
492
513
  dataset.typed = true;
493
514
  } else {
@@ -498,10 +519,7 @@ function string(message) {
498
519
  };
499
520
  }
500
521
  function parse(schema, input, config2) {
501
- const dataset = schema._run(
502
- { typed: false, value: input },
503
- getGlobalConfig(config2)
504
- );
522
+ const dataset = schema["~run"]({ value: input }, getGlobalConfig(config2));
505
523
  if (dataset.issues) {
506
524
  throw new ValiError(dataset.issues);
507
525
  }
@@ -1326,7 +1344,8 @@ var normalizeSettings = createMemoizedFunction((settings) => {
1326
1344
  if (!name || !as || selector || attributes.length > 0) return acc;
1327
1345
  if (!/^[\w-]+$/u.test(name)) return acc;
1328
1346
  return acc.set(name, as);
1329
- }, /* @__PURE__ */ new Map())
1347
+ }, /* @__PURE__ */ new Map()),
1348
+ version: match(settings.version).with(P.union(P.nullish, "", "detect"), () => getPackageInfoSync("react")?.version).otherwise(F.identity) ?? "18.3.1"
1330
1349
  });
1331
1350
  }, { isEqual: shallowEqual });
1332
1351
  var defineSettings = F.identity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.17.0",
3
+ "version": "1.17.1-beta.2",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/rel1cx/eslint-react",
6
6
  "bugs": {
@@ -36,8 +36,10 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@typescript-eslint/utils": "^8.15.0",
39
+ "local-pkg": "^0.5.1",
39
40
  "picomatch": "^4.0.2",
40
- "@eslint-react/tools": "1.17.0"
41
+ "ts-pattern": "^5.5.0",
42
+ "@eslint-react/tools": "1.17.1-beta.2"
41
43
  },
42
44
  "devDependencies": {
43
45
  "@types/picomatch": "^3.0.1",
@@ -45,7 +47,7 @@
45
47
  "micro-memoize": "^4.1.2",
46
48
  "tsup": "^8.3.5",
47
49
  "type-fest": "^4.27.0",
48
- "valibot": "^1.0.0-beta.7"
50
+ "valibot": "^1.0.0-beta.8"
49
51
  },
50
52
  "scripts": {
51
53
  "build": "tsup --dts-resolve",