From 4e12d0d97f1a7046d8ea206422ac6256404dcf43 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 14 May 2026 15:07:01 -0400 Subject: [PATCH 1/2] Automated Testing: Allow console logging in all bin, scripts, tools files --- packages/babel-preset-default/bin/index.js | 1 - .../bin/extract-files-from-sourcemap.js | 7 ------- .../react-native-editor/bin/extract-used-strings.js | 1 - .../bin/i18n-translations-download.js | 9 +++------ .../scripts/config/jest-environment-puppeteer/index.js | 2 -- .../config/jest-github-actions-reporter/index.js | 1 - packages/scripts/scripts/lint-js.js | 1 - packages/scripts/scripts/packages-update.js | 2 -- packages/scripts/scripts/test-playwright.js | 1 - packages/scripts/utils/cli.js | 4 ---- tools/api-docs/gen-components-docs/index.mjs | 1 - tools/api-docs/gen-theme-reference.mjs | 1 - tools/api-docs/update-api-docs.js | 1 - tools/eslint/config.mjs | 10 +--------- 14 files changed, 4 insertions(+), 38 deletions(-) diff --git a/packages/babel-preset-default/bin/index.js b/packages/babel-preset-default/bin/index.js index 041ab0143a5ae4..d9dfd7aae5c44a 100755 --- a/packages/babel-preset-default/bin/index.js +++ b/packages/babel-preset-default/bin/index.js @@ -29,7 +29,6 @@ builder( { ) .then( ( output ) => writeFile( './build/polyfill.min.js', output.code ) ) .catch( ( error ) => { - // eslint-disable-next-line no-console console.log( error ); process.exit( 1 ); } ); diff --git a/packages/react-native-editor/bin/extract-files-from-sourcemap.js b/packages/react-native-editor/bin/extract-files-from-sourcemap.js index 6f755f567c098d..1eb8dda5cd29e1 100755 --- a/packages/react-native-editor/bin/extract-files-from-sourcemap.js +++ b/packages/react-native-editor/bin/extract-files-from-sourcemap.js @@ -29,26 +29,22 @@ if ( require.main === module ) { // Validate arguments if ( ! mapFile ) { - // eslint-disable-next-line no-console console.error( `Map file argument is required.` ); process.exit( 1 ); } if ( ! targetDir ) { - // eslint-disable-next-line no-console console.error( `Target directory argument is required.` ); process.exit( 1 ); } try { fs.accessSync( mapFile ); } catch { - // eslint-disable-next-line no-console console.error( `Map file "${ mapFile } doesn't exist.` ); process.exit( 1 ); } try { fs.accessSync( targetDir ); } catch { - // eslint-disable-next-line no-console console.error( `Target directory "${ targetDir }"" doesn't exist.` ); process.exit( 1 ); } @@ -88,14 +84,12 @@ if ( require.main === module ) { try { fs.accessSync( compiledFile ); } catch { - // eslint-disable-next-line no-console console.warn( `Couldn't find matching build file for Typescript file "${ compiledFile }".` ); return file; } - // eslint-disable-next-line no-console console.log( `Using compiled file "${ compiledFile }" for Typescript file "${ file }"` ); @@ -110,7 +104,6 @@ if ( require.main === module ) { copyFileToDir( sourceFile, targetDir ) ); } catch ( error ) { - // eslint-disable-next-line no-console console.error( `Something went wrong when copying source files to "${ targetDir }":`, error diff --git a/packages/react-native-editor/bin/extract-used-strings.js b/packages/react-native-editor/bin/extract-used-strings.js index 798cda36f7a4ba..5620ff93fd5d05 100755 --- a/packages/react-native-editor/bin/extract-used-strings.js +++ b/packages/react-native-editor/bin/extract-used-strings.js @@ -143,7 +143,6 @@ const generatePotFiles = ( plugins, potFilesDir ) => { } ); } catch ( error ) { - // eslint-disable-next-line no-console console.error( error ); process.exit( 1 ); } diff --git a/packages/react-native-editor/bin/i18n-translations-download.js b/packages/react-native-editor/bin/i18n-translations-download.js index 24911a3ed64b3a..66e3b6b8738247 100644 --- a/packages/react-native-editor/bin/i18n-translations-download.js +++ b/packages/react-native-editor/bin/i18n-translations-download.js @@ -1,5 +1,4 @@ #!/usr/bin/env node -/* eslint-disable no-console */ /** * External dependencies @@ -243,7 +242,7 @@ const getUsedStrings = ( usedStringsFile, domain ) => { const generateIndexFile = ( translations, pluginDir ) => { const indexNative = `/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ /* eslint-disable prettier/prettier */ - + const translations = { ${ translations .filter( Boolean ) @@ -253,9 +252,9 @@ const generateIndexFile = ( translations, pluginDir ) => { ) .join( '\n' ) } }; - + export const getTranslation = ( locale ) => translations[ locale ]; - + /* eslint-enable prettier/prettier */ `; @@ -312,5 +311,3 @@ if ( require.main === module ) { generateIndexFile( translations, pluginDir ); } ); } - -/* eslint-enable no-console */ diff --git a/packages/scripts/config/jest-environment-puppeteer/index.js b/packages/scripts/config/jest-environment-puppeteer/index.js index 9e903ab498e1df..89d4afbd62b0bd 100644 --- a/packages/scripts/config/jest-environment-puppeteer/index.js +++ b/packages/scripts/config/jest-environment-puppeteer/index.js @@ -32,7 +32,6 @@ const handleError = ( error ) => { // https://github.com/facebook/jest/blob/1be8d737abd0e2f30e3314184a0efc372ad6d88f/packages/jest-jasmine2/src/jasmine/Env.ts#L250-L251 // Emitting an uncaughtException event to the process will throw an // empty error which is very hard to debug in puppeteer context. - // eslint-disable-next-line no-console console.error( error ); }; @@ -70,7 +69,6 @@ class PuppeteerEnvironment extends NodeEnvironment { // eslint-disable-next-line no-debugger debugger; } ); - // eslint-disable-next-line no-console console.log( chalk.blue( '\n\nšŸ•µļøā€ Code is paused, press enter to resume' diff --git a/packages/scripts/config/jest-github-actions-reporter/index.js b/packages/scripts/config/jest-github-actions-reporter/index.js index 8496373c38971f..0f90d368e0aca9 100644 --- a/packages/scripts/config/jest-github-actions-reporter/index.js +++ b/packages/scripts/config/jest-github-actions-reporter/index.js @@ -28,7 +28,6 @@ class GithubActionsReporter { const messages = getMessages( _aggregatedResults.testResults ); for ( const message of messages ) { - // eslint-disable-next-line no-console console.log( message ); } } diff --git a/packages/scripts/scripts/lint-js.js b/packages/scripts/scripts/lint-js.js index afe5603a6d37ca..79623fcd5affa7 100644 --- a/packages/scripts/scripts/lint-js.js +++ b/packages/scripts/scripts/lint-js.js @@ -43,7 +43,6 @@ if ( ! hasLintConfig ) { ]; const hasLegacyConfig = legacyConfigFiles.some( hasProjectFile ); if ( hasLegacyConfig ) { - // eslint-disable-next-line no-console console.warn( 'Warning: Legacy eslintrc configuration detected. ' + 'ESLint v10 no longer supports eslintrc files. ' + diff --git a/packages/scripts/scripts/packages-update.js b/packages/scripts/scripts/packages-update.js index fee287a24de292..9a412d9d6211b7 100644 --- a/packages/scripts/scripts/packages-update.js +++ b/packages/scripts/scripts/packages-update.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ /** * External dependencies */ @@ -82,4 +81,3 @@ function updatePackageJSON() { } updatePackageJSON(); -/* eslint-enable no-console */ diff --git a/packages/scripts/scripts/test-playwright.js b/packages/scripts/scripts/test-playwright.js index 27934f0f7ec144..46cb73d12bb39a 100644 --- a/packages/scripts/scripts/test-playwright.js +++ b/packages/scripts/scripts/test-playwright.js @@ -41,7 +41,6 @@ try { // First, try to load the package installed from among the optional peerDependencies. loadConfig = require( '@wordpress/env/lib/config' ).loadConfig; } catch { - // eslint-disable-next-line no-console console.log( 'Notice: Could not find @wordpress/env package. Using WP_BASE_URL environment variable or else the default http://localhost:8889 URL for tests.' ); diff --git a/packages/scripts/utils/cli.js b/packages/scripts/utils/cli.js index 5f889e7543fa91..da7bbcd39ca3d0 100644 --- a/packages/scripts/utils/cli.js +++ b/packages/scripts/utils/cli.js @@ -38,14 +38,12 @@ const hasFileArgInCLI = () => getFileArgsFromCLI().length > 0; const handleSignal = ( signal ) => { if ( signal === 'SIGKILL' ) { - // eslint-disable-next-line no-console console.log( 'The script failed because the process exited too early. ' + 'This probably means the system ran out of memory or someone called ' + '`kill -9` on the process.' ); } else if ( signal === 'SIGTERM' ) { - // eslint-disable-next-line no-console console.log( 'The script failed because the process exited too early. ' + 'Someone might have called `kill` or `killall`, or the system could ' + @@ -57,13 +55,11 @@ const handleSignal = ( signal ) => { const spawnScript = ( scriptName, args = [], nodeArgs = [] ) => { if ( ! scriptName ) { - // eslint-disable-next-line no-console console.log( 'Script name is missing.' ); exit( 1 ); } if ( ! hasScriptFile( scriptName ) ) { - // eslint-disable-next-line no-console console.log( 'Unknown script "' + scriptName + diff --git a/tools/api-docs/gen-components-docs/index.mjs b/tools/api-docs/gen-components-docs/index.mjs index c84903bec656c2..81e33c5d11938f 100644 --- a/tools/api-docs/gen-components-docs/index.mjs +++ b/tools/api-docs/gen-components-docs/index.mjs @@ -142,7 +142,6 @@ await Promise.all( ); try { - // eslint-disable-next-line no-console console.log( `Writing docs to ${ outputFile }` ); return fs.writeFile( outputFile, docs ); } catch ( e ) { diff --git a/tools/api-docs/gen-theme-reference.mjs b/tools/api-docs/gen-theme-reference.mjs index c3e57b663988fb..f50d194c17ee79 100644 --- a/tools/api-docs/gen-theme-reference.mjs +++ b/tools/api-docs/gen-theme-reference.mjs @@ -290,7 +290,6 @@ async function main() { } main().catch( ( error ) => { - // eslint-disable-next-line no-console console.error( error ); process.exit( 1 ); } ); diff --git a/tools/api-docs/update-api-docs.js b/tools/api-docs/update-api-docs.js index 891cff657c4b70..d7b162f69194b2 100755 --- a/tools/api-docs/update-api-docs.js +++ b/tools/api-docs/update-api-docs.js @@ -246,7 +246,6 @@ glob.stream( [ cwd: ROOT_DIR, } ); } catch ( error ) { - // eslint-disable-next-line no-console console.error( error ); process.exit( 1 ); } diff --git a/tools/eslint/config.mjs b/tools/eslint/config.mjs index 688aba47dc0d2c..134265d8506ea3 100644 --- a/tools/eslint/config.mjs +++ b/tools/eslint/config.mjs @@ -564,15 +564,7 @@ export default dedupePlugins( [ // Override: CLI/bin/env files — allow console. { - files: [ - 'bin/**/*.js', - 'bin/**/*.mjs', - 'tools/**/*.js', - 'tools/**/*.mjs', - 'tools/**/*.cjs', - 'packages/env/**', - 'packages/theme/bin/**/*.[tj]s?(x)', - ], + files: [ '**/{bin,scripts,tools}/**', 'packages/env/**' ], rules: { 'no-console': 'off', }, From 10e53e2a3403af96f9b08a0109dbbc0f89055037 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 14 May 2026 16:26:05 -0400 Subject: [PATCH 2/2] Restore no-console disabling in scripts package Scripts package doesn't currently respect project-level ESLint configuration. See: https://github.com/WordPress/gutenberg/pull/78312#issuecomment-4454411723 --- packages/scripts/config/jest-environment-puppeteer/index.js | 2 ++ packages/scripts/config/jest-github-actions-reporter/index.js | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/scripts/config/jest-environment-puppeteer/index.js b/packages/scripts/config/jest-environment-puppeteer/index.js index 89d4afbd62b0bd..9e903ab498e1df 100644 --- a/packages/scripts/config/jest-environment-puppeteer/index.js +++ b/packages/scripts/config/jest-environment-puppeteer/index.js @@ -32,6 +32,7 @@ const handleError = ( error ) => { // https://github.com/facebook/jest/blob/1be8d737abd0e2f30e3314184a0efc372ad6d88f/packages/jest-jasmine2/src/jasmine/Env.ts#L250-L251 // Emitting an uncaughtException event to the process will throw an // empty error which is very hard to debug in puppeteer context. + // eslint-disable-next-line no-console console.error( error ); }; @@ -69,6 +70,7 @@ class PuppeteerEnvironment extends NodeEnvironment { // eslint-disable-next-line no-debugger debugger; } ); + // eslint-disable-next-line no-console console.log( chalk.blue( '\n\nšŸ•µļøā€ Code is paused, press enter to resume' diff --git a/packages/scripts/config/jest-github-actions-reporter/index.js b/packages/scripts/config/jest-github-actions-reporter/index.js index 0f90d368e0aca9..8496373c38971f 100644 --- a/packages/scripts/config/jest-github-actions-reporter/index.js +++ b/packages/scripts/config/jest-github-actions-reporter/index.js @@ -28,6 +28,7 @@ class GithubActionsReporter { const messages = getMessages( _aggregatedResults.testResults ); for ( const message of messages ) { + // eslint-disable-next-line no-console console.log( message ); } }