fix: corrige erros do ESLint e configura variáveis globais

- Adiciona variáveis globais do Node.js (process, console, __dirname, require, module, exports)
- Adiciona variáveis globais do Jest (describe, it, beforeEach, fail, etc.)
- Configura ESLint para arquivos JavaScript de configuração
- Remove diretivas eslint-disable não utilizadas
- Corrige variáveis não usadas prefixando com _
- Ajusta regras do ESLint para ignorar variáveis que começam com _
- Formata código com Prettier
This commit is contained in:
JuruSysadmin
2025-11-21 17:05:07 -03:00
parent d5286fe91a
commit 233734fdea
48 changed files with 395 additions and 319 deletions

View File

@@ -74,11 +74,11 @@ export async function createDataConsultServiceTestModule(
error: jest.fn(),
};
jest.spyOn(Logger.prototype, 'error').mockImplementation(
(message: any, ...optionalParams: any[]) => {
jest
.spyOn(Logger.prototype, 'error')
.mockImplementation((message: any, ...optionalParams: any[]) => {
mockLogger.error(message, ...optionalParams);
},
);
});
return {
service,

View File

@@ -623,15 +623,15 @@ describe('DataConsultService', () => {
});
it('should throw error when filter is invalid', async () => {
await expect(
context.service.products(null as any),
).rejects.toThrow(HttpException);
await expect(context.service.products(null as any)).rejects.toThrow(
HttpException,
);
await expect(
context.service.products(undefined as any),
).rejects.toThrow(HttpException);
await expect(
context.service.products('' as any),
).rejects.toThrow(HttpException);
await expect(context.service.products('' as any)).rejects.toThrow(
HttpException,
);
});
it('should log error when repository throws exception', async () => {

View File

@@ -1,6 +1,4 @@
import {
ApiTags,
} from '@nestjs/swagger';
import { ApiTags } from '@nestjs/swagger';
import { Controller, Get, Param } from '@nestjs/common';
import { clientesService } from './clientes.service';

View File

@@ -1,5 +1,3 @@
/* eslint-disable prettier/prettier */
import { clientesService } from './clientes.service';
import { clientesController } from './clientes.controller';
@@ -10,10 +8,8 @@ https://docs.nestjs.com/modules
import { Module } from '@nestjs/common';
@Module({
imports: [],
controllers: [
clientesController,],
providers: [
clientesService,],
imports: [],
controllers: [clientesController],
providers: [clientesService],
})
export class clientes { }
export class clientes {}

View File

@@ -142,9 +142,7 @@ export class clientesService {
);
}
async clearCustomersCache(pattern?: string) {
const cachePattern = pattern || 'clientes:*';
async clearCustomersCache(_pattern?: string) {
// Cache clearing logic would be implemented here
}
}

View File

@@ -87,13 +87,18 @@ export class DataConsultController {
@ApiBearerAuth()
@Get('products/codauxiliar/:codauxiliar')
@ApiOperation({ summary: 'Busca produtos por código auxiliar (EAN)' })
@ApiParam({ name: 'codauxiliar', description: 'Código auxiliar (EAN) do produto' })
@ApiParam({
name: 'codauxiliar',
description: 'Código auxiliar (EAN) do produto',
})
@ApiResponse({
status: 200,
description: 'Lista de produtos encontrados por código auxiliar',
type: [ProductDto],
})
async productsByCodauxiliar(@Param('codauxiliar') codauxiliar: string): Promise<ProductDto[]> {
async productsByCodauxiliar(
@Param('codauxiliar') codauxiliar: string,
): Promise<ProductDto[]> {
return this.dataConsultService.productsByCodauxiliar(codauxiliar);
}

View File

@@ -124,7 +124,10 @@ export class DataConsultRepository {
WHERE PCPRODUT.CODPROD = :0
OR REGEXP_REPLACE(PCPRODUT.CODAUXILIAR, '[^0-9]', '') = :1
`;
const results = await this.executeQuery<ProductDto[]>(sql, [filter, cleanedFilter]);
const results = await this.executeQuery<ProductDto[]>(sql, [
filter,
cleanedFilter,
]);
return results.map((result) => new ProductDto(result));
}

View File

@@ -1,4 +1,10 @@
import { Injectable, HttpException, HttpStatus, Inject, Logger } from '@nestjs/common';
import {
Injectable,
HttpException,
HttpStatus,
Inject,
Logger,
} from '@nestjs/common';
import { DataConsultRepository } from './data-consult.repository';
import { StoreDto } from './dto/store.dto';
import { SellerDto } from './dto/seller.dto';
@@ -231,9 +237,14 @@ export class DataConsultService {
this.logger.log(`Buscando produtos por codauxiliar: ${codauxiliar}`);
try {
if (!codauxiliar || typeof codauxiliar !== 'string') {
throw new HttpException('Código auxiliar inválido', HttpStatus.BAD_REQUEST);
throw new HttpException(
'Código auxiliar inválido',
HttpStatus.BAD_REQUEST,
);
}
const products = await this.repository.findProductsByCodauxiliar(codauxiliar);
const products = await this.repository.findProductsByCodauxiliar(
codauxiliar,
);
return products.map((product) => new ProductDto(product));
} catch (error) {
this.logger.error('Erro ao buscar produtos por codauxiliar', error);