Skip to content

Commit 71d84a8

Browse files
committed
Fix lint warnings
1 parent 8460b48 commit 71d84a8

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

node/services/product.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async function fetchProductFromIntsch(
6969
const { field, value } = identifier
7070

7171
// Get locale from context (fallback)
72-
const defaultLocale = ctx.vtex.tenant?.locale || ctx.vtex.locale
72+
const defaultLocale = ctx.vtex.tenant?.locale ?? ctx.vtex.locale
7373

7474
// Default salesChannel from args
7575
let finalSalesChannel = salesChannel ? `${salesChannel}` : undefined
@@ -170,9 +170,9 @@ export async function resolveProduct(
170170
const args =
171171
rawArgs && isValidProductIdentifier(rawArgs.identifier)
172172
? rawArgs
173-
: { identifier: { field: 'slug', value: rawArgs.slug! } }
173+
: { identifier: { field: 'slug', value: rawArgs.slug ?? '' } }
174174

175-
if (!args.identifier) {
175+
if (!args.identifier?.value) {
176176
throw new Error('No product identifier provided')
177177
}
178178

@@ -205,7 +205,7 @@ export async function resolveProduct(
205205
return null
206206
}
207207

208-
const product = products[0]
208+
const [product] = products
209209

210210
return product
211211
} catch (error) {
@@ -266,7 +266,7 @@ async function fetchProductsByIdentifierFromIntsch(
266266
const { field, values, salesChannel, regionId } = args
267267

268268
// Get locale from context (fallback)
269-
const defaultLocale = ctx.vtex.tenant?.locale || ctx.vtex.locale
269+
const defaultLocale = ctx.vtex.tenant?.locale ?? ctx.vtex.locale
270270

271271
// Default salesChannel from args
272272
let finalSalesChannel = salesChannel ? `${salesChannel}` : undefined
@@ -334,12 +334,20 @@ export async function resolveProductsByIdentifier(
334334

335335
// Check if current account should use intsch directly
336336
if (shouldUseNewPDPEndpoint) {
337-
products = await fetchProductsByIdentifierFromIntsch(ctx, args, vtexSegment)
337+
products = await fetchProductsByIdentifierFromIntsch(
338+
ctx,
339+
args,
340+
vtexSegment
341+
)
338342
} else {
339-
products = await fetchProductsByIdentifierFromSearch(ctx, args, vtexSegment)
343+
products = await fetchProductsByIdentifierFromSearch(
344+
ctx,
345+
args,
346+
vtexSegment
347+
)
340348
}
341349

342-
return products
350+
return products
343351
} catch (error) {
344352
ctx.vtex.logger.error({
345353
message: 'Error fetching products by identifier',

node/services/productSearch.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const defaultAdvertisementOptions = {
1616
/**
1717
* Fetches product search results using the intelligentSearchApi client (Biggy)
1818
*/
19+
// eslint-disable-next-line max-params
1920
async function fetchProductSearchFromBiggy(
2021
ctx: Context,
2122
args: ProductSearchInput,
@@ -58,6 +59,7 @@ async function fetchProductSearchFromBiggy(
5859
/**
5960
* Fetches product search results using the intsch client (Intelligent Search)
6061
*/
62+
// eslint-disable-next-line max-params
6163
async function fetchProductSearchFromIntsch(
6264
ctx: Context,
6365
args: ProductSearchInput,
@@ -100,6 +102,7 @@ async function fetchProductSearchFromIntsch(
100102
/**
101103
* ProductSearch service that extracts product search fetching logic and implements comparison or flag-based routing
102104
*/
105+
// eslint-disable-next-line max-params
103106
export async function fetchProductSearch(
104107
ctx: Context,
105108
args: ProductSearchInput,

0 commit comments

Comments
 (0)