Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
itegulov committed Nov 22, 2022
1 parent b167ce5 commit 958270f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/cli/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export function runAbiCompilerPlugin(
if (diagnostics.length > 0) {
diagnostics.forEach((diagnostic) => {
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
if (diagnostic.file) {
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);
if (diagnostic.file && diagnostic.start) {
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
} else {
console.error(message);
Expand All @@ -81,7 +81,10 @@ export function runAbiCompilerPlugin(
throw Error("Failed to compile the contract");
}

const generator = TJS.buildGenerator(program)!;
const generator = TJS.buildGenerator(program);
if (!generator) {
throw Error("Failed to generate ABI due to an unexpected typescript-json-schema error. Please report this.");
}

const abiFunctions: abi.AbiFunction[] = [];

Expand All @@ -108,6 +111,7 @@ export function runAbiCompilerPlugin(
if (arg.kind !== ts.SyntaxKind.ObjectLiteralExpression) return;
const objLiteral = arg as ts.ObjectLiteralExpression;
objLiteral.properties.forEach((prop) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const propName = (prop.name as any).text;
if (propName === "privateFunction") {
if (prop.kind !== ts.SyntaxKind.PropertyAssignment) return;
Expand Down Expand Up @@ -166,6 +170,7 @@ export function runAbiCompilerPlugin(
const nodeType = tc.getTypeAtLocation(parameter);
const schema = generator.getTypeDefinition(nodeType, true);
const abiParameter: abi.AbiJsonParameter = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
name: (parameter.name as any).text,
type_schema: schema as JSONSchema7
};
Expand All @@ -184,6 +189,7 @@ export function runAbiCompilerPlugin(
};
}
const abiFunction: abi.AbiFunction = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
name: (methodDeclaration.name as any).text,
kind: isView ? abi.AbiFunctionKind.View : abi.AbiFunctionKind.Call,
modifiers: abiModifiers,
Expand Down

0 comments on commit 958270f

Please sign in to comment.