Files
element-web/knip.ts
T
Michael Telatynski 7a1a3f518c Make codebase comply to knip --strict (#33893)
* Make codebase comply to `knip --strict`

Deletes a few bits of dead code

* Trim i18n strings

* Fix missing export

* Remove test of dead code
2026-06-18 09:35:47 +00:00

130 lines
4.6 KiB
TypeScript

import { KnipConfig } from "knip";
// Specify this as knip loads config files which may conditionally load plugins
process.env.GITHUB_ACTIONS = "1";
export default {
workspaces: {
"packages/shared-components": {
entry: ["src/index.ts!", "scripts/**"],
project: [
"**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!",
"!scripts/**!",
"!src/test/**!",
"!src/**/test-*!",
"!src/**/*-{mock,mocks,snapshot,actions}.*!",
],
},
"packages/playwright-common": {
entry: ["src/fixtures/index.ts!", "src/testcontainers/index.ts!"],
project: [
"**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!",
"!src/flaky-reporter.ts!",
"!src/stale-screenshot-reporter.ts!",
],
ignoreDependencies: [
// Used in playwright-screenshots.sh
"wait-on",
],
ignoreBinaries: ["awk", "printf"],
},
"packages/module-api": {},
"apps/web": {
entry: [
"src/serviceworker/index.ts!",
"src/workers/*.worker.ts!",
"src/utils/exportUtils/exportJS.js!",
"src/vector/localstorage-fix.ts!",
"scripts/**",
"playwright/**",
"test/**",
"res/decoder-ring/**",
"res/jitsi_external_api.min.js",
"res/themes/*/css/*.pcss",
"I18nWebpackPlugin.ts!",
"module_system/**!",
// Keep for now
"src/hooks/useLocalStorageState.ts!",
"src/hooks/useIsReleaseAnnouncementOpen.ts!",
"src/components/structures/ReleaseAnnouncement.tsx!",
"src/utils/arrays.ts!",
"src/utils/EventPresentationContextProvider.tsx!",
// This is just an awful side-effect import
"src/stores/LifecycleStore.ts!",
],
project: [
"**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!",
"!scripts/**!",
"!src/test/**!",
"!recorder-worklet-loader.cjs!",
],
ignoreDependencies: [
// False positive
"sw.js",
// Used by webpack
"process",
"util",
// Embedded into webapp
"@element-hq/element-call-embedded",
// Used by matrix-js-sdk, which means we have to include them as a
// dependency so that // we can run `tsc` (since we import the typescript
// source of js-sdk, rather than the transpiled and annotated JS like you
// would with a normal library).
"@types/sdp-transform",
],
},
"apps/desktop": {
entry: ["src/preload.cts!", "electron-builder.ts!", "scripts/**", "hak/**"],
project: ["**/*.{js,ts}"],
ignoreDependencies: [
// Brought in via hak scripts
"matrix-seshat",
],
ignoreBinaries: [
"scripts/in-docker.sh",
// Used to build seshat (optional)
"rustc",
// Used by the fetch-package script (optional)
"gpg",
// Used for the macOS universal builds
"lipo",
],
},
"modules": {
project: ["**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!", "!playwright/**!"],
},
"modules/*": {
entry: ["src/index.ts{x,}!"],
project: ["**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!", "!src/tests/**!", "!e2e/**!"],
},
".": {
entry: ["scripts/**", "docs/**"],
},
},
ignoreDependencies: [
// Used by multiple packages, raises a false positive for some reason
"events",
],
ignoreExportsUsedInFile: true,
ignoreBinaries: [
// Optional for coverage:diff development script
"diff-cover",
],
compilers: {
pcss: (text: string) =>
[...text.matchAll(/@import\s+(?:url\()?["']([^"']+)["']\)?[^;]*;/g)]
.map(([, specifier]) => `import "${specifier}";`)
.join("\n"),
},
nx: {
config: ["{nx,package,project}.json", "{apps,packages,modules}/**/{package,project}.json"],
},
playwright: {
config: ["playwright.config.ts", "playwright-merge.config.ts"],
},
tags: ["-knipignore"],
treatConfigHintsAsErrors: true,
treatTagHintsAsErrors: true,
} satisfies KnipConfig;