Skip to content

Commit

Permalink
chore: fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed Sep 5, 2024
1 parent 4922c4d commit 8c81e17
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>
type Decoder = t.Mixed

Expand All @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(params: HttpClientRequestParams) {
Expand Down
2 changes: 1 addition & 1 deletion src/o-auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions src/operations/amazon-ad-type-uri-prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
3 changes: 2 additions & 1 deletion src/operations/commons/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(FRUIT),
Expand Down
2 changes: 2 additions & 0 deletions src/operations/operation-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends Operation>(ops: new (client: HttpClient) => T): T {
return new ops(this.client)
}
Expand Down
7 changes: 4 additions & 3 deletions src/operations/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@ 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 {
[key: string]: OperationParameterValues
}

export type WithOperationParameterKeys<T extends OperationParameter> = {
// eslint-disable-next-line no-unused-vars
[K in keyof T]: OperationParameterValues
}

export type OperationParameterTransformer<T> = (
// eslint-disable-next-line no-unused-vars
originalQuery: T,
// eslint-disable-next-line no-unused-vars
clonedQuery: WithOperationParameterKeys<T>,
) => WithOperationParameterKeys<T>

export class Operation {
protected version = 'v2'
protected resource = ''

// eslint-disable-next-line no-unused-vars
constructor(protected client: HttpClient) {}

public static create<T extends typeof Operation>(
Expand All @@ -31,7 +34,6 @@ export class Operation {
return new this(httpClient) as InstanceType<T>
}

// eslint-disable-next-line class-methods-use-this
protected query<T extends OperationParameter>(
resource: string,
originalQuery?: T,
Expand All @@ -48,7 +50,6 @@ export class Operation {
return `${resource}?${stringify(transformer(originalQuery, clonedQuery))}`
}

// eslint-disable-next-line class-methods-use-this
private hasKey<T>(obj: T, key: string | number | symbol): key is keyof T {
return key in obj
}
Expand Down
1 change: 0 additions & 1 deletion src/operations/reports/base-report-operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class BaseReportOperation extends Operation {
* @param reportId -
* @returns \{(Promise\<Partial\<Record\<T, 'number' | 'string'\>\>[]\>)\}
*/
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
public async downloadReport<T extends string>(
reportId: ReportId,
): Promise<Partial<Record<T, 'number' | 'string'>>[]> {
Expand Down
4 changes: 2 additions & 2 deletions test/o-auth-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -43,7 +43,7 @@ describe(OAuthClient.name, () => {
refresh_token: PLACEHOLDER,
}),
)
/* eslint-enable @typescript-eslint/camelcase */
/* eslint-enable camelcase */
})
})

Expand Down
8 changes: 5 additions & 3 deletions test/polly.js
Original file line number Diff line number Diff line change
@@ -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__'),
},
},
Expand All @@ -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) => {
Expand Down

0 comments on commit 8c81e17

Please sign in to comment.