@eslint-react/shared 1.40.0 → 1.40.1-beta.0
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 +149 -1555
- package/dist/index.d.ts +149 -1555
- package/dist/index.js +47 -385
- package/dist/index.mjs +1 -339
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import module from 'node:module';
|
|
2
2
|
import { identity } from '@eslint-react/eff';
|
|
3
3
|
import { match, P } from 'ts-pattern';
|
|
4
|
+
import { object, optional, string, boolean, array, parse } from 'valibot';
|
|
4
5
|
import pm from 'picomatch';
|
|
5
6
|
|
|
6
7
|
// src/constants.ts
|
|
@@ -27,345 +28,6 @@ function getReactVersion(fallback = "19.0.0") {
|
|
|
27
28
|
return fallback;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
// ../../node_modules/.pnpm/valibot@1.0.0_typescript@5.8.2/node_modules/valibot/dist/index.js
|
|
32
|
-
var store;
|
|
33
|
-
// @__NO_SIDE_EFFECTS__
|
|
34
|
-
function getGlobalConfig(config2) {
|
|
35
|
-
return {
|
|
36
|
-
lang: config2?.lang ?? store?.lang,
|
|
37
|
-
message: config2?.message,
|
|
38
|
-
abortEarly: config2?.abortEarly ?? store?.abortEarly,
|
|
39
|
-
abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
var store2;
|
|
43
|
-
// @__NO_SIDE_EFFECTS__
|
|
44
|
-
function getGlobalMessage(lang) {
|
|
45
|
-
return store2?.get(lang);
|
|
46
|
-
}
|
|
47
|
-
var store3;
|
|
48
|
-
// @__NO_SIDE_EFFECTS__
|
|
49
|
-
function getSchemaMessage(lang) {
|
|
50
|
-
return store3?.get(lang);
|
|
51
|
-
}
|
|
52
|
-
var store4;
|
|
53
|
-
// @__NO_SIDE_EFFECTS__
|
|
54
|
-
function getSpecificMessage(reference, lang) {
|
|
55
|
-
return store4?.get(reference)?.get(lang);
|
|
56
|
-
}
|
|
57
|
-
// @__NO_SIDE_EFFECTS__
|
|
58
|
-
function _stringify(input) {
|
|
59
|
-
const type = typeof input;
|
|
60
|
-
if (type === "string") {
|
|
61
|
-
return `"${input}"`;
|
|
62
|
-
}
|
|
63
|
-
if (type === "number" || type === "bigint" || type === "boolean") {
|
|
64
|
-
return `${input}`;
|
|
65
|
-
}
|
|
66
|
-
if (type === "object" || type === "function") {
|
|
67
|
-
return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
68
|
-
}
|
|
69
|
-
return type;
|
|
70
|
-
}
|
|
71
|
-
function _addIssue(context, label, dataset, config2, other) {
|
|
72
|
-
const input = other && "input" in other ? other.input : dataset.value;
|
|
73
|
-
const expected = other?.expected ?? context.expects ?? null;
|
|
74
|
-
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
75
|
-
const issue = {
|
|
76
|
-
kind: context.kind,
|
|
77
|
-
type: context.type,
|
|
78
|
-
input,
|
|
79
|
-
expected,
|
|
80
|
-
received,
|
|
81
|
-
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
82
|
-
requirement: context.requirement,
|
|
83
|
-
path: other?.path,
|
|
84
|
-
issues: other?.issues,
|
|
85
|
-
lang: config2.lang,
|
|
86
|
-
abortEarly: config2.abortEarly,
|
|
87
|
-
abortPipeEarly: config2.abortPipeEarly
|
|
88
|
-
};
|
|
89
|
-
const isSchema = context.kind === "schema";
|
|
90
|
-
const message = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
91
|
-
if (message !== void 0) {
|
|
92
|
-
issue.message = typeof message === "function" ? (
|
|
93
|
-
// @ts-expect-error
|
|
94
|
-
message(issue)
|
|
95
|
-
) : message;
|
|
96
|
-
}
|
|
97
|
-
if (isSchema) {
|
|
98
|
-
dataset.typed = false;
|
|
99
|
-
}
|
|
100
|
-
if (dataset.issues) {
|
|
101
|
-
dataset.issues.push(issue);
|
|
102
|
-
} else {
|
|
103
|
-
dataset.issues = [issue];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// @__NO_SIDE_EFFECTS__
|
|
107
|
-
function _getStandardProps(context) {
|
|
108
|
-
return {
|
|
109
|
-
version: 1,
|
|
110
|
-
vendor: "valibot",
|
|
111
|
-
validate(value2) {
|
|
112
|
-
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
var ValiError = class extends Error {
|
|
117
|
-
/**
|
|
118
|
-
* Creates a Valibot error with useful information.
|
|
119
|
-
*
|
|
120
|
-
* @param issues The error issues.
|
|
121
|
-
*/
|
|
122
|
-
constructor(issues) {
|
|
123
|
-
super(issues[0].message);
|
|
124
|
-
this.name = "ValiError";
|
|
125
|
-
this.issues = issues;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
// @__NO_SIDE_EFFECTS__
|
|
129
|
-
function getFallback(schema, dataset, config2) {
|
|
130
|
-
return typeof schema.fallback === "function" ? (
|
|
131
|
-
// @ts-expect-error
|
|
132
|
-
schema.fallback(dataset, config2)
|
|
133
|
-
) : (
|
|
134
|
-
// @ts-expect-error
|
|
135
|
-
schema.fallback
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
// @__NO_SIDE_EFFECTS__
|
|
139
|
-
function getDefault(schema, dataset, config2) {
|
|
140
|
-
return typeof schema.default === "function" ? (
|
|
141
|
-
// @ts-expect-error
|
|
142
|
-
schema.default(dataset, config2)
|
|
143
|
-
) : (
|
|
144
|
-
// @ts-expect-error
|
|
145
|
-
schema.default
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
// @__NO_SIDE_EFFECTS__
|
|
149
|
-
function array(item, message) {
|
|
150
|
-
return {
|
|
151
|
-
kind: "schema",
|
|
152
|
-
type: "array",
|
|
153
|
-
reference: array,
|
|
154
|
-
expects: "Array",
|
|
155
|
-
async: false,
|
|
156
|
-
item,
|
|
157
|
-
message,
|
|
158
|
-
get "~standard"() {
|
|
159
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
160
|
-
},
|
|
161
|
-
"~run"(dataset, config2) {
|
|
162
|
-
const input = dataset.value;
|
|
163
|
-
if (Array.isArray(input)) {
|
|
164
|
-
dataset.typed = true;
|
|
165
|
-
dataset.value = [];
|
|
166
|
-
for (let key = 0; key < input.length; key++) {
|
|
167
|
-
const value2 = input[key];
|
|
168
|
-
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
169
|
-
if (itemDataset.issues) {
|
|
170
|
-
const pathItem = {
|
|
171
|
-
type: "array",
|
|
172
|
-
origin: "value",
|
|
173
|
-
input,
|
|
174
|
-
key,
|
|
175
|
-
value: value2
|
|
176
|
-
};
|
|
177
|
-
for (const issue of itemDataset.issues) {
|
|
178
|
-
if (issue.path) {
|
|
179
|
-
issue.path.unshift(pathItem);
|
|
180
|
-
} else {
|
|
181
|
-
issue.path = [pathItem];
|
|
182
|
-
}
|
|
183
|
-
dataset.issues?.push(issue);
|
|
184
|
-
}
|
|
185
|
-
if (!dataset.issues) {
|
|
186
|
-
dataset.issues = itemDataset.issues;
|
|
187
|
-
}
|
|
188
|
-
if (config2.abortEarly) {
|
|
189
|
-
dataset.typed = false;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (!itemDataset.typed) {
|
|
194
|
-
dataset.typed = false;
|
|
195
|
-
}
|
|
196
|
-
dataset.value.push(itemDataset.value);
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
_addIssue(this, "type", dataset, config2);
|
|
200
|
-
}
|
|
201
|
-
return dataset;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
// @__NO_SIDE_EFFECTS__
|
|
206
|
-
function boolean(message) {
|
|
207
|
-
return {
|
|
208
|
-
kind: "schema",
|
|
209
|
-
type: "boolean",
|
|
210
|
-
reference: boolean,
|
|
211
|
-
expects: "boolean",
|
|
212
|
-
async: false,
|
|
213
|
-
message,
|
|
214
|
-
get "~standard"() {
|
|
215
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
216
|
-
},
|
|
217
|
-
"~run"(dataset, config2) {
|
|
218
|
-
if (typeof dataset.value === "boolean") {
|
|
219
|
-
dataset.typed = true;
|
|
220
|
-
} else {
|
|
221
|
-
_addIssue(this, "type", dataset, config2);
|
|
222
|
-
}
|
|
223
|
-
return dataset;
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
// @__NO_SIDE_EFFECTS__
|
|
228
|
-
function object(entries, message) {
|
|
229
|
-
return {
|
|
230
|
-
kind: "schema",
|
|
231
|
-
type: "object",
|
|
232
|
-
reference: object,
|
|
233
|
-
expects: "Object",
|
|
234
|
-
async: false,
|
|
235
|
-
entries,
|
|
236
|
-
message,
|
|
237
|
-
get "~standard"() {
|
|
238
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
239
|
-
},
|
|
240
|
-
"~run"(dataset, config2) {
|
|
241
|
-
const input = dataset.value;
|
|
242
|
-
if (input && typeof input === "object") {
|
|
243
|
-
dataset.typed = true;
|
|
244
|
-
dataset.value = {};
|
|
245
|
-
for (const key in this.entries) {
|
|
246
|
-
const valueSchema = this.entries[key];
|
|
247
|
-
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
|
|
248
|
-
valueSchema.default !== void 0) {
|
|
249
|
-
const value2 = key in input ? (
|
|
250
|
-
// @ts-expect-error
|
|
251
|
-
input[key]
|
|
252
|
-
) : /* @__PURE__ */ getDefault(valueSchema);
|
|
253
|
-
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
254
|
-
if (valueDataset.issues) {
|
|
255
|
-
const pathItem = {
|
|
256
|
-
type: "object",
|
|
257
|
-
origin: "value",
|
|
258
|
-
input,
|
|
259
|
-
key,
|
|
260
|
-
value: value2
|
|
261
|
-
};
|
|
262
|
-
for (const issue of valueDataset.issues) {
|
|
263
|
-
if (issue.path) {
|
|
264
|
-
issue.path.unshift(pathItem);
|
|
265
|
-
} else {
|
|
266
|
-
issue.path = [pathItem];
|
|
267
|
-
}
|
|
268
|
-
dataset.issues?.push(issue);
|
|
269
|
-
}
|
|
270
|
-
if (!dataset.issues) {
|
|
271
|
-
dataset.issues = valueDataset.issues;
|
|
272
|
-
}
|
|
273
|
-
if (config2.abortEarly) {
|
|
274
|
-
dataset.typed = false;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (!valueDataset.typed) {
|
|
279
|
-
dataset.typed = false;
|
|
280
|
-
}
|
|
281
|
-
dataset.value[key] = valueDataset.value;
|
|
282
|
-
} else if (valueSchema.fallback !== void 0) {
|
|
283
|
-
dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
284
|
-
} else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
285
|
-
_addIssue(this, "key", dataset, config2, {
|
|
286
|
-
input: void 0,
|
|
287
|
-
expected: `"${key}"`,
|
|
288
|
-
path: [
|
|
289
|
-
{
|
|
290
|
-
type: "object",
|
|
291
|
-
origin: "key",
|
|
292
|
-
input,
|
|
293
|
-
key,
|
|
294
|
-
// @ts-expect-error
|
|
295
|
-
value: input[key]
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
});
|
|
299
|
-
if (config2.abortEarly) {
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
_addIssue(this, "type", dataset, config2);
|
|
306
|
-
}
|
|
307
|
-
return dataset;
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
// @__NO_SIDE_EFFECTS__
|
|
312
|
-
function optional(wrapped, default_) {
|
|
313
|
-
return {
|
|
314
|
-
kind: "schema",
|
|
315
|
-
type: "optional",
|
|
316
|
-
reference: optional,
|
|
317
|
-
expects: `(${wrapped.expects} | undefined)`,
|
|
318
|
-
async: false,
|
|
319
|
-
wrapped,
|
|
320
|
-
default: default_,
|
|
321
|
-
get "~standard"() {
|
|
322
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
323
|
-
},
|
|
324
|
-
"~run"(dataset, config2) {
|
|
325
|
-
if (dataset.value === void 0) {
|
|
326
|
-
if (this.default !== void 0) {
|
|
327
|
-
dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
328
|
-
}
|
|
329
|
-
if (dataset.value === void 0) {
|
|
330
|
-
dataset.typed = true;
|
|
331
|
-
return dataset;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return this.wrapped["~run"](dataset, config2);
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
// @__NO_SIDE_EFFECTS__
|
|
339
|
-
function string(message) {
|
|
340
|
-
return {
|
|
341
|
-
kind: "schema",
|
|
342
|
-
type: "string",
|
|
343
|
-
reference: string,
|
|
344
|
-
expects: "string",
|
|
345
|
-
async: false,
|
|
346
|
-
message,
|
|
347
|
-
get "~standard"() {
|
|
348
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
349
|
-
},
|
|
350
|
-
"~run"(dataset, config2) {
|
|
351
|
-
if (typeof dataset.value === "string") {
|
|
352
|
-
dataset.typed = true;
|
|
353
|
-
} else {
|
|
354
|
-
_addIssue(this, "type", dataset, config2);
|
|
355
|
-
}
|
|
356
|
-
return dataset;
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
function parse(schema, input, config2) {
|
|
361
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
362
|
-
if (dataset.issues) {
|
|
363
|
-
throw new ValiError(dataset.issues);
|
|
364
|
-
}
|
|
365
|
-
return dataset.value;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// src/schemas.ts
|
|
369
31
|
var CustomComponentPropSchema = object({
|
|
370
32
|
/**
|
|
371
33
|
* The name of the prop in the user-defined component.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "1.40.0",
|
|
3
|
+
"version": "1.40.1-beta.0",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
"@typescript-eslint/utils": "^8.29.0",
|
|
39
39
|
"picomatch": "^4.0.2",
|
|
40
40
|
"ts-pattern": "^5.7.0",
|
|
41
|
-
"
|
|
42
|
-
"@eslint-react/
|
|
41
|
+
"valibot": "^1.0.0",
|
|
42
|
+
"@eslint-react/eff": "1.40.1-beta.0",
|
|
43
|
+
"@eslint-react/kit": "1.40.1-beta.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@tsconfig/node22": "^22.0.1",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
"micro-memoize": "^4.1.3",
|
|
49
50
|
"tsup": "^8.4.0",
|
|
50
51
|
"type-fest": "^4.38.0",
|
|
51
|
-
"valibot": "^1.0.0",
|
|
52
52
|
"@local/configs": "0.0.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|