-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-linter-errors.js
More file actions
38 lines (31 loc) · 1.09 KB
/
fix-linter-errors.js
File metadata and controls
38 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Script to fix TypeScript linter errors in server files
*/
const fs = require('fs');
const path = require('path');
// Files that need to be processed
const filesToFix = [
'server/database.ts',
'server/mongo-storage.ts'
];
// Read each file, fix the issues, and write it back
for (const filePath of filesToFix) {
console.log(`Processing ${filePath}...`);
let content = fs.readFileSync(filePath, 'utf8');
// Fix 1: Remove jwt import if present
content = content.replace(/import\s+jwt\s+from\s+['"]jsonwebtoken['"];?/g, '');
// Fix 2: Add type annotations to map callbacks for questions
content = content.replace(
/questions\.map\(async\s+\(question\)\s+=>/g,
'questions.map(async (question: IQuestion) =>'
);
// Fix 3: Add type annotations to map callbacks for answers
content = content.replace(
/answers\.map\(async\s+\(answer\)\s+=>/g,
'answers.map(async (answer: IAnswer) =>'
);
// Write the fixed content back
fs.writeFileSync(filePath, content, 'utf8');
console.log(`Fixed ${filePath}`);
}
console.log('All files processed successfully');