From 866e58c0997536e371119761cceb713eeb81407f Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 29 Apr 2024 14:08:40 +0200 Subject: [PATCH] fixing linting for doc-gen --- apps/doc-gen/src/app/docgen-client.ts | 6 +- .../src/app/docgen/common/properties.ts | 72 +++++++++---------- apps/doc-gen/src/app/docgen/templates.ts | 7 +- .../src/app/docgen/utils/memoized-getter.ts | 18 ++--- apps/doc-gen/src/app/docgen/utils/natspec.ts | 8 +-- .../app/docgen/utils/normalizeContractPath.ts | 2 +- 6 files changed, 56 insertions(+), 57 deletions(-) diff --git a/apps/doc-gen/src/app/docgen-client.ts b/apps/doc-gen/src/app/docgen-client.ts index ee06c3237f..c3801ecf81 100644 --- a/apps/doc-gen/src/app/docgen-client.ts +++ b/apps/doc-gen/src/app/docgen-client.ts @@ -17,7 +17,7 @@ export class DocGenClient extends PluginClient { public docs: string[] = [] private fileName: string = '' private contractPath: string = '' - + constructor() { super() this.eventEmitter = new EventEmitter() @@ -30,7 +30,7 @@ export class DocGenClient extends PluginClient { async setListeners() { this.currentTheme = await this.call('theme', 'currentTheme') - + this.on('theme', 'themeChanged', (theme: any) => { this.currentTheme = theme this.eventEmitter.emit('themeChanged', this.currentTheme) @@ -50,7 +50,7 @@ export class DocGenClient extends PluginClient { } const segmentedPathList = normalizeContractPath(fileName) this.fileName = segmentedPathList[segmentedPathList.length - 1] - this.contractPath = segmentedPathList[0] + this.contractPath = segmentedPathList[0] this.eventEmitter.emit('compilationFinished', this.build, this.fileName) }) } diff --git a/apps/doc-gen/src/app/docgen/common/properties.ts b/apps/doc-gen/src/app/docgen/common/properties.ts index 5366e8d7ef..f3e197953e 100644 --- a/apps/doc-gen/src/app/docgen/common/properties.ts +++ b/apps/doc-gen/src/app/docgen/common/properties.ts @@ -36,47 +36,47 @@ export function fullName ({ item, contract }: DocItemContext): string { export function signature ({ item }: DocItemContext): string | undefined { switch (item.nodeType) { - case 'ContractDefinition': - return undefined; - - case 'FunctionDefinition': { - const { kind, name } = item; - const params = item.parameters.parameters; - const returns = item.returnParameters.parameters; - const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; - const res = [ - `${head}(${params.map(formatVariable).join(', ')})`, - item.visibility, - ]; - if (item.stateMutability !== 'nonpayable') { - res.push(item.stateMutability); - } - if (item.virtual) { - res.push('virtual'); - } - if (returns.length > 0) { - res.push(`returns (${returns.map(formatVariable).join(', ')})`); - } - return res.join(' '); + case 'ContractDefinition': + return undefined; + + case 'FunctionDefinition': { + const { kind, name } = item; + const params = item.parameters.parameters; + const returns = item.returnParameters.parameters; + const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; + const res = [ + `${head}(${params.map(formatVariable).join(', ')})`, + item.visibility, + ]; + if (item.stateMutability !== 'nonpayable') { + res.push(item.stateMutability); } - - case 'EventDefinition': { - const params = item.parameters.parameters; - return `event ${item.name}(${params.map(formatVariable).join(', ')})`; + if (item.virtual) { + res.push('virtual'); } - - case 'ErrorDefinition': { - const params = item.parameters.parameters; - return `error ${item.name}(${params.map(formatVariable).join(', ')})`; + if (returns.length > 0) { + res.push(`returns (${returns.map(formatVariable).join(', ')})`); } + return res.join(' '); + } - case 'ModifierDefinition': { - const params = item.parameters.parameters; - return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; - } + case 'EventDefinition': { + const params = item.parameters.parameters; + return `event ${item.name}(${params.map(formatVariable).join(', ')})`; + } + + case 'ErrorDefinition': { + const params = item.parameters.parameters; + return `error ${item.name}(${params.map(formatVariable).join(', ')})`; + } + + case 'ModifierDefinition': { + const params = item.parameters.parameters; + return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; + } - case 'VariableDeclaration': - return formatVariable(item); + case 'VariableDeclaration': + return formatVariable(item); } } diff --git a/apps/doc-gen/src/app/docgen/templates.ts b/apps/doc-gen/src/app/docgen/templates.ts index b83d0ac77d..34ee88df38 100644 --- a/apps/doc-gen/src/app/docgen/templates.ts +++ b/apps/doc-gen/src/app/docgen/templates.ts @@ -3,7 +3,7 @@ import { mapKeys } from './utils/map-keys'; import { DocItemContext } from './site'; import * as defaultProperties from './common/properties'; -import * as themeHelpers from './themes/markdown/helpers' +import * as themeHelpers from './themes/markdown/helpers' const common = require('./themes/markdown/common.hbs'); const contract = require('./themes/markdown/contract.hbs'); @@ -45,7 +45,6 @@ export async function loadTemplates(defaultTheme: string, root: string, userTemp properties: { ...defaultProperties }, }; - // Add partials and helpers from all themes, prefixed with the theme name. for (const [themeName, theme] of Object.entries(themes)) { const addPrefix = (k: string) => `${themeName}/${k}`; @@ -86,7 +85,7 @@ async function readPartials() { } async function readHelpers(name: string) { - + const helpers: Record any> = {}; for (const name in themeHelpers) { @@ -94,7 +93,7 @@ async function readHelpers(name: string) { helpers[name] = themeHelpers[name]; } } - + return helpers; } diff --git a/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts b/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts index 1a2fef4ae5..d4814e1da2 100644 --- a/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts +++ b/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts @@ -6,17 +6,17 @@ export function defineGetterMemoized