From 64fcb3ad5e4116e46e81ff3cb77cf36516a5decc Mon Sep 17 00:00:00 2001 From: Rolando Bosch Date: Thu, 26 Feb 2026 22:09:03 -0800 Subject: [PATCH 1/2] chore: replace chalk with picocolors and remove rimraf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace chalk (≈44KB) with picocolors (≈3KB) in test utility - Replace rimraf prebuild script with native fs.rmSync (Node >=18) - Net removal of 2 dependencies Co-Authored-By: Claude Opus 4.6 --- package.json | 5 ++--- tests/failOnUnexpectedConsoleCalls.js | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index b768729f..00943151 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "node": ">=18" }, "scripts": { - "prebuild": "rimraf dist", + "prebuild": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"", "build": "npm-run-all --parallel build:main build:bundle:main build:bundle:pure", "build:bundle:main": "dotenv -e .bundle.main.env kcd-scripts build -- --bundle --no-clean --no-ts-defs", "build:bundle:pure": "dotenv -e .bundle.main.env -e .bundle.pure.env kcd-scripts build -- --bundle --no-clean --no-ts-defs", @@ -52,14 +52,13 @@ "@testing-library/jest-dom": "^5.11.6", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", - "chalk": "^4.1.2", "dotenv-cli": "^4.0.0", "jest-diff": "^29.7.0", "kcd-scripts": "^13.0.0", "npm-run-all2": "^6.2.6", + "picocolors": "^1.1.1", "react": "^19.0.0", "react-dom": "^19.0.0", - "rimraf": "^3.0.2", "typescript": "^5.9.3" }, "peerDependencies": { diff --git a/tests/failOnUnexpectedConsoleCalls.js b/tests/failOnUnexpectedConsoleCalls.js index 83e0c641..e9988957 100644 --- a/tests/failOnUnexpectedConsoleCalls.js +++ b/tests/failOnUnexpectedConsoleCalls.js @@ -25,7 +25,7 @@ SOFTWARE. /* eslint-disable prefer-template */ /* eslint-disable func-names */ const util = require('util') -const chalk = require('chalk') +const pc = require('picocolors') const shouldIgnoreConsoleError = require('./shouldIgnoreConsoleError') const patchConsoleMethod = (methodName, unexpectedConsoleCallStacks) => { @@ -69,23 +69,23 @@ const flushUnexpectedConsoleCalls = ( if (unexpectedConsoleCallStacks.length > 0) { const messages = unexpectedConsoleCallStacks.map( ([stack, message]) => - `${chalk.red(message)}\n` + + `${pc.red(message)}\n` + `${stack .split('\n') - .map(line => chalk.gray(line)) + .map(line => pc.gray(line)) .join('\n')}`, ) const message = - `Expected test not to call ${chalk.bold( + `Expected test not to call ${pc.bold( `console.${methodName}()`, )}.\n\n` + 'If the warning is expected, test for it explicitly by:\n' + - `1. Using the ${chalk.bold('.' + expectedMatcher + '()')} ` + + `1. Using the ${pc.bold('.' + expectedMatcher + '()')} ` + `matcher, or...\n` + - `2. Mock it out using ${chalk.bold( + `2. Mock it out using ${pc.bold( 'spyOnDev', - )}(console, '${methodName}') or ${chalk.bold( + )}(console, '${methodName}') or ${pc.bold( 'spyOnProd', )}(console, '${methodName}'), and test that the warning occurs.` From 9b7e6fcf882eb5a7153a67e88c2e839df5b88acb Mon Sep 17 00:00:00 2001 From: Rolando Bosch Date: Thu, 26 Feb 2026 22:38:10 -0800 Subject: [PATCH 2/2] style: fix Prettier formatting Co-Authored-By: Claude Opus 4.6 --- tests/failOnUnexpectedConsoleCalls.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/failOnUnexpectedConsoleCalls.js b/tests/failOnUnexpectedConsoleCalls.js index e9988957..0dca0fd9 100644 --- a/tests/failOnUnexpectedConsoleCalls.js +++ b/tests/failOnUnexpectedConsoleCalls.js @@ -77,9 +77,7 @@ const flushUnexpectedConsoleCalls = ( ) const message = - `Expected test not to call ${pc.bold( - `console.${methodName}()`, - )}.\n\n` + + `Expected test not to call ${pc.bold(`console.${methodName}()`)}.\n\n` + 'If the warning is expected, test for it explicitly by:\n' + `1. Using the ${pc.bold('.' + expectedMatcher + '()')} ` + `matcher, or...\n` +