@eslint-react/shared
Advanced tools
Comparing version 1.5.16 to 1.5.17-beta.2
'use strict'; | ||
var utils = require('@typescript-eslint/utils'); | ||
var valibot = require('valibot'); | ||
@@ -191,254 +192,29 @@ // src/constants.ts | ||
var createRuleForPlugin = (pluginName) => utils.ESLintUtils.RuleCreator(getDocsUrl(pluginName)); | ||
// ../../node_modules/.pnpm/valibot@0.32.0/node_modules/valibot/dist/index.js | ||
var store2; | ||
function getGlobalMessage(lang) { | ||
return store2?.get(lang); | ||
} | ||
var store3; | ||
function getSchemaMessage(lang) { | ||
return store3?.get(lang); | ||
} | ||
var store4; | ||
function getSpecificMessage(reference, lang) { | ||
return store4?.get(reference)?.get(lang); | ||
} | ||
function _stringify(input) { | ||
let type = typeof input; | ||
if (type === "object") { | ||
type = (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null"; | ||
} | ||
return type === "string" ? `"${input}"` : type === "number" || type === "bigint" || type === "boolean" ? `${input}` : type; | ||
} | ||
function _addIssue(context, label, dataset, config2, other) { | ||
const input = dataset.value; | ||
const expected = context.expects ?? null; | ||
const received = _stringify(input); | ||
const issue = { | ||
kind: context.kind, | ||
type: context.type, | ||
input, | ||
expected, | ||
received, | ||
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`, | ||
// @ts-expect-error | ||
requirement: context.requirement, | ||
path: other?.path, | ||
issues: other?.issues, | ||
lang: config2.lang, | ||
abortEarly: config2.abortEarly, | ||
abortPipeEarly: config2.abortPipeEarly | ||
}; | ||
const isSchema = context.kind === "schema"; | ||
const message = // @ts-expect-error | ||
context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang); | ||
if (message) { | ||
issue.message = typeof message === "function" ? message(issue) : message; | ||
} | ||
if (isSchema) { | ||
dataset.typed = false; | ||
} | ||
if (dataset.issues) { | ||
dataset.issues.push(issue); | ||
} else { | ||
dataset.issues = [issue]; | ||
} | ||
} | ||
function getDefault(schema, dataset, config2) { | ||
return typeof schema.default === "function" ? ( | ||
// @ts-expect-error | ||
schema.default(dataset, config2) | ||
) : ( | ||
// @ts-expect-error | ||
schema.default | ||
); | ||
} | ||
function array(item, message) { | ||
return { | ||
kind: "schema", | ||
type: "array", | ||
reference: array, | ||
expects: "Array", | ||
async: false, | ||
item, | ||
message, | ||
_run(dataset, config2) { | ||
const input = dataset.value; | ||
if (Array.isArray(input)) { | ||
dataset.typed = true; | ||
dataset.value = []; | ||
for (let key = 0; key < input.length; key++) { | ||
const value2 = input[key]; | ||
const itemDataset = this.item._run({ typed: false, value: value2 }, config2); | ||
if (itemDataset.issues) { | ||
const pathItem = { | ||
type: "array", | ||
origin: "value", | ||
input, | ||
key, | ||
value: value2 | ||
}; | ||
for (const issue of itemDataset.issues) { | ||
if (issue.path) { | ||
issue.path.unshift(pathItem); | ||
} else { | ||
issue.path = [pathItem]; | ||
} | ||
dataset.issues?.push(issue); | ||
} | ||
if (!dataset.issues) { | ||
dataset.issues = itemDataset.issues; | ||
} | ||
if (config2.abortEarly) { | ||
dataset.typed = false; | ||
break; | ||
} | ||
} | ||
if (!itemDataset.typed) { | ||
dataset.typed = false; | ||
} | ||
dataset.value.push(itemDataset.value); | ||
} | ||
} else { | ||
_addIssue(this, "type", dataset, config2); | ||
} | ||
return dataset; | ||
} | ||
}; | ||
} | ||
function object(entries, message) { | ||
return { | ||
kind: "schema", | ||
type: "object", | ||
reference: object, | ||
expects: "Object", | ||
async: false, | ||
entries, | ||
message, | ||
_run(dataset, config2) { | ||
const input = dataset.value; | ||
if (input && typeof input === "object") { | ||
dataset.typed = true; | ||
dataset.value = {}; | ||
for (const key in this.entries) { | ||
const value2 = input[key]; | ||
const valueDataset = this.entries[key]._run( | ||
{ typed: false, value: value2 }, | ||
config2 | ||
); | ||
if (valueDataset.issues) { | ||
const pathItem = { | ||
type: "object", | ||
origin: "value", | ||
input, | ||
key, | ||
value: value2 | ||
}; | ||
for (const issue of valueDataset.issues) { | ||
if (issue.path) { | ||
issue.path.unshift(pathItem); | ||
} else { | ||
issue.path = [pathItem]; | ||
} | ||
dataset.issues?.push(issue); | ||
} | ||
if (!dataset.issues) { | ||
dataset.issues = valueDataset.issues; | ||
} | ||
if (config2.abortEarly) { | ||
dataset.typed = false; | ||
break; | ||
} | ||
} | ||
if (!valueDataset.typed) { | ||
dataset.typed = false; | ||
} | ||
if (valueDataset.value !== void 0 || key in input) { | ||
dataset.value[key] = valueDataset.value; | ||
} | ||
} | ||
} else { | ||
_addIssue(this, "type", dataset, config2); | ||
} | ||
return dataset; | ||
} | ||
}; | ||
} | ||
function optional(wrapped, ...args) { | ||
const schema = { | ||
kind: "schema", | ||
type: "optional", | ||
reference: optional, | ||
expects: `${wrapped.expects} | undefined`, | ||
async: false, | ||
wrapped, | ||
_run(dataset, config2) { | ||
if (dataset.value === void 0) { | ||
if ("default" in this) { | ||
dataset.value = getDefault( | ||
this, | ||
dataset, | ||
config2 | ||
); | ||
} | ||
if (dataset.value === void 0) { | ||
dataset.typed = true; | ||
return dataset; | ||
} | ||
} | ||
return this.wrapped._run(dataset, config2); | ||
} | ||
}; | ||
if (0 in args) { | ||
schema.default = args[0]; | ||
} | ||
return schema; | ||
} | ||
function string(message) { | ||
return { | ||
kind: "schema", | ||
type: "string", | ||
reference: string, | ||
expects: "string", | ||
async: false, | ||
message, | ||
_run(dataset, config2) { | ||
if (typeof dataset.value === "string") { | ||
dataset.typed = true; | ||
} else { | ||
_addIssue(this, "type", dataset, config2); | ||
} | ||
return dataset; | ||
} | ||
}; | ||
} | ||
// src/settings.ts | ||
var ESLintReactSettingsSchema = object({ | ||
additionalHooks: optional(object({ | ||
use: optional(string()), | ||
useCallback: optional(array(string())), | ||
useContext: optional(array(string())), | ||
useDebugValue: optional(array(string())), | ||
useDeferredValue: optional(array(string())), | ||
useEffect: optional(array(string())), | ||
useId: optional(array(string())), | ||
useImperativeHandle: optional(array(string())), | ||
useInsertionEffect: optional(array(string())), | ||
useLayoutEffect: optional(array(string())), | ||
useMemo: optional(array(string())), | ||
useOptimistic: optional(array(string())), | ||
useReducer: optional(array(string())), | ||
useRef: optional(array(string())), | ||
useState: optional(array(string())), | ||
useSyncExternalStore: optional(array(string())), | ||
useTransition: optional(array(string())) | ||
var ESLintReactSettingsSchema = valibot.object({ | ||
additionalHooks: valibot.optional(valibot.object({ | ||
use: valibot.optional(valibot.string()), | ||
useCallback: valibot.optional(valibot.array(valibot.string())), | ||
useContext: valibot.optional(valibot.array(valibot.string())), | ||
useDebugValue: valibot.optional(valibot.array(valibot.string())), | ||
useDeferredValue: valibot.optional(valibot.array(valibot.string())), | ||
useEffect: valibot.optional(valibot.array(valibot.string())), | ||
useId: valibot.optional(valibot.array(valibot.string())), | ||
useImperativeHandle: valibot.optional(valibot.array(valibot.string())), | ||
useInsertionEffect: valibot.optional(valibot.array(valibot.string())), | ||
useLayoutEffect: valibot.optional(valibot.array(valibot.string())), | ||
useMemo: valibot.optional(valibot.array(valibot.string())), | ||
useOptimistic: valibot.optional(valibot.array(valibot.string())), | ||
useReducer: valibot.optional(valibot.array(valibot.string())), | ||
useRef: valibot.optional(valibot.array(valibot.string())), | ||
useState: valibot.optional(valibot.array(valibot.string())), | ||
useSyncExternalStore: valibot.optional(valibot.array(valibot.string())), | ||
useTransition: valibot.optional(valibot.array(valibot.string())) | ||
})), | ||
importSource: optional(string()), | ||
jsxPragma: optional(string()), | ||
jsxPragmaFrag: optional(string()), | ||
version: optional(string()) | ||
importSource: valibot.optional(valibot.string()), | ||
jsxPragma: valibot.optional(valibot.string()), | ||
jsxPragmaFrag: valibot.optional(valibot.string()), | ||
version: valibot.optional(valibot.string()) | ||
}); | ||
var ESLintSettingsSchema = object({ | ||
reactOptions: optional(ESLintReactSettingsSchema) | ||
var ESLintSettingsSchema = valibot.object({ | ||
reactOptions: valibot.optional(ESLintReactSettingsSchema) | ||
}); | ||
@@ -445,0 +221,0 @@ |
{ | ||
"name": "@eslint-react/shared", | ||
"version": "1.5.16", | ||
"version": "1.5.17-beta.2", | ||
"description": "ESLint React's Shared constants and functions.", | ||
@@ -38,9 +38,9 @@ "homepage": "https://github.com/rel1cx/eslint-react", | ||
"dependencies": { | ||
"@typescript-eslint/utils": "^7.13.0", | ||
"deepmerge-ts": "7.0.3" | ||
"@typescript-eslint/utils": "^7.13.1", | ||
"deepmerge-ts": "^7.0.3", | ||
"valibot": "^0.32.0" | ||
}, | ||
"devDependencies": { | ||
"tsup": "8.1.0", | ||
"type-fest": "4.20.1", | ||
"valibot": "0.32.0" | ||
"type-fest": "4.20.1" | ||
}, | ||
@@ -47,0 +47,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
30411
3
557
1
+ Addedvalibot@^0.32.0
+ Addeddeepmerge-ts@7.1.4(transitive)
+ Addedvalibot@0.32.0(transitive)
- Removeddeepmerge-ts@7.0.3(transitive)
Updateddeepmerge-ts@^7.0.3