Files
wwjcloud-nest-v1/wwjcloud-nest-v1/tools/fix-comparison-operators.js
wanwu 1fe757c7be fix: 🐛 修复JSONObject重复导出,达到0编译错误
- 删除 common.types.ts 中重复的 JSONObject 定义
- 保留 util.types.ts 中的 JSONObject 类型定义
- 编译结果: 17,816 错误 → 0 错误 
- 所有模块编译通过
2025-10-27 10:38:44 +08:00

76 lines
2.6 KiB
JavaScript

#!/usr/bin/env node
/**
* 修复比较运算符错误
* = == → ===
* = !比 → !==
*/
const fs = require('fs');
const path = require('path');
class ComparisonOperatorFixer {
constructor() {
this.fixedCount = 0;
}
fixFile(filePath) {
let content = fs.readFileSync(filePath, 'utf-8');
const originalContent = content;
// 修复 = == → ===
content = content.replace(/\s+=\s+==\s+/g, ' === ');
// 修复 = != → !==
content = content.replace(/\s+=\s+!=\s+/g, ' !== ');
// 修复 !=== 三等号错误(可能之前的工具引入)
content = content.replace(/!===/g, '!==');
// 修复 ====四等号
content = content.replace(/====/g, '===');
if (content !== originalContent) {
fs.writeFileSync(filePath, content, 'utf-8');
this.fixedCount++;
return true;
}
return false;
}
processDirectory(dir) {
const files = fs.readdirSync(dir);
for (const file of files) {
const fullPath = path.join(dir, file);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
this.processDirectory(fullPath);
} else if (file.endsWith('.service.ts')) {
if (this.fixFile(fullPath)) {
console.log(`${path.basename(fullPath)}`);
}
}
}
}
}
// 主执行
console.log('╔══════════════════════════════════════════════════════════════╗');
console.log('║ 🔧 比较运算符修复工具 ║');
console.log('╚══════════════════════════════════════════════════════════════╝\n');
const fixer = new ComparisonOperatorFixer();
const servicesDir = '/Users/wanwu/Documents/wanwujie/wwjcloud-nsetjs/wwjcloud-nest-v1/wwjcloud/libs/wwjcloud-core/src/services';
console.log('🔄 开始修复...\n');
fixer.processDirectory(servicesDir);
console.log('\n╔══════════════════════════════════════════════════════════════╗');
console.log('║ 📊 修复统计 ║');
console.log('╚══════════════════════════════════════════════════════════════╝');
console.log(`✅ 已修复文件: ${fixer.fixedCount}\n`);