From 8c81e17b5f8a50a3ee9dbc0fe011bd1a6791c6a6 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Thu, 5 Sep 2024 14:37:58 +0700 Subject: [PATCH] chore: fix lints --- src/decorators.ts | 2 -- src/http-client.ts | 2 ++ src/o-auth-client.ts | 2 +- src/operations/amazon-ad-type-uri-prefix.ts | 2 ++ src/operations/commons/types.test.ts | 3 ++- src/operations/operation-provider.ts | 2 ++ src/operations/operation.ts | 7 ++++--- src/operations/reports/base-report-operation.ts | 1 - test/o-auth-client.test.ts | 4 ++-- test/polly.js | 8 +++++--- 10 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/decorators.ts b/src/decorators.ts index 964d3273f..a1e09c77f 100644 --- a/src/decorators.ts +++ b/src/decorators.ts @@ -7,7 +7,6 @@ import * as tPromise from 'io-ts-promise' import { Operation } from './operations/operation' -// eslint-disable-next-line @typescript-eslint/no-explicit-any type Descriptor = TypedPropertyDescriptor type Decoder = t.Mixed @@ -16,7 +15,6 @@ export function Decode(decoder: Decoder): Function { const originalMethod = descriptor.value return { - // eslint-disable-next-line @typescript-eslint/no-explicit-any value: function value(...args: any[]) { return Promise.resolve(originalMethod.apply(this, args)).then((res) => tPromise.decode(decoder, res), diff --git a/src/http-client.ts b/src/http-client.ts index 32714145e..578f0fc7c 100644 --- a/src/http-client.ts +++ b/src/http-client.ts @@ -50,9 +50,11 @@ export class HttpClient { public readonly httpStatus = HttpStatus public constructor( + /* eslint-disable no-unused-vars */ private readonly uri: string, private readonly auth: HttpClientAuth, private readonly sandbox = false, + /* eslint-enable no-unused-vars */ ) {} private async request(params: HttpClientRequestParams) { diff --git a/src/o-auth-client.ts b/src/o-auth-client.ts index dbcf670b9..ebd8d8427 100644 --- a/src/o-auth-client.ts +++ b/src/o-auth-client.ts @@ -43,7 +43,7 @@ export class OAuthClient { scopes: ['cpc_advertising:campaign_management'], } - this.client = new ClientOAuth2(defaultsDeep({}, this.opts, amazonOptions), request) + this.client = new ClientOAuth2(defaultsDeep({}, opts, amazonOptions), request) } public get getUri() { diff --git a/src/operations/amazon-ad-type-uri-prefix.ts b/src/operations/amazon-ad-type-uri-prefix.ts index 525ebba2c..2fabf801a 100644 --- a/src/operations/amazon-ad-type-uri-prefix.ts +++ b/src/operations/amazon-ad-type-uri-prefix.ts @@ -7,8 +7,10 @@ * * @example "sp" */ +/* eslint-disable no-unused-vars */ export enum AmazonAdTypeURIPrefix { SponsoredBrands = 'hsa', SponsoredDisplay = 'sd', SponsoredProducts = 'sp', } +/* eslint-enable no-unused-vars */ diff --git a/src/operations/commons/types.test.ts b/src/operations/commons/types.test.ts index cc3d79716..392fc2e4e 100644 --- a/src/operations/commons/types.test.ts +++ b/src/operations/commons/types.test.ts @@ -31,13 +31,14 @@ describe('ResponseStatus', () => { }) describe('EnumType', () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any let FruitItem: any beforeEach(() => { + /* eslint-disable no-unused-vars */ enum FRUIT { APPLE = 'APPLE', BANANA = 'BANANA', } + /* eslint-enable no-unused-vars */ FruitItem = t2.type({ fruit: t.createEnumType(FRUIT), diff --git a/src/operations/operation-provider.ts b/src/operations/operation-provider.ts index b1c91a258..5e3894a14 100644 --- a/src/operations/operation-provider.ts +++ b/src/operations/operation-provider.ts @@ -2,8 +2,10 @@ import { HttpClient } from '../http-client' import { Operation } from './operation' export class OperationProvider { + // eslint-disable-next-line no-unused-vars constructor(private client: HttpClient) {} + // eslint-disable-next-line no-unused-vars create(ops: new (client: HttpClient) => T): T { return new ops(this.client) } diff --git a/src/operations/operation.ts b/src/operations/operation.ts index 1f3676e88..b2351e793 100644 --- a/src/operations/operation.ts +++ b/src/operations/operation.ts @@ -2,7 +2,6 @@ import { HttpClient } from '../http-client' import { stringify } from 'querystring' import { isEmpty, endsWith, cloneDeep } from 'lodash' -// eslint-disable-next-line @typescript-eslint/no-explicit-any export type OperationParameterValues = any export interface OperationParameter { @@ -10,11 +9,14 @@ export interface OperationParameter { } export type WithOperationParameterKeys = { + // eslint-disable-next-line no-unused-vars [K in keyof T]: OperationParameterValues } export type OperationParameterTransformer = ( + // eslint-disable-next-line no-unused-vars originalQuery: T, + // eslint-disable-next-line no-unused-vars clonedQuery: WithOperationParameterKeys, ) => WithOperationParameterKeys @@ -22,6 +24,7 @@ export class Operation { protected version = 'v2' protected resource = '' + // eslint-disable-next-line no-unused-vars constructor(protected client: HttpClient) {} public static create( @@ -31,7 +34,6 @@ export class Operation { return new this(httpClient) as InstanceType } - // eslint-disable-next-line class-methods-use-this protected query( resource: string, originalQuery?: T, @@ -48,7 +50,6 @@ export class Operation { return `${resource}?${stringify(transformer(originalQuery, clonedQuery))}` } - // eslint-disable-next-line class-methods-use-this private hasKey(obj: T, key: string | number | symbol): key is keyof T { return key in obj } diff --git a/src/operations/reports/base-report-operation.ts b/src/operations/reports/base-report-operation.ts index ec0fb7b71..baeccd2ad 100644 --- a/src/operations/reports/base-report-operation.ts +++ b/src/operations/reports/base-report-operation.ts @@ -20,7 +20,6 @@ export class BaseReportOperation extends Operation { * @param reportId - * @returns \{(Promise\\>[]\>)\} */ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type public async downloadReport( reportId: ReportId, ): Promise>[]> { diff --git a/test/o-auth-client.test.ts b/test/o-auth-client.test.ts index 377a037ae..4e18726ec 100644 --- a/test/o-auth-client.test.ts +++ b/test/o-auth-client.test.ts @@ -28,7 +28,7 @@ describe(OAuthClient.name, () => { jestPollyContext.polly.server .post('https://api.amazon.com/auth/o2/token') .on('beforeResponse', (req, res) => { - /* eslint-disable @typescript-eslint/camelcase */ + /* eslint-disable camelcase */ req.body = stringify( Object.assign(parse(req.body), { refresh_token: PLACEHOLDER, @@ -43,7 +43,7 @@ describe(OAuthClient.name, () => { refresh_token: PLACEHOLDER, }), ) - /* eslint-enable @typescript-eslint/camelcase */ + /* eslint-enable camelcase */ }) }) diff --git a/test/polly.js b/test/polly.js index 10f119635..21ffda79b 100644 --- a/test/polly.js +++ b/test/polly.js @@ -1,11 +1,12 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { jestPollyConfigService, jestPollyContext } = require('@scaleleap/jest-polly') -const { resolve } = require('path') +import { jestPollyConfigService, jestPollyContext } from '@scaleleap/jest-polly' +import { resolve } from 'path' +// eslint-disable-next-line no-undef beforeAll(() => { jestPollyConfigService.config = { persisterOptions: { fs: { + // eslint-disable-next-line no-undef recordingsDir: resolve(__dirname, '__recordings__'), }, }, @@ -15,6 +16,7 @@ beforeAll(() => { } }) +// eslint-disable-next-line no-undef beforeEach(() => { // removes secrets from stored recordings jestPollyContext.polly.server.any().on('beforePersist', (req, rec) => {