From b343dab6bdf1b06d000bcdd1a7abe0d54e06f50d Mon Sep 17 00:00:00 2001 From: Chanakorn Aramsak Date: Sat, 6 Sep 2025 12:39:35 +0700 Subject: [PATCH 1/2] Add Playwright CT CSS fixture and update entry patterns --- .../fixtures/plugins/playwright-ct/playwright/common.css | 3 +++ .../fixtures/plugins/playwright-ct/playwright/index.tsx | 2 +- packages/knip/src/plugins/playwright-ct/index.ts | 6 ++++-- packages/knip/src/plugins/playwright/index.ts | 2 +- packages/knip/test/plugins/playwright-ct.test.ts | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 packages/knip/fixtures/plugins/playwright-ct/playwright/common.css diff --git a/packages/knip/fixtures/plugins/playwright-ct/playwright/common.css b/packages/knip/fixtures/plugins/playwright-ct/playwright/common.css new file mode 100644 index 000000000..6fab1b6a8 --- /dev/null +++ b/packages/knip/fixtures/plugins/playwright-ct/playwright/common.css @@ -0,0 +1,3 @@ +body { + background-color: #f0f0f0; +} \ No newline at end of file diff --git a/packages/knip/fixtures/plugins/playwright-ct/playwright/index.tsx b/packages/knip/fixtures/plugins/playwright-ct/playwright/index.tsx index ac6de14bf..0d2ef3260 100644 --- a/packages/knip/fixtures/plugins/playwright-ct/playwright/index.tsx +++ b/packages/knip/fixtures/plugins/playwright-ct/playwright/index.tsx @@ -1,2 +1,2 @@ // Import styles, initialize component theme here. -// import '../src/common.css'; +import './common.css'; diff --git a/packages/knip/src/plugins/playwright-ct/index.ts b/packages/knip/src/plugins/playwright-ct/index.ts index 39f94573b..8446430c3 100644 --- a/packages/knip/src/plugins/playwright-ct/index.ts +++ b/packages/knip/src/plugins/playwright-ct/index.ts @@ -1,6 +1,6 @@ import type { IsPluginEnabled, Plugin } from '../../types/config.js'; import { hasDependency } from '../../util/plugin.js'; -import { entry, resolveConfig } from '../playwright/index.js'; +import { resolveConfig } from '../playwright/index.js'; // https://playwright.dev/docs/test-components @@ -10,7 +10,9 @@ const enablers = [/^@playwright\/experimental-ct-/]; const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers); -const config = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}']; +const config = ['playwright-ct.config.{js,ts}']; + +const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)', 'playwright/index.{js,ts,jsx,tsx}'] export default { title, diff --git a/packages/knip/src/plugins/playwright/index.ts b/packages/knip/src/plugins/playwright/index.ts index cc2d1049c..a2ffafec8 100644 --- a/packages/knip/src/plugins/playwright/index.ts +++ b/packages/knip/src/plugins/playwright/index.ts @@ -15,7 +15,7 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc const config = ['playwright.config.{js,ts,mjs}']; -export const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)']; +const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)']; const toEntryPatterns = ( testMatch: string | RegExp | Array, diff --git a/packages/knip/test/plugins/playwright-ct.test.ts b/packages/knip/test/plugins/playwright-ct.test.ts index ca067e3dc..e60939f24 100644 --- a/packages/knip/test/plugins/playwright-ct.test.ts +++ b/packages/knip/test/plugins/playwright-ct.test.ts @@ -13,6 +13,7 @@ test('Find dependencies with the Playwright for components plugin', async () => assert.deepEqual(counters, { ...baseCounters, + files: 1, devDependencies: 0, unlisted: 0, processed: 3, From 9c601330911662e3d5069675cf80c0dde3dee1b8 Mon Sep 17 00:00:00 2001 From: Chanakorn Aramsak <85776877+clickCA@users.noreply.github.com> Date: Sat, 6 Sep 2025 12:44:22 +0700 Subject: [PATCH 2/2] Add semicolon Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/knip/src/plugins/playwright-ct/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/knip/src/plugins/playwright-ct/index.ts b/packages/knip/src/plugins/playwright-ct/index.ts index 8446430c3..95b33d4a6 100644 --- a/packages/knip/src/plugins/playwright-ct/index.ts +++ b/packages/knip/src/plugins/playwright-ct/index.ts @@ -12,7 +12,7 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc const config = ['playwright-ct.config.{js,ts}']; -const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)', 'playwright/index.{js,ts,jsx,tsx}'] +const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)', 'playwright/index.{js,ts,jsx,tsx}']; export default { title,