refactor: reduce number of leaked anys (#7465)

This commit is contained in:
Joshua Chen 2022-05-23 00:30:32 +08:00 committed by GitHub
parent 6e62bba30f
commit 89b0fff128
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 121 additions and 89 deletions

View file

@ -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()};
}

View file

@ -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();
}