From f6815d593b44086d63f45cfe39dd2d93badacca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Fri, 22 Aug 2025 18:02:36 +0200 Subject: [PATCH] Make 'yarn lint --fix' work as an alias to 'yarn lint-fix'. --- bin/output-fixing-commands.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/output-fixing-commands.js b/bin/output-fixing-commands.js index c6be36c2cc..262437fd81 100644 --- a/bin/output-fixing-commands.js +++ b/bin/output-fixing-commands.js @@ -16,12 +16,20 @@ const fixingCommands = { }; const command = process.argv.slice(2); +const currentScriptName = process.env.npm_lifecycle_event; + +// Redirect the main lint command, but not individual commands. +if (currentScriptName === 'lint' && command.includes('--fix')) { + console.log(`🔧 Detected --fix flag, running: yarn lint-fix`); + const result = cp.spawnSync('yarn', ['lint-fix'], { stdio: 'inherit' }); + process.exitCode = result.status; + process.exit(); +} const result = cp.spawnSync(command[0], command.slice(1), { stdio: 'inherit' }); if (result.status !== 0) { process.exitCode = result.status; - const currentScriptName = process.env.npm_lifecycle_event; if (currentScriptName && currentScriptName in fixingCommands) { console.log( '💡 You might be able to fix the error by running `yarn ' +