fix: replace require() with ES6 imports for fs and path
All checks were successful
CI/CD Pipeline / Backend - Build, Test & Push (push) Successful in 7m10s
CI/CD Pipeline / Frontend - Build, Test & Push (push) Successful in 11m27s
CI/CD Pipeline / Integration Tests (push) Has been skipped
CI/CD Pipeline / Deployment Summary (push) Successful in 1s
CI/CD Pipeline / Discord Notification (Failure) (push) Has been skipped
CI/CD Pipeline / Discord Notification (Success) (push) Successful in 2s

- Add fs and path imports at top of file
- Remove inline require() statements that violated ESLint rules
- Fixes 6 @typescript-eslint/no-var-requires errors
This commit is contained in:
David 2025-11-17 23:26:22 +01:00
parent 435d587501
commit f9b1625e20

View File

@ -40,6 +40,8 @@ import {
import { CsvRateMapper } from '../../mappers/csv-rate.mapper'; import { CsvRateMapper } from '../../mappers/csv-rate.mapper';
import { S3StorageAdapter } from '@infrastructure/storage/s3-storage.adapter'; import { S3StorageAdapter } from '@infrastructure/storage/s3-storage.adapter';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import * as fs from 'fs';
import * as path from 'path';
/** /**
* CSV Rates Admin Controller * CSV Rates Admin Controller
@ -187,8 +189,6 @@ export class CsvRatesAdminController {
this.logger.log(`Successfully parsed ${ratesCount} rates from ${file.filename}`); this.logger.log(`Successfully parsed ${ratesCount} rates from ${file.filename}`);
// Rename file to final name (company-name.csv) // Rename file to final name (company-name.csv)
const fs = require('fs');
const path = require('path');
const finalPath = path.join(path.dirname(filePathToValidate), finalFilename); const finalPath = path.join(path.dirname(filePathToValidate), finalFilename);
// Delete old file if exists // Delete old file if exists
@ -439,8 +439,6 @@ export class CsvRatesAdminController {
this.logger.log('Fetching all CSV files (frontend compatibility)'); this.logger.log('Fetching all CSV files (frontend compatibility)');
const configs = await this.csvConfigRepository.findAll(); const configs = await this.csvConfigRepository.findAll();
const fs = require('fs');
const path = require('path');
// Map configs to file info format expected by frontend // Map configs to file info format expected by frontend
const files = configs.map((config) => { const files = configs.map((config) => {
@ -509,8 +507,6 @@ export class CsvRatesAdminController {
} }
// Delete the file from filesystem // Delete the file from filesystem
const fs = require('fs');
const path = require('path');
const filePath = path.join( const filePath = path.join(
process.cwd(), process.cwd(),
'apps/backend/src/infrastructure/storage/csv-storage/rates', 'apps/backend/src/infrastructure/storage/csv-storage/rates',