Skip to content

Commit 478db7c

Browse files
committed
chore: fixing linting issues for codacy
1 parent b2e78b8 commit 478db7c

File tree

7 files changed

+12
-20
lines changed

7 files changed

+12
-20
lines changed

src/common/dom.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const processContainer = <
6060
elements: T,
6161
type: keyof T,
6262
): processedElement<T, F> | string => {
63-
const contained = document.getElementById(`${elements[type]}-tag-frame`);
63+
const contained = document.getElementById(`${elements[type] as string}-tag-frame`);
6464
if (contained === null) {
6565
const frameType = webComponentMap[type as ElementTypes];
6666
const frame = addFrame(frameType, elements[type] as string) as F;

src/common/format.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const parseInputParams = (
6060
const inputCopy = JSON.parse(JSON.stringify(inputParams)) as ModifiedTransactProps;
6161
inputCopy.payTheoryData = {
6262
account_code: inputParams.accountCode ?? (metadata['pay-theory-account-code'] as string),
63-
billing_info: (inputParams as TransactProps).billingInfo as BillingInfo | undefined,
64-
fee: (inputParams as TransactProps).fee as number | undefined,
65-
invoice_id: invoiceId as string | undefined,
63+
billing_info: (inputParams as TransactProps).billingInfo,
64+
fee: (inputParams as TransactProps).fee,
65+
invoice_id: invoiceId,
6666
payment_parameters:
6767
inputParams.paymentParameters ?? (metadata['payment-parameters-name'] as string),
68-
payor_id: payorId as string | undefined,
68+
payor_id: payorId,
6969
receipt_description:
7070
(inputParams as TransactProps).receiptDescription ??
7171
(metadata['pay-theory-receipt-description'] as string),

src/common/pay_theory_types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface ErrorResponse {
142142
export interface TokenizeProps {
143143
payorInfo?: PayorInfo;
144144
payorId?: string;
145-
metadata?: { [keys: string | number]: string | number | boolean };
145+
metadata?: Record<string | number, string | number | boolean>;
146146
billingInfo?: BillingInfo;
147147
}
148148

@@ -151,7 +151,7 @@ export interface TransactProps {
151151
payorInfo?: PayorInfo;
152152
billingInfo?: BillingInfo;
153153
payorId?: string;
154-
metadata?: { [keys: string | number]: string | number | boolean };
154+
metadata?: Record<string | number, string | number | boolean>;
155155
feeMode?: typeof MERCHANT_FEE | typeof SERVICE_FEE;
156156
fee?: number;
157157
confirmation?: boolean;

src/components/pay-theory-checkout-button/index.ts

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class PayTheoryCheckoutButton extends HTMLElement {
2020
protected _buttonBarcode: string | undefined;
2121
protected _session: string | undefined;
2222

23-
constructor() {
24-
super();
25-
}
26-
2723
defineButton() {
2824
// Creating the iFrame for the Button
2925
const buttonFrame = document.createElement('iframe');

src/components/pay-theory-checkout-qr/index.ts

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ class PayTheoryCheckoutQR extends HTMLElement {
1414
protected _clearSuccessListener: (() => void) | undefined;
1515
protected _clearErrorListener: (() => void) | undefined;
1616

17-
constructor() {
18-
super();
19-
}
20-
2117
defineQR() {
2218
// Creating the iFrame for the Button
2319
const qrFrame = document.createElement('iframe');

src/field-set/payment-fields-v2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ const payTheoryFields = async (inputParams: PayTheoryPaymentFieldsInput) =>
235235
const result = initializeFields(inputParams, channel.port2);
236236
if (result) resolve(result);
237237
} else {
238-
document.addEventListener('DOMContentLoaded', async () => {
238+
document.addEventListener('DOMContentLoaded', () => {
239239
const result = initializeFields(inputParams, channel.port2);
240240
if (result) resolve(result);
241241
});

src/field-set/payment-qr.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export default async (inputParams: PayTheoryQRInput) => {
1818
? modifiedCheckoutDetails.feeMode
1919
: common.defaultFeeMode;
2020
const { paymentName, callToAction, acceptedPaymentMethods } = modifiedCheckoutDetails;
21-
let removeErrorListener = () => {};
22-
let removeHostedErrorListener = () => {};
21+
let removeErrorListener: (() => void) | null = null;
22+
let removeHostedErrorListener: (() => void) | null = null;
2323
// Putting error listener on the window and hosted button so that it can catch errors while it readies the session
2424
if (onError) {
2525
removeErrorListener = common.errorObserver(onError);
@@ -47,8 +47,8 @@ export default async (inputParams: PayTheoryQRInput) => {
4747
// Adding logic to onReady to receive the session data for redirecting to the hosted checkout page
4848
const onReadyWrapper = () => {
4949
// Remove the error listener because we added it to the button iFrame and do not want it to be called twice
50-
removeErrorListener();
51-
removeHostedErrorListener();
50+
if (removeErrorListener) removeErrorListener();
51+
if (removeHostedErrorListener) removeHostedErrorListener();
5252
if (onReady) {
5353
onReady(true);
5454
}

0 commit comments

Comments
 (0)