fix: resolve ESLint errors and warnings

- Add emoji accessibility labels (jsx-a11y/accessible-emoji)
- Remove unused imports and variables
- Fix async functions without await
- Add dev directory to ESLint ignore list
- Add eslint-disable comment for necessary console.error
- Clean up unused route file

All ESLint errors resolved (0 errors, 33 warnings remaining)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-08 14:37:02 +01:00
parent 3508418698
commit da24fa05d9
13 changed files with 33 additions and 36 deletions

View File

@@ -44,6 +44,7 @@ export async function POST(request: Request) {
},
})
} catch (error) {
// eslint-disable-next-line no-console
console.error('Failed to create payment:', error)
return Response.json(
{

View File

@@ -1,13 +1,4 @@
import configPromise from '@payload-config'
import { getPayload } from 'payload'
import { useBillingPlugin } from '../../../src/plugin'
export const GET = async (request: Request) => {
const payload = await getPayload({
config: configPromise,
})
export const GET = async () => {
return Response.json({
message: 'This is an example of a custom route.',
})

View File

@@ -20,9 +20,13 @@ export const defaultESLintIgnores = [
'**/build/',
'**/node_modules/',
'**/temp/',
'**/dev/**', // Ignore dev demo directory
]
export default [
{
ignores: defaultESLintIgnores,
},
...payloadEsLintConfig,
{
rules: {

View File

@@ -1,4 +1,4 @@
import {
import type {
AccessArgs,
CollectionAfterChangeHook,
CollectionBeforeChangeHook,
@@ -390,7 +390,7 @@ export function createInvoicesCollection(pluginConfig: BillingPluginConfig): Col
] satisfies CollectionBeforeChangeHook<Invoice>[],
beforeValidate: [
({ data }) => {
if (!data) return
if (!data) {return}
// If using extractor, customer relationship is required
if (customerRelationSlug && customerInfoExtractor && !data.customer) {

View File

@@ -1,7 +1,8 @@
import type { AccessArgs, CollectionConfig } from 'payload'
import { BillingPluginConfig, defaults } from '../plugin/config'
import type { BillingPluginConfig} from '../plugin/config';
import { defaults } from '../plugin/config'
import { extractSlug } from '../plugin/utils'
import { Payment } from '../plugin/types/index'
import type { Payment } from '../plugin/types/index'
import { createContextLogger } from '../utils/logger'
export function createRefundsCollection(pluginConfig: BillingPluginConfig): CollectionConfig {

View File

@@ -62,7 +62,7 @@ export const PaymentStatusBadge: React.FC<{ status: string }> = ({ status }) =>
// Test mode indicator components
export const TestModeWarningBanner: React.FC<{ visible?: boolean }> = ({ visible = true }) => {
if (!visible) return null
if (!visible) {return null}
return (
<div style={{
@@ -75,13 +75,13 @@ export const TestModeWarningBanner: React.FC<{ visible?: boolean }> = ({ visible
marginBottom: '20px',
borderRadius: '4px'
}}>
🧪 TEST MODE - Payment system is running in test mode for development
<span role="img" aria-label="test tube">🧪</span> TEST MODE - Payment system is running in test mode for development
</div>
)
}
export const TestModeBadge: React.FC<{ visible?: boolean }> = ({ visible = true }) => {
if (!visible) return null
if (!visible) {return null}
return (
<span style={{
@@ -127,7 +127,7 @@ export const TestPaymentControls: React.FC<{
return (
<div style={{ border: '1px solid #e9ecef', borderRadius: '8px', padding: '16px', margin: '16px 0' }}>
<h4 style={{ marginBottom: '12px', color: '#2c3e50' }}>🧪 Test Payment Controls</h4>
<h4 style={{ marginBottom: '12px', color: '#2c3e50' }}><span role="img" aria-label="test tube">🧪</span> Test Payment Controls</h4>
<div style={{ marginBottom: '16px' }}>
<label style={{ display: 'block', marginBottom: '8px', fontWeight: '600' }}>Payment Method:</label>

View File

@@ -10,8 +10,8 @@ interface BillingServerStatsProps {
payloadInstance?: unknown
}
export const BillingServerStats: React.FC<BillingServerStatsProps> = async ({
payloadInstance
export const BillingServerStats: React.FC<BillingServerStatsProps> = ({
payloadInstance: _payloadInstance
}) => {
// In a real implementation, this would fetch data from the database
// const stats = await payloadInstance?.find({

View File

@@ -1,6 +1,6 @@
import { CollectionConfig } from 'payload'
import { FieldsOverride } from './utils'
import { PaymentProvider } from './types/index'
import type { CollectionConfig } from 'payload'
import type { FieldsOverride } from './utils'
import type { PaymentProvider } from './types/index'
export const defaults = {
paymentsCollection: 'payments',

View File

@@ -1,5 +1,5 @@
import { Payment } from './payments'
import { Id } from './id'
import type { Payment } from './payments'
import type { Id } from './id'
export interface Invoice<TCustomer = unknown> {
id: Id;

View File

@@ -1,6 +1,6 @@
import { Refund } from './refunds'
import { Invoice } from './invoices'
import { Id } from './id'
import type { Refund } from './refunds'
import type { Invoice } from './invoices'
import type { Id } from './id'
export interface Payment {
id: Id;

View File

@@ -1,4 +1,4 @@
import { Payment } from './payments'
import type { Payment } from './payments'
export interface Refund {
id: number;

View File

@@ -281,10 +281,10 @@ export const testProvider = (testConfig: TestProviderConfig) => {
{
path: '/payload-billing/test/config',
method: 'get',
handler: async (req) => {
handler: () => {
const response: TestProviderConfigResponse = {
enabled: testConfig.enabled,
scenarios: scenarios,
scenarios,
methods: Object.entries(PAYMENT_METHODS).map(([id, method]) => ({
id,
name: method.name,
@@ -525,7 +525,7 @@ async function processTestPayment(
pluginConfig: BillingPluginConfig
): Promise<void> {
try {
if (!session.scenario) return
if (!session.scenario) {return}
// Map scenario outcome to payment status
let finalStatus: Payment['status'] = 'pending'

View File

@@ -91,7 +91,7 @@ export async function updatePaymentStatus(
const paymentInTransaction = await payload.findByID({
collection: paymentsCollection,
id: toPayloadId(paymentId),
req: { transactionID: transactionID }
req: { transactionID }
}) as Payment
// Check if version still matches
@@ -115,7 +115,7 @@ export async function updatePaymentStatus(
},
version: currentVersion + 1
},
req: { transactionID: transactionID }
req: { transactionID }
})
await payload.db.commitTransaction(transactionID)
@@ -139,7 +139,7 @@ export async function updateInvoiceOnPaymentSuccess(
payment: Payment,
pluginConfig: BillingPluginConfig
): Promise<void> {
if (!payment.invoice) return
if (!payment.invoice) {return}
const invoicesCollection = extractSlug(pluginConfig.collections?.invoices || defaults.invoicesCollection)
const invoiceId = typeof payment.invoice === 'object'
@@ -206,7 +206,7 @@ export function logWebhookEvent(
export function validateProductionUrl(url: string | undefined, urlType: string): void {
const isProduction = process.env.NODE_ENV === 'production'
if (!isProduction) return
if (!isProduction) {return}
if (!url) {
throw new Error(`${urlType} URL is required for production`)