mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
refactor: reduce number of leaked anys (#7465)
This commit is contained in:
parent
6e62bba30f
commit
89b0fff128
39 changed files with 121 additions and 89 deletions
|
@ -11,7 +11,7 @@ const JoiFrontMatterString: Joi.Extension = {
|
|||
type: 'string',
|
||||
base: Joi.string(),
|
||||
// Fix Yaml that tries to auto-convert many things to string out of the box
|
||||
prepare: (value) => {
|
||||
prepare: (value: unknown) => {
|
||||
if (typeof value === 'number' || value instanceof Date) {
|
||||
return {value: value.toString()};
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ export const URISchema = Joi.alternatives(
|
|||
Joi.string().uri({allowRelative: true}),
|
||||
// This custom validation logic is required notably because Joi does not
|
||||
// accept paths like /a/b/c ...
|
||||
Joi.custom((val, helpers) => {
|
||||
Joi.custom((val: unknown, helpers) => {
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new URL(val);
|
||||
new URL(String(val));
|
||||
return val;
|
||||
} catch {
|
||||
return helpers.error('any.invalid');
|
||||
|
@ -55,7 +55,7 @@ export const URISchema = Joi.alternatives(
|
|||
});
|
||||
|
||||
export const PathnameSchema = Joi.string()
|
||||
.custom((val) => {
|
||||
.custom((val: string) => {
|
||||
if (!isValidPathname(val)) {
|
||||
throw new Error();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue