Skip to content

Commit

Permalink
chore(linter): enable no-unused-vars error
Browse files Browse the repository at this point in the history
This makes it so that the linter will error
out when there are unused variables.
This is more important than it looks because unused imports can contribute
a lot of overhead to the build artifact sizes.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Feb 2, 2021
1 parent 8854039 commit 4ddda0b
Show file tree
Hide file tree
Showing 44 changed files with 86 additions and 222 deletions.
11 changes: 4 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ module.exports = {
"no-prototype-builtins": "error",
"@typescript-eslint/no-var-requires": "warn",
"no-dupe-class-members": "off",
"no-unused-vars": [
"warn",
{
vars: "all",
args: "after-used",
ignoreRestSiblings: false,
},
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ ignoreRestSiblings: true },
],
indent: ["off"],
semi: ["error", "always"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
PluginLedgerConnectorQuorum,
Web3SigningCredentialType,
DefaultApi as QuorumApi,
EthContractInvocationType,
} from "@hyperledger/cactus-plugin-ledger-connector-quorum";

import {
Expand All @@ -41,10 +40,7 @@ import {
} from "@hyperledger/cactus-plugin-ledger-connector-besu";

import { SupplyChainAppDummyInfrastructure } from "./infrastructure/supply-chain-app-dummy-infrastructure";
import {
BambooHarvest,
SupplyChainCactusPlugin,
} from "@hyperledger/cactus-example-supply-chain-business-logic-plugin";
import { SupplyChainCactusPlugin } from "@hyperledger/cactus-example-supply-chain-business-logic-plugin";

export interface ISupplyChainAppOptions {
logLevel?: LogLevelDesc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Express, Request, Response, NextFunction } from "express";
import { Express, Request, Response } from "express";

import {
Logger,
Expand Down Expand Up @@ -39,7 +39,7 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {

private readonly log: Logger;

public get className() {
public get className(): string {
return InsertBambooHarvestEndpoint.CLASS_NAME;
}

Expand Down Expand Up @@ -76,11 +76,7 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {
return this.handleRequest.bind(this);
}

async handleRequest(
req: Request,
res: Response,
next: NextFunction,
): Promise<void> {
async handleRequest(req: Request, res: Response): Promise<void> {
const tag = `${this.getVerbLowerCase().toUpperCase()} ${this.getPath()}`;
try {
const { bambooHarvest } = req.body as InsertBambooHarvestRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Express, Request, Response, NextFunction } from "express";
import { Express, Request, Response } from "express";

import {
Logger,
Expand Down Expand Up @@ -39,7 +39,7 @@ export class InsertBookshelfEndpoint implements IWebServiceEndpoint {

private readonly log: Logger;

public get className() {
public get className(): string {
return InsertBookshelfEndpoint.CLASS_NAME;
}

Expand Down Expand Up @@ -76,11 +76,7 @@ export class InsertBookshelfEndpoint implements IWebServiceEndpoint {
return this.handleRequest.bind(this);
}

async handleRequest(
req: Request,
res: Response,
next: NextFunction,
): Promise<void> {
async handleRequest(req: Request, res: Response): Promise<void> {
const tag = `${this.getVerbLowerCase().toUpperCase()} ${this.getPath()}`;
try {
const { bookshelf } = req.body as InsertBookshelfRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Express, Request, Response, NextFunction } from "express";
import { Express, Request, Response } from "express";

import {
Logger,
Expand Down Expand Up @@ -75,11 +75,7 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint {
return this.handleRequest.bind(this);
}

async handleRequest(
req: Request,
res: Response,
next: NextFunction,
): Promise<void> {
async handleRequest(req: Request, res: Response): Promise<void> {
const tag = `${this.getVerbLowerCase().toUpperCase()} ${this.getPath()}`;
try {
this.log.debug(`${tag}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Express, Request, Response, NextFunction } from "express";
import { Express, Request, Response } from "express";

import {
Logger,
Expand Down Expand Up @@ -38,7 +38,7 @@ export class ListBookshelfEndpoint implements IWebServiceEndpoint {

private readonly log: Logger;

public get className() {
public get className(): string {
return ListBookshelfEndpoint.CLASS_NAME;
}

Expand Down Expand Up @@ -75,11 +75,7 @@ export class ListBookshelfEndpoint implements IWebServiceEndpoint {
return this.handleRequest.bind(this);
}

async handleRequest(
req: Request,
res: Response,
next: NextFunction,
): Promise<void> {
async handleRequest(req: Request, res: Response): Promise<void> {
const tag = `${this.getVerbLowerCase().toUpperCase()} ${this.getPath()}`;
try {
this.log.debug(`${tag}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from "@angular/core";
import { Component } from "@angular/core";

import { Platform } from "@ionic/angular";
import { SplashScreen } from "@ionic-native/splash-screen/ngx";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { ModalController } from "@ionic/angular";

import { ApiClient } from "@hyperledger/cactus-api-client";
import {
BambooHarvest,
DefaultApi as SupplyChainApi,
} from "@hyperledger/cactus-example-supply-chain-business-logic-plugin";
import { BambooHarvest } from "@hyperledger/cactus-example-supply-chain-business-logic-plugin";

import { QUORUM_DEMO_LEDGER_ID } from "../../../constants";
import { Logger, LoggerProvider } from "@hyperledger/cactus-common";
Expand Down Expand Up @@ -55,13 +52,13 @@ export class BambooHarvestDetailPage implements OnInit {
});
}

onClickFormSubmit(value: any) {
public onClickFormSubmit(value: any): void {
this.log.debug("form submitted", value);
this.bambooHarvest = value;
this.modalController.dismiss(this.bambooHarvest);
}

onClickBtnCancel() {
public onClickBtnCancel(): void {
this.log.debug("form submission cancelled by user");
this.modalController.dismiss();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Component, Inject, OnInit } from "@angular/core";

import { v4 as uuidv4 } from "uuid";

import { Logger, LoggerProvider } from "@hyperledger/cactus-common";
import { ApiClient } from "@hyperledger/cactus-api-client";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const main = async () => {
}
};

export async function launchApp(cliOpts?: any): Promise<void> {
export async function launchApp(): Promise<void> {
try {
await main();
log.info(`Cactus API server launched OK `);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import test, { Test } from "tape-promise/tape";
import { v4 as uuidv4 } from "uuid";

import { LogLevelDesc } from "@hyperledger/cactus-common";

import { ApiServer, ConfigService } from "../../../main/typescript/public-api";

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ tap.test("works with HTTPS NodeJS module", async (assert: any) => {
),
);

aServer.once("tlsClientError", (err: Error) => reject(err));
aServer.once("listening", () => resolve(aServer));
aServer.listen(0, "localhost");
assert.tearDown(() => aServer.close());
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-cockpit/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Inject } from "@angular/core";
import { Component, Inject } from "@angular/core";

import { Platform } from "@ionic/angular";
import { SplashScreen } from "@ionic-native/splash-screen/ngx";
Expand Down
3 changes: 1 addition & 2 deletions packages/cactus-cockpit/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "@angular/compiler";
import { NgModule, APP_INITIALIZER, InjectionToken } from "@angular/core";
import { NgModule } from "@angular/core";

import { HttpClientModule } from "@angular/common/http";
import { BrowserModule } from "@angular/platform-browser";
import { RouteReuseStrategy } from "@angular/router";

Expand Down
8 changes: 2 additions & 6 deletions packages/cactus-common/src/main/typescript/logging/logger.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import libLogLevel, {
Logger as LogLevelLogger,
levels,
LogLevelDesc,
} from "loglevel";
import libLogLevel, { Logger as LogLevelLogger, LogLevelDesc } from "loglevel";
import prefix from "loglevel-plugin-prefix";

prefix.reg(libLogLevel);
Expand Down Expand Up @@ -46,7 +42,7 @@ export class Logger {
this.backend.setLevel(logLevel);
}

public async shutdown(gracePeriodMillis = 60000): Promise<void> {
public async shutdown(): Promise<void> {
this.backend.info("Shut down logger OK.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ test("Circular JSON Test", async (assert: Test) => {
};
const jsObjectSigner = new JsObjectSigner(jsObjectSignerOptions);

const date: Date = new Date();

const obj: any = { a: "foo" };
obj.b = obj;

Expand Down Expand Up @@ -209,8 +207,7 @@ test("Test missing required constructor field", async (assert: Test) => {
const jsObjectSignerOptions: IJsObjectSignerOptions = {
privateKey: undefined,
};

const jsObjectSigner = new JsObjectSigner(jsObjectSignerOptions);
new JsObjectSigner(jsObjectSignerOptions);
} catch (e) {
assert.equal(e.message, "JsObjectSigner#ctor options.privateKey falsy.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export interface IPluginKeychain extends ICactusPlugin {
has(key: string): Promise<boolean>;
get<T>(key: string): Promise<T>;
set<T>(key: string, value: T): Promise<void>;
delete<T>(key: string): Promise<void>;
delete(key: string): Promise<void>;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Express, Request, Response, NextFunction } from "express";
import { AxiosResponse } from "axios";
import { Express, Request, Response } from "express";

import {
IWebServiceEndpoint,
Expand All @@ -11,7 +10,6 @@ import {
import {
Configuration,
DefaultApi,
GetNodeJwsResponse,
} from "../generated/openapi/typescript-axios";

import {
Expand Down Expand Up @@ -80,11 +78,7 @@ export class GetConsortiumEndpointV1 implements IWebServiceEndpoint {
return this;
}

async handleRequest(
req: Request,
res: Response,
next: NextFunction,
): Promise<void> {
async handleRequest(req: Request, res: Response): Promise<void> {
const fnTag = "GetConsortiumJwsEndpointV1#handleRequest()";
this.log.debug(`GET ${this.getPath()}`);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid from "uuid";
import { Express, Request, Response, NextFunction } from "express";
import { Express, Request, Response } from "express";
import { JWS, JWK } from "jose";
import jsonStableStringify from "json-stable-stringify";

Expand Down Expand Up @@ -77,11 +77,7 @@ export class GetNodeJwsEndpoint implements IWebServiceEndpoint {
return this;
}

async handleRequest(
req: Request,
res: Response,
next: NextFunction,
): Promise<void> {
async handleRequest(req: Request, res: Response): Promise<void> {
try {
this.log.debug(`GET ${this.getPath()}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import {
ICactusPluginOptions,
} from "@hyperledger/cactus-core-api";

import {
PluginRegistry,
IConsortiumRepositoryOptions,
ConsortiumRepository,
} from "@hyperledger/cactus-core";
import { PluginRegistry, ConsortiumRepository } from "@hyperledger/cactus-core";

import {
Checks,
Expand Down Expand Up @@ -82,7 +78,7 @@ export class PluginConsortiumManual
}

public async installWebServices(
expressApp: any,
expressApp: Express,
): Promise<IWebServiceEndpoint[]> {
const { log } = this;

Expand Down Expand Up @@ -113,7 +109,6 @@ export class PluginConsortiumManual
}

const { consortiumDatabase, keyPairPem } = this.options;
const packageName = this.getPackageName();
const consortiumRepo = new ConsortiumRepository({
db: consortiumDatabase,
});
Expand Down
Loading

0 comments on commit 4ddda0b

Please sign in to comment.