Skip to content

Commit

Permalink
fix more linting issues and some code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
catosaurusrex2003 committed Oct 9, 2024
1 parent 1821aff commit d50baab
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions library/src/helpers/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ asyncapiParser.registerSchemaParser(ProtoBuffSchemaParser());
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class Parser {
static async parse(
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
content: string | any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
parserOptions?: any,
): Promise<ParserReturn> {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const { document, diagnostics } = await asyncapiParser.parse(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
content,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
parserOptions,
);

if (document === undefined) {
const error = this.convertDiagnosticToErrorObject(diagnostics, [0]);
throw error;
throw this.convertDiagnosticToErrorObject(diagnostics, [0]);
}

return { asyncapi: document };
Expand Down Expand Up @@ -67,8 +67,7 @@ export class Parser {
if (document == undefined) {
// this means there are errors in the document.
// so we gather all the severity 0 diagnostics and throw them as errors
const error = this.convertDiagnosticToErrorObject(diagnostics, [0]);
throw error;
throw this.convertDiagnosticToErrorObject(diagnostics, [0]);
}

return { asyncapi: document, error: undefined };
Expand All @@ -77,7 +76,7 @@ export class Parser {
}
}

static convertDiagnosticToErrorObject = (
static readonly convertDiagnosticToErrorObject = (
diagnostics: Diagnostic[],
severities: DiagnosticSeverity[],
): ErrorObject => {
Expand All @@ -88,7 +87,7 @@ export class Parser {
};
diagnostics.forEach((diagnostic) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (diagnostic.severity in severities) {
if (severities.includes(diagnostic.severity)) {
const tempObj: ValidationError = {
title: diagnostic.message,
location: {
Expand Down

0 comments on commit d50baab

Please sign in to comment.