mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 02:43:24 +00:00
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:
@@ -44,6 +44,7 @@ export async function POST(request: Request) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error('Failed to create payment:', error)
|
console.error('Failed to create payment:', error)
|
||||||
return Response.json(
|
return Response.json(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,13 +1,4 @@
|
|||||||
import configPromise from '@payload-config'
|
export const GET = async () => {
|
||||||
import { getPayload } from 'payload'
|
|
||||||
import { useBillingPlugin } from '../../../src/plugin'
|
|
||||||
|
|
||||||
export const GET = async (request: Request) => {
|
|
||||||
const payload = await getPayload({
|
|
||||||
config: configPromise,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
return Response.json({
|
return Response.json({
|
||||||
message: 'This is an example of a custom route.',
|
message: 'This is an example of a custom route.',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,9 +20,13 @@ export const defaultESLintIgnores = [
|
|||||||
'**/build/',
|
'**/build/',
|
||||||
'**/node_modules/',
|
'**/node_modules/',
|
||||||
'**/temp/',
|
'**/temp/',
|
||||||
|
'**/dev/**', // Ignore dev demo directory
|
||||||
]
|
]
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
{
|
||||||
|
ignores: defaultESLintIgnores,
|
||||||
|
},
|
||||||
...payloadEsLintConfig,
|
...payloadEsLintConfig,
|
||||||
{
|
{
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {
|
import type {
|
||||||
AccessArgs,
|
AccessArgs,
|
||||||
CollectionAfterChangeHook,
|
CollectionAfterChangeHook,
|
||||||
CollectionBeforeChangeHook,
|
CollectionBeforeChangeHook,
|
||||||
@@ -390,7 +390,7 @@ export function createInvoicesCollection(pluginConfig: BillingPluginConfig): Col
|
|||||||
] satisfies CollectionBeforeChangeHook<Invoice>[],
|
] satisfies CollectionBeforeChangeHook<Invoice>[],
|
||||||
beforeValidate: [
|
beforeValidate: [
|
||||||
({ data }) => {
|
({ data }) => {
|
||||||
if (!data) return
|
if (!data) {return}
|
||||||
|
|
||||||
// If using extractor, customer relationship is required
|
// If using extractor, customer relationship is required
|
||||||
if (customerRelationSlug && customerInfoExtractor && !data.customer) {
|
if (customerRelationSlug && customerInfoExtractor && !data.customer) {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import type { AccessArgs, CollectionConfig } from 'payload'
|
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 { extractSlug } from '../plugin/utils'
|
||||||
import { Payment } from '../plugin/types/index'
|
import type { Payment } from '../plugin/types/index'
|
||||||
import { createContextLogger } from '../utils/logger'
|
import { createContextLogger } from '../utils/logger'
|
||||||
|
|
||||||
export function createRefundsCollection(pluginConfig: BillingPluginConfig): CollectionConfig {
|
export function createRefundsCollection(pluginConfig: BillingPluginConfig): CollectionConfig {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const PaymentStatusBadge: React.FC<{ status: string }> = ({ status }) =>
|
|||||||
|
|
||||||
// Test mode indicator components
|
// Test mode indicator components
|
||||||
export const TestModeWarningBanner: React.FC<{ visible?: boolean }> = ({ visible = true }) => {
|
export const TestModeWarningBanner: React.FC<{ visible?: boolean }> = ({ visible = true }) => {
|
||||||
if (!visible) return null
|
if (!visible) {return null}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
@@ -75,13 +75,13 @@ export const TestModeWarningBanner: React.FC<{ visible?: boolean }> = ({ visible
|
|||||||
marginBottom: '20px',
|
marginBottom: '20px',
|
||||||
borderRadius: '4px'
|
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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TestModeBadge: React.FC<{ visible?: boolean }> = ({ visible = true }) => {
|
export const TestModeBadge: React.FC<{ visible?: boolean }> = ({ visible = true }) => {
|
||||||
if (!visible) return null
|
if (!visible) {return null}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span style={{
|
<span style={{
|
||||||
@@ -127,7 +127,7 @@ export const TestPaymentControls: React.FC<{
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ border: '1px solid #e9ecef', borderRadius: '8px', padding: '16px', margin: '16px 0' }}>
|
<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' }}>
|
<div style={{ marginBottom: '16px' }}>
|
||||||
<label style={{ display: 'block', marginBottom: '8px', fontWeight: '600' }}>Payment Method:</label>
|
<label style={{ display: 'block', marginBottom: '8px', fontWeight: '600' }}>Payment Method:</label>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ interface BillingServerStatsProps {
|
|||||||
payloadInstance?: unknown
|
payloadInstance?: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BillingServerStats: React.FC<BillingServerStatsProps> = async ({
|
export const BillingServerStats: React.FC<BillingServerStatsProps> = ({
|
||||||
payloadInstance
|
payloadInstance: _payloadInstance
|
||||||
}) => {
|
}) => {
|
||||||
// In a real implementation, this would fetch data from the database
|
// In a real implementation, this would fetch data from the database
|
||||||
// const stats = await payloadInstance?.find({
|
// const stats = await payloadInstance?.find({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CollectionConfig } from 'payload'
|
import type { CollectionConfig } from 'payload'
|
||||||
import { FieldsOverride } from './utils'
|
import type { FieldsOverride } from './utils'
|
||||||
import { PaymentProvider } from './types/index'
|
import type { PaymentProvider } from './types/index'
|
||||||
|
|
||||||
export const defaults = {
|
export const defaults = {
|
||||||
paymentsCollection: 'payments',
|
paymentsCollection: 'payments',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Payment } from './payments'
|
import type { Payment } from './payments'
|
||||||
import { Id } from './id'
|
import type { Id } from './id'
|
||||||
|
|
||||||
export interface Invoice<TCustomer = unknown> {
|
export interface Invoice<TCustomer = unknown> {
|
||||||
id: Id;
|
id: Id;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Refund } from './refunds'
|
import type { Refund } from './refunds'
|
||||||
import { Invoice } from './invoices'
|
import type { Invoice } from './invoices'
|
||||||
import { Id } from './id'
|
import type { Id } from './id'
|
||||||
|
|
||||||
export interface Payment {
|
export interface Payment {
|
||||||
id: Id;
|
id: Id;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Payment } from './payments'
|
import type { Payment } from './payments'
|
||||||
|
|
||||||
export interface Refund {
|
export interface Refund {
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
@@ -281,10 +281,10 @@ export const testProvider = (testConfig: TestProviderConfig) => {
|
|||||||
{
|
{
|
||||||
path: '/payload-billing/test/config',
|
path: '/payload-billing/test/config',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
handler: async (req) => {
|
handler: () => {
|
||||||
const response: TestProviderConfigResponse = {
|
const response: TestProviderConfigResponse = {
|
||||||
enabled: testConfig.enabled,
|
enabled: testConfig.enabled,
|
||||||
scenarios: scenarios,
|
scenarios,
|
||||||
methods: Object.entries(PAYMENT_METHODS).map(([id, method]) => ({
|
methods: Object.entries(PAYMENT_METHODS).map(([id, method]) => ({
|
||||||
id,
|
id,
|
||||||
name: method.name,
|
name: method.name,
|
||||||
@@ -525,7 +525,7 @@ async function processTestPayment(
|
|||||||
pluginConfig: BillingPluginConfig
|
pluginConfig: BillingPluginConfig
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (!session.scenario) return
|
if (!session.scenario) {return}
|
||||||
|
|
||||||
// Map scenario outcome to payment status
|
// Map scenario outcome to payment status
|
||||||
let finalStatus: Payment['status'] = 'pending'
|
let finalStatus: Payment['status'] = 'pending'
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export async function updatePaymentStatus(
|
|||||||
const paymentInTransaction = await payload.findByID({
|
const paymentInTransaction = await payload.findByID({
|
||||||
collection: paymentsCollection,
|
collection: paymentsCollection,
|
||||||
id: toPayloadId(paymentId),
|
id: toPayloadId(paymentId),
|
||||||
req: { transactionID: transactionID }
|
req: { transactionID }
|
||||||
}) as Payment
|
}) as Payment
|
||||||
|
|
||||||
// Check if version still matches
|
// Check if version still matches
|
||||||
@@ -115,7 +115,7 @@ export async function updatePaymentStatus(
|
|||||||
},
|
},
|
||||||
version: currentVersion + 1
|
version: currentVersion + 1
|
||||||
},
|
},
|
||||||
req: { transactionID: transactionID }
|
req: { transactionID }
|
||||||
})
|
})
|
||||||
|
|
||||||
await payload.db.commitTransaction(transactionID)
|
await payload.db.commitTransaction(transactionID)
|
||||||
@@ -139,7 +139,7 @@ export async function updateInvoiceOnPaymentSuccess(
|
|||||||
payment: Payment,
|
payment: Payment,
|
||||||
pluginConfig: BillingPluginConfig
|
pluginConfig: BillingPluginConfig
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!payment.invoice) return
|
if (!payment.invoice) {return}
|
||||||
|
|
||||||
const invoicesCollection = extractSlug(pluginConfig.collections?.invoices || defaults.invoicesCollection)
|
const invoicesCollection = extractSlug(pluginConfig.collections?.invoices || defaults.invoicesCollection)
|
||||||
const invoiceId = typeof payment.invoice === 'object'
|
const invoiceId = typeof payment.invoice === 'object'
|
||||||
@@ -206,7 +206,7 @@ export function logWebhookEvent(
|
|||||||
export function validateProductionUrl(url: string | undefined, urlType: string): void {
|
export function validateProductionUrl(url: string | undefined, urlType: string): void {
|
||||||
const isProduction = process.env.NODE_ENV === 'production'
|
const isProduction = process.env.NODE_ENV === 'production'
|
||||||
|
|
||||||
if (!isProduction) return
|
if (!isProduction) {return}
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
throw new Error(`${urlType} URL is required for production`)
|
throw new Error(`${urlType} URL is required for production`)
|
||||||
|
|||||||
Reference in New Issue
Block a user