fix: ajv related tranistive build errors

This commit is contained in:
Rainer Killinger
2021-12-17 10:17:53 +01:00
parent f602d6fe41
commit e82f4e9209
3 changed files with 25 additions and 28 deletions

42
package-lock.json generated
View File

@@ -584,9 +584,9 @@
},
"dependencies": {
"@types/node": {
"version": "16.11.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.13.tgz",
"integrity": "sha512-eUXZzHLHoZqj1frtUetNkUetYoJ6X55UmrVnFD4DMhVeAmwLjniZhtBmsRiemQh4uq4G3vUra/Ws/hs9vEvL3Q=="
"version": "17.0.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz",
"integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw=="
}
}
},
@@ -634,9 +634,9 @@
},
"dependencies": {
"@types/node": {
"version": "16.11.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.13.tgz",
"integrity": "sha512-eUXZzHLHoZqj1frtUetNkUetYoJ6X55UmrVnFD4DMhVeAmwLjniZhtBmsRiemQh4uq4G3vUra/Ws/hs9vEvL3Q=="
"version": "17.0.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz",
"integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw=="
}
}
},
@@ -685,9 +685,9 @@
},
"dependencies": {
"@types/node": {
"version": "16.11.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.13.tgz",
"integrity": "sha512-eUXZzHLHoZqj1frtUetNkUetYoJ6X55UmrVnFD4DMhVeAmwLjniZhtBmsRiemQh4uq4G3vUra/Ws/hs9vEvL3Q=="
"version": "17.0.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz",
"integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw=="
}
}
},
@@ -706,9 +706,9 @@
},
"dependencies": {
"@types/node": {
"version": "16.11.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.13.tgz",
"integrity": "sha512-eUXZzHLHoZqj1frtUetNkUetYoJ6X55UmrVnFD4DMhVeAmwLjniZhtBmsRiemQh4uq4G3vUra/Ws/hs9vEvL3Q=="
"version": "17.0.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz",
"integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw=="
}
}
},
@@ -1154,9 +1154,9 @@
}
},
"caniuse-lite": {
"version": "1.0.30001286",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001286.tgz",
"integrity": "sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==",
"version": "1.0.30001287",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001287.tgz",
"integrity": "sha512-4udbs9bc0hfNrcje++AxBuc6PfLNHwh3PO9kbwnfCQWyqtlzg3py0YgFu8jyRTTo85VAz4U+VLxSlID09vNtWA==",
"dev": true
},
"chai": {
@@ -1670,9 +1670,9 @@
}
},
"electron-to-chromium": {
"version": "1.4.18",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.18.tgz",
"integrity": "sha512-i7nKjGGBE1+YUIbfLObA1EZPmN7J1ITEllbhusDk+KIk6V6gUxN9PFe36v+Sd+8Cg0k3cgUv9lQhQZalr8rggw==",
"version": "1.4.23",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.23.tgz",
"integrity": "sha512-q3tB59Api3+DMbLnDPkW/UBHBO7KTGcF+rDCeb0GAGyqFj562s6y+c/2tDKTS/y5lbC+JOvT4MSUALJLPqlcSA==",
"dev": true
},
"emoji-regex": {
@@ -1823,9 +1823,9 @@
"dev": true
},
"eslint-plugin-jsdoc": {
"version": "37.2.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.2.0.tgz",
"integrity": "sha512-ca7s/DD1mMObZQ2Y0n0DO/KnFV+FqCX6ztir8pcSuylg3GGCREIisn36P/0cRySuWW/7Y7MNCuUDqtKdgLPU7Q==",
"version": "37.2.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.2.3.tgz",
"integrity": "sha512-YXBonC2F78wQuzKpq8J0kqT4xlxDPkqZS9zrcZwsKAsrz2g81dAsOq4WfmnKRsMVh9TjKFXJANqswyQMMq913g==",
"dev": true,
"requires": {
"@es-joy/jsdoccomment": "0.13.0",

View File

@@ -85,7 +85,7 @@
"@typescript-eslint/parser": "5.7.0",
"conventional-changelog-cli": "2.1.1",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jsdoc": "37.2.0",
"eslint-plugin-jsdoc": "37.2.3",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-unicorn": "39.0.0",
"mocha": "9.1.3",

View File

@@ -14,7 +14,7 @@
*/
import {Logger} from '@openstapps/logger';
import Ajv from 'ajv';
import betterAjvErrors from 'better-ajv-errors';
import betterAjvErrors, {IOutputError} from 'better-ajv-errors';
import {PathLike} from 'fs';
import {JSONSchema7} from 'json-schema';
import * as mustache from 'mustache';
@@ -34,7 +34,6 @@ export class Validator {
*/
private readonly ajv = new Ajv({
verbose: true,
ignoreKeywordsWithRef: true,
code: {regExp: re2},
});
@@ -134,8 +133,7 @@ function fromAjvResult(
instance: unknown,
ajvInstance: Ajv,
): ValidationResult {
// @ts-expect-error function can return void, which at runtime will be undefined. TS doesn't allow to assign void to undefined
const betterErrorObject: betterAjvErrors.IOutputError[] | undefined = betterAjvErrors(
const betterErrorObject: IOutputError[] | undefined = betterAjvErrors(
schema,
instance,
ajvInstance.errors ?? [],
@@ -149,8 +147,7 @@ function fromAjvResult(
const error: ValidationError = {
dataPath: ajvError.instancePath,
instance: instance,
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
message: betterErrorObject?.[index]?.error! ?? ajvError.message,
message: betterErrorObject?.[index]?.error ?? ajvError.message,
name: ajvError.keyword,
schemaPath: ajvError.schemaPath,
suggestion: betterErrorObject?.[index]?.suggestion,