Fix linter warnings for no-sync rule

- Convert async file operations in awsCredentialProvider.js to use fs.promises
- Add eslint-disable comments for necessary sync operations during initialization
- Fix warnings in logger.js, secureCredentials.js, and test files
- All 21 linter warnings resolved

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jonathan Flatt
2025-05-26 01:17:55 +00:00
parent b0e5d01f6e
commit 59a7a975be
5 changed files with 14 additions and 3 deletions

View File

@@ -150,7 +150,7 @@ class AWSCredentialProvider {
* Get credentials from AWS profile
*/
async getProfileCredentials(profileName) {
const fs = require('fs');
const fs = require('fs').promises;
const path = require('path');
const os = require('os');
@@ -159,8 +159,8 @@ class AWSCredentialProvider {
try {
// Read credentials file
const credentialsContent = fs.readFileSync(credentialsPath, 'utf8');
const configContent = fs.readFileSync(configPath, 'utf8');
const credentialsContent = await fs.readFile(credentialsPath, 'utf8');
const configContent = await fs.readFile(configPath, 'utf8');
// Parse credentials for the specific profile
const profileRegex = new RegExp(`\\[${profileName}\\]([^\\[]*)`);

View File

@@ -6,7 +6,9 @@ const path = require('path');
// Use home directory for logs to avoid permission issues
const homeDir = process.env.HOME || '/tmp';
const logsDir = path.join(homeDir, '.claude-webhook', 'logs');
// eslint-disable-next-line no-sync
if (!fs.existsSync(logsDir)) {
// eslint-disable-next-line no-sync
fs.mkdirSync(logsDir, { recursive: true });
}
@@ -111,17 +113,22 @@ if (isProduction) {
// Check log file size and rotate if necessary
try {
const maxSize = 10 * 1024 * 1024; // 10MB
// eslint-disable-next-line no-sync
if (fs.existsSync(logFileName)) {
// eslint-disable-next-line no-sync
const stats = fs.statSync(logFileName);
if (stats.size > maxSize) {
// Simple rotation - keep up to 5 backup files
for (let i = 4; i >= 0; i--) {
const oldFile = `${logFileName}.${i}`;
const newFile = `${logFileName}.${i + 1}`;
// eslint-disable-next-line no-sync
if (fs.existsSync(oldFile)) {
// eslint-disable-next-line no-sync
fs.renameSync(oldFile, newFile);
}
}
// eslint-disable-next-line no-sync
fs.renameSync(logFileName, `${logFileName}.0`);
logger.info('Log file rotated');

View File

@@ -35,7 +35,9 @@ class SecureCredentials {
// Try to read from file first (most secure)
try {
// eslint-disable-next-line no-sync
if (fs.existsSync(config.file)) {
// eslint-disable-next-line no-sync
value = fs.readFileSync(config.file, 'utf8').trim();
logger.info(`Loaded ${key} from secure file: ${config.file}`);
}

View File

@@ -6,6 +6,7 @@ const payloadPath = process.argv[2] || './test-payload.json';
const webhookUrl = process.argv[3] || 'http://localhost:3001/api/webhooks/github';
// Read the payload file
// eslint-disable-next-line no-sync
const payload = fs.readFileSync(payloadPath, 'utf8');
// Calculate the signature using the utility

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-sync */
const fs = require('fs');
// Mock dependencies