From 16dfff7712c81dedc8e8ed049feb2a6092ee09f3 Mon Sep 17 00:00:00 2001 From: Hanna Date: Wed, 26 Nov 2025 13:56:34 -0800 Subject: [PATCH] =?UTF-8?q?Replace=20Chalk=20with=20Colorette;=20fix=20to-?= =?UTF-8?q?have-style=20to=20use=20named=20red=20import=20##=20Details:=20?= =?UTF-8?q?-=20Removed=20malicious=20dependency=20chalk=20due=20to=20secur?= =?UTF-8?q?ity=20concerns.=20-=20Switched=20to=20colorette=20and=20updated?= =?UTF-8?q?=20to-have-style=20to=20import=20red=20as=20a=20named=20export.?= =?UTF-8?q?=20-=20Adjusted=20expectedDiff=20to=20strip=20the=20=E2=80=9C+?= =?UTF-8?q?=20Received=E2=80=9D=20annotation=20using=20red('+=20Received')?= =?UTF-8?q?.=20##=20Security:=20-=20Chalk=20removal=20mitigates=20risk=20f?= =?UTF-8?q?rom=20supply-chain=20compromise.=20Consider=20auditing=20the=20?= =?UTF-8?q?lockfile=20and=20running=20npm=20audit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/to-have-style.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 93294d6..0b4af60 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "react-native" ], "dependencies": { - "chalk": "^4.1.2", + "colorette": "^2.0.20", "jest-diff": "^29.0.1", "jest-matcher-utils": "^29.0.1", "pretty-format": "^29.0.3", diff --git a/src/to-have-style.ts b/src/to-have-style.ts index 38b3e10..c781195 100644 --- a/src/to-have-style.ts +++ b/src/to-have-style.ts @@ -3,7 +3,7 @@ import type { ReactTestInstance } from 'react-test-renderer'; import { StyleSheet } from 'react-native'; import { matcherHint } from 'jest-matcher-utils'; import { diff } from 'jest-diff'; -import chalk from 'chalk'; +import { red } from 'colorette'; import { checkReactElement } from './utils'; type Style = TextStyle | ViewStyle | ImageStyle; @@ -42,7 +42,7 @@ function expectedDiff(expected: StyleLike, received: StyleLike) { const diffOutput = diff(printoutStyles(expected), printoutStyles(receivedNarrow)); // Remove the "+ Received" annotation because this is a one-way diff - return diffOutput?.replace(`${chalk.red('+ Received')}\n`, '') ?? ''; + return diffOutput?.replace(`${red('+ Received')}\n`, '') ?? ''; } export function toHaveStyle(