From a953439f08913ec1f0846979c285900637f20d50 Mon Sep 17 00:00:00 2001 From: Keimpe de Jong Date: Thu, 30 Oct 2025 08:27:08 +0000 Subject: [PATCH] Fix code quality issues from Copilot review - Remove duplicated code block (lines 292-304) in check-md-conformance.js - Remove unused variable fenceStartLine in check-md-conformance.js - Remove unused variable hasLanguage in fix-fence-languages.js - Rename fixOpenTicks to fixOpenLine to store full original line --- tools/markdown/check-md-conformance.js | 16 ---------------- tools/markdown/fix-fence-languages.js | 9 ++++----- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/tools/markdown/check-md-conformance.js b/tools/markdown/check-md-conformance.js index 008e5256..859689de 100644 --- a/tools/markdown/check-md-conformance.js +++ b/tools/markdown/check-md-conformance.js @@ -80,7 +80,6 @@ function checkFile(filePath) { const violations = []; let inFence = false; - let fenceStartLine = -1; // Pass 1: fence tracking to avoid interpreting list/table inside code blocks const excluded = Array.from({ length: lines.length }).fill(false); @@ -89,10 +88,8 @@ function checkFile(filePath) { if (inFence) { // closing fence inFence = false; - fenceStartLine = -1; } else { inFence = true; - fenceStartLine = i; } excluded[i] = true; continue; @@ -289,16 +286,3 @@ if (require.main === module) { } module.exports = { checkFile }; -{ - console.log(`\n- ${path.relative(process.cwd(), file)}`); - for (const v of violations) { - console.log(` L${v.line.toString().padStart(4, ' ')} ${v.type} ${v.message}`); - } - process.exit(1); -} - -if (require.main === module) { - main(); -} - -module.exports = { checkFile }; diff --git a/tools/markdown/fix-fence-languages.js b/tools/markdown/fix-fence-languages.js index a9454198..01e09b44 100644 --- a/tools/markdown/fix-fence-languages.js +++ b/tools/markdown/fix-fence-languages.js @@ -95,7 +95,7 @@ function fixFile(filePath) { let fixing = false; let fixFenceStart = -1; let fixOpenIndent = ''; - let fixOpenTicks = ''; + let fixOpenLine = ''; let fixOpenLen = 0; let fenceContent = []; @@ -117,7 +117,7 @@ function fixFile(filePath) { fixes.push({ line: fixFenceStart + 1, - original: fixOpenTicks, + original: fixOpenLine, fixed: fixedOpenLine, detectedLanguage: language, contentPreview: fenceContent.slice(0, 2).join('\n').slice(0, 60) + '...', @@ -127,7 +127,7 @@ function fixFile(filePath) { fixing = false; fixFenceStart = -1; fixOpenIndent = ''; - fixOpenTicks = ''; + fixOpenLine = ''; fixOpenLen = 0; fenceContent = []; continue; @@ -146,7 +146,6 @@ function fixFile(filePath) { const ticksLen = ticks.length; const rest = fenceLineMatch[3] || ''; const restTrim = rest.trim(); - const hasLanguage = restTrim.length > 0; // simplistic but effective for our cases // Determine if this is a closing fence for the current outer fence if (fenceStack.length > 0) { @@ -173,7 +172,7 @@ function fixFile(filePath) { fixing = true; fixFenceStart = i; fixOpenIndent = indent; - fixOpenTicks = ticks; + fixOpenLine = line; fixOpenLen = ticksLen; fenceContent = []; // Do not push the original opening line; we'll emit the fixed one at close