From 586e5f7289fa134bb2e03e2e207e6347d81313f6 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 6 Apr 2026 15:34:25 +0100 Subject: [PATCH] refactor(lint): guard extension runner coverage --- scripts/lib/run-extension-oxlint.mjs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/lib/run-extension-oxlint.mjs b/scripts/lib/run-extension-oxlint.mjs index 9477d68154a..bce3e54f685 100644 --- a/scripts/lib/run-extension-oxlint.mjs +++ b/scripts/lib/run-extension-oxlint.mjs @@ -55,9 +55,32 @@ function writeTempOxlintConfig(repoRoot, configPath) { delete config.$schema; + if (Array.isArray(config.ignorePatterns)) { + const extensionsIgnorePattern = config.ignorePatterns.find((pattern) => + isTopLevelExtensionsIgnorePattern(pattern), + ); + if (extensionsIgnorePattern) { + throw new Error( + `Refusing to run extension oxlint with .oxlintrc.json ignore pattern ${JSON.stringify( + extensionsIgnorePattern, + )}. Remove the top-level extensions ignore so root and focused lint agree.`, + ); + } + } + fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8"); } +function isTopLevelExtensionsIgnorePattern(pattern) { + const normalized = pattern + .trim() + .replaceAll("\\", "/") + .replaceAll(/^\.?\//g, ""); + return ( + normalized === "extensions" || normalized === "extensions/" || normalized === "extensions/**" + ); +} + function collectTypeScriptFiles(directoryPath) { const entries = fs.readdirSync(directoryPath, { withFileTypes: true }); const files = [];