forked from cardosofelipe/fast-next-template
Refactor useAuth hook, settings components, and docs for formatting and readability improvements
- Consolidated multi-line arguments into single lines where appropriate in `useAuth`. - Improved spacing and readability in data processing across components (`ProfileSettingsForm`, `PasswordChangeForm`, `SessionCard`). - Applied consistent table and markdown formatting in design system docs (e.g., `README.md`, `08-ai-guidelines.md`, `00-quick-start.md`). - Updated code snippets to ensure adherence to Prettier rules and streamlined JSX structures.
This commit is contained in:
@@ -94,7 +94,7 @@ async function convertV8ToIstanbul() {
|
||||
|
||||
// Read all V8 coverage files
|
||||
const files = await fs.readdir(rawDir);
|
||||
const jsonFiles = files.filter(f => f.endsWith('.json'));
|
||||
const jsonFiles = files.filter((f) => f.endsWith('.json'));
|
||||
|
||||
if (jsonFiles.length === 0) {
|
||||
console.log('⚠️ No coverage files found in:', rawDir);
|
||||
@@ -122,10 +122,7 @@ async function convertV8ToIstanbul() {
|
||||
for (const entry of v8Coverage) {
|
||||
try {
|
||||
// Skip non-source files
|
||||
if (
|
||||
!entry.url.startsWith('http://localhost') &&
|
||||
!entry.url.startsWith('file://')
|
||||
) {
|
||||
if (!entry.url.startsWith('http://localhost') && !entry.url.startsWith('file://')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -174,7 +171,6 @@ async function convertV8ToIstanbul() {
|
||||
// Merge into combined coverage
|
||||
Object.assign(istanbulCoverage, converted);
|
||||
totalConverted++;
|
||||
|
||||
} catch (error: any) {
|
||||
console.log(` ⚠️ Skipped ${entry.url}: ${error.message}`);
|
||||
totalSkipped++;
|
||||
@@ -198,7 +194,7 @@ async function convertV8ToIstanbul() {
|
||||
|
||||
if (totalConverted === 0) {
|
||||
console.log('⚠️ No files were converted. Possible reasons:');
|
||||
console.log(' • V8 coverage doesn\'t contain source files from src/');
|
||||
console.log(" • V8 coverage doesn't contain source files from src/");
|
||||
console.log(' • Coverage was collected for build artifacts instead of source');
|
||||
console.log(' • Source maps are not correctly configured\n');
|
||||
console.log('💡 Consider using Istanbul instrumentation instead (see guide)\n');
|
||||
|
||||
@@ -59,11 +59,9 @@ async function mergeCoverage() {
|
||||
const jestCoveragePath = path.join(process.cwd(), 'coverage/coverage-final.json');
|
||||
|
||||
if (fs.existsSync(jestCoveragePath)) {
|
||||
const jestCoverage: CoverageData = JSON.parse(
|
||||
fs.readFileSync(jestCoveragePath, 'utf-8')
|
||||
);
|
||||
const jestCoverage: CoverageData = JSON.parse(fs.readFileSync(jestCoveragePath, 'utf-8'));
|
||||
|
||||
Object.keys(jestCoverage).forEach(file => jestFiles.add(file));
|
||||
Object.keys(jestCoverage).forEach((file) => jestFiles.add(file));
|
||||
stats.jestFiles = jestFiles.size;
|
||||
|
||||
console.log(` ✅ Loaded ${stats.jestFiles} files from Jest coverage`);
|
||||
@@ -78,7 +76,7 @@ async function mergeCoverage() {
|
||||
const e2eDir = path.join(process.cwd(), 'coverage-e2e/.nyc_output');
|
||||
|
||||
if (fs.existsSync(e2eDir)) {
|
||||
const files = fs.readdirSync(e2eDir).filter(f => f.endsWith('.json'));
|
||||
const files = fs.readdirSync(e2eDir).filter((f) => f.endsWith('.json'));
|
||||
|
||||
if (files.length === 0) {
|
||||
console.log(' ⚠️ No E2E coverage files found in:', e2eDir);
|
||||
@@ -89,7 +87,7 @@ async function mergeCoverage() {
|
||||
fs.readFileSync(path.join(e2eDir, file), 'utf-8')
|
||||
);
|
||||
|
||||
Object.keys(coverage).forEach(f => e2eFiles.add(f));
|
||||
Object.keys(coverage).forEach((f) => e2eFiles.add(f));
|
||||
map.merge(coverage);
|
||||
console.log(` ✅ Loaded E2E coverage from: ${file}`);
|
||||
}
|
||||
@@ -104,7 +102,7 @@ async function mergeCoverage() {
|
||||
// Step 3: Calculate statistics
|
||||
stats.combinedFiles = map.files().length;
|
||||
|
||||
map.files().forEach(file => {
|
||||
map.files().forEach((file) => {
|
||||
const inJest = jestFiles.has(file);
|
||||
const inE2E = e2eFiles.has(file);
|
||||
|
||||
@@ -146,10 +144,18 @@ async function mergeCoverage() {
|
||||
console.log('\n' + '='.repeat(70));
|
||||
console.log('📊 COMBINED COVERAGE SUMMARY');
|
||||
console.log('='.repeat(70));
|
||||
console.log(`\n Statements: ${summary.statements.pct.toFixed(2)}% (${summary.statements.covered}/${summary.statements.total})`);
|
||||
console.log(` Branches: ${summary.branches.pct.toFixed(2)}% (${summary.branches.covered}/${summary.branches.total})`);
|
||||
console.log(` Functions: ${summary.functions.pct.toFixed(2)}% (${summary.functions.covered}/${summary.functions.total})`);
|
||||
console.log(` Lines: ${summary.lines.pct.toFixed(2)}% (${summary.lines.covered}/${summary.lines.total})`);
|
||||
console.log(
|
||||
`\n Statements: ${summary.statements.pct.toFixed(2)}% (${summary.statements.covered}/${summary.statements.total})`
|
||||
);
|
||||
console.log(
|
||||
` Branches: ${summary.branches.pct.toFixed(2)}% (${summary.branches.covered}/${summary.branches.total})`
|
||||
);
|
||||
console.log(
|
||||
` Functions: ${summary.functions.pct.toFixed(2)}% (${summary.functions.covered}/${summary.functions.total})`
|
||||
);
|
||||
console.log(
|
||||
` Lines: ${summary.lines.pct.toFixed(2)}% (${summary.lines.covered}/${summary.lines.total})`
|
||||
);
|
||||
|
||||
console.log('\n' + '-'.repeat(70));
|
||||
console.log('📁 FILE COVERAGE BREAKDOWN');
|
||||
@@ -162,10 +168,12 @@ async function mergeCoverage() {
|
||||
// Show E2E-only files (these were excluded from Jest)
|
||||
if (stats.e2eOnlyFiles.length > 0) {
|
||||
console.log('\n 📋 Files covered ONLY by E2E tests (excluded from unit tests):');
|
||||
stats.e2eOnlyFiles.slice(0, 10).forEach(file => {
|
||||
stats.e2eOnlyFiles.slice(0, 10).forEach((file) => {
|
||||
const fileCoverage = map.fileCoverageFor(file);
|
||||
const fileSummary = fileCoverage.toSummary();
|
||||
console.log(` • ${path.relative(process.cwd(), file)} (${fileSummary.statements.pct.toFixed(1)}%)`);
|
||||
console.log(
|
||||
` • ${path.relative(process.cwd(), file)} (${fileSummary.statements.pct.toFixed(1)}%)`
|
||||
);
|
||||
});
|
||||
if (stats.e2eOnlyFiles.length > 10) {
|
||||
console.log(` ... and ${stats.e2eOnlyFiles.length - 10} more`);
|
||||
@@ -190,7 +198,9 @@ async function mergeCoverage() {
|
||||
const actual = (summary as any)[metric].pct;
|
||||
const passed = actual >= threshold;
|
||||
const icon = passed ? '✅' : '❌';
|
||||
console.log(` ${icon} ${metric.padEnd(12)}: ${actual.toFixed(2)}% (threshold: ${threshold}%)`);
|
||||
console.log(
|
||||
` ${icon} ${metric.padEnd(12)}: ${actual.toFixed(2)}% (threshold: ${threshold}%)`
|
||||
);
|
||||
if (!passed) thresholdsFailed = true;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user