super-productivity/tools/check-file.js
Johannes Millan 3777672711 fix(test): fix failing dropbox tests and scss lint issues
- Fix dropbox-api.spec.ts tests by mocking fetch on globalThis instead of window
- Fix task-detail-item.component.scss hover states for light/dark themes
- Remove duplicate background property in dark theme mixin
- Update check-file.js to use stylelint for SCSS files
2025-08-05 20:27:02 +02:00

46 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
const { execSync } = require('child_process');
const path = require('path');
const file = process.argv[2];
if (!file) {
console.error('❌ Please provide a file path');
process.exit(1);
}
// Get absolute path
const absolutePath = path.resolve(file);
try {
// Run prettier
console.log(`🎨 Formatting ${path.basename(file)}...`);
execSync(`npm run prettier:file ${absolutePath}`, {
stdio: 'pipe',
encoding: 'utf8',
});
// Run lint based on file type
console.log(`🔍 Linting ${path.basename(file)}...`);
if (file.endsWith('.scss')) {
// Use stylelint for SCSS files
execSync(`npx stylelint ${absolutePath}`, {
stdio: 'pipe',
encoding: 'utf8',
});
} else {
// Use ng lint for TypeScript/JavaScript files
const lintOutput = execSync(`npm run lint:file ${absolutePath}`, {
stdio: 'pipe',
encoding: 'utf8',
});
}
// If we get here, both commands succeeded
console.log(`${path.basename(file)} - All checks passed!`);
} catch (error) {
// If there's an error, show the full output
console.error('\n❌ Errors found:\n');
console.error(error.stdout || error.stderr || error.message);
process.exit(1);
}