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