From e133289a7fef85cdfab94c4a12ef4a4279c1c479 Mon Sep 17 00:00:00 2001 From: Timo K Date: Mon, 4 Aug 2025 18:50:57 +0200 Subject: [PATCH 1/4] Make convert remaining js config files to ts Co-authored-by: hughns Signed-off-by: Timo K --- i18next-parser.config.ts | 12 +++++++++- ...edded.config.js => vite-embedded.config.ts | 10 +++++++- vite.config.js => vite.config.ts | 23 +++++++++++++------ vitest.config.js => vitest.config.ts | 9 +++++++- 4 files changed, 44 insertions(+), 10 deletions(-) rename vite-embedded.config.js => vite-embedded.config.ts (84%) rename vite.config.js => vite.config.ts (90%) rename vitest.config.js => vitest.config.ts (81%) diff --git a/i18next-parser.config.ts b/i18next-parser.config.ts index 3acf2b5e..e07021ae 100644 --- a/i18next-parser.config.ts +++ b/i18next-parser.config.ts @@ -1,4 +1,12 @@ -export default { +/* +Copyright 2024 New Vector Ltd. +SPDX-License-Identifier: AGPL-3.0-only +Please see LICENSE in the repository root for full details. +*/ + +import type { UserConfig } from "i18next-parser"; + +const config: UserConfig = { keySeparator: ".", namespaceSeparator: false, contextSeparator: "|", @@ -26,3 +34,5 @@ export default { input: ["src/**/*.{ts,tsx}"], sort: true, }; + +export default config; diff --git a/vite-embedded.config.js b/vite-embedded.config.ts similarity index 84% rename from vite-embedded.config.js rename to vite-embedded.config.ts index 8f5bcba8..27a42fbb 100644 --- a/vite-embedded.config.js +++ b/vite-embedded.config.ts @@ -1,7 +1,15 @@ +/* +Copyright 2025 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE in the repository root for full details. +*/ + import { defineConfig, mergeConfig } from "vite"; -import fullConfig from "./vite.config"; import generateFile from "vite-plugin-generate-file"; +import fullConfig from "./vite.config"; + const base = "./"; // Config for embedded deployments (possibly hosted under a non-root path) diff --git a/vite.config.js b/vite.config.ts similarity index 90% rename from vite.config.js rename to vite.config.ts index 5fe3a99b..115565bb 100644 --- a/vite.config.js +++ b/vite.config.ts @@ -5,7 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ -import { defineConfig, loadEnv, searchForWorkspaceRoot } from "vite"; +import { + loadEnv, + searchForWorkspaceRoot, + type ConfigEnv, + type UserConfig, +} from "vite"; import svgrPlugin from "vite-plugin-svgr"; import { createHtmlPlugin } from "vite-plugin-html"; import { codecovVitePlugin } from "@codecov/vite-plugin"; @@ -13,12 +18,16 @@ import { sentryVitePlugin } from "@sentry/vite-plugin"; import react from "@vitejs/plugin-react"; import { realpathSync } from "fs"; import * as fs from "node:fs"; - +import { logger } from "matrix-js-sdk/lib/logger"; // https://vitejs.dev/config/ -export default defineConfig(({ mode, packageType }) => { +// Modified type helper from defineConfig to allow for packageType (see defineConfig from vite) +export default ({ + mode, + packageType, +}: ConfigEnv & { packageType?: "full" | "embedded" }): UserConfig => { const env = loadEnv(mode, process.cwd()); // Environment variables with the VITE_ prefix are accessible at runtime. - // So, we set this to allow for build/package specific behaviour. + // So, we set this to allow for build/package specific behavior. // In future we might be able to do what is needed via code splitting at // build time. process.env.VITE_PACKAGE = packageType ?? "full"; @@ -77,7 +86,7 @@ export default defineConfig(({ mode, packageType }) => { allow.push(realpathSync(path)); } catch {} } - console.log("Allowed vite paths:", allow); + logger.log("Allowed vite paths:", allow); return { server: { @@ -93,7 +102,7 @@ export default defineConfig(({ mode, packageType }) => { sourcemap: true, rollupOptions: { output: { - assetFileNames: ({ originalFileNames }) => { + assetFileNames: ({ originalFileNames }): string => { if (originalFileNames) { for (const name of originalFileNames) { // Custom asset name for locales to include the locale code in the filename @@ -143,4 +152,4 @@ export default defineConfig(({ mode, packageType }) => { exclude: ["@matrix-org/matrix-sdk-crypto-wasm"], }, }; -}); +}; diff --git a/vitest.config.js b/vitest.config.ts similarity index 81% rename from vitest.config.js rename to vitest.config.ts index a6c3107f..ff8947b0 100644 --- a/vitest.config.js +++ b/vitest.config.ts @@ -1,5 +1,12 @@ +/* +Copyright 2024 New Vector Ltd. +SPDX-License-Identifier: AGPL-3.0-only +Please see LICENSE in the repository root for full details. +*/ + import { defineConfig, mergeConfig } from "vitest/config"; -import viteConfig from "./vite.config.js"; + +import viteConfig from "./vite.config"; export default defineConfig((configEnv) => mergeConfig( From 02f9d0822fdc497107df77ee6e333a8847ff6e35 Mon Sep 17 00:00:00 2001 From: Timo K Date: Tue, 5 Aug 2025 09:17:50 +0200 Subject: [PATCH 2/4] update knip.ts Signed-off-by: Timo K --- knip.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/knip.ts b/knip.ts index 2381356c..6b378e29 100644 --- a/knip.ts +++ b/knip.ts @@ -1,8 +1,15 @@ -import { KnipConfig } from "knip"; +/* +Copyright 2025 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE in the repository root for full details. +*/ + +import { type KnipConfig } from "knip"; export default { vite: { - config: ["vite.config.js", "vite-embedded.config.js"], + config: ["vite.config.ts", "vite-embedded.config.ts"], }, entry: ["src/main.tsx", "i18next-parser.config.ts"], ignoreBinaries: [ From 217fa40ddbb1ceb745ab81b6a4e623f5dfa73c26 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 14 Aug 2025 14:57:20 +0200 Subject: [PATCH 3/4] Only forbid using console in application code --- .eslintrc.cjs | 11 +++++++++-- vite.config.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index b734c520..98e6e4c8 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -28,8 +28,6 @@ module.exports = { rules: { "matrix-org/require-copyright-header": ["error", COPYRIGHT_HEADER], "jsx-a11y/media-has-caption": "off", - // We should use the js-sdk logger, never console directly. - "no-console": ["error"], "react/display-name": "error", // Encourage proper usage of Promises: "@typescript-eslint/no-floating-promises": "error", @@ -46,6 +44,15 @@ module.exports = { "rxjs/no-exposed-subjects": "error", "rxjs/finnish": ["error", { names: { "^this$": false } }], }, + overrides: [ + { + files: ["src/*/**"], + rules: { + // In application code we should use the js-sdk logger, never console directly. + "no-console": ["error"], + }, + }, + ], settings: { react: { version: "detect", diff --git a/vite.config.ts b/vite.config.ts index 115565bb..cfc80279 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,7 +18,7 @@ import { sentryVitePlugin } from "@sentry/vite-plugin"; import react from "@vitejs/plugin-react"; import { realpathSync } from "fs"; import * as fs from "node:fs"; -import { logger } from "matrix-js-sdk/lib/logger"; + // https://vitejs.dev/config/ // Modified type helper from defineConfig to allow for packageType (see defineConfig from vite) export default ({ @@ -86,7 +86,7 @@ export default ({ allow.push(realpathSync(path)); } catch {} } - logger.log("Allowed vite paths:", allow); + console.log("Allowed vite paths:", allow); return { server: { From 8c1fa3fd703a2a48a483dc7129e0b76f737734d3 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 14 Aug 2025 14:57:39 +0200 Subject: [PATCH 4/4] Fix inaccurate copyright headers --- i18next-parser.config.ts | 6 ------ src/livekit/BlurBackgroundTransformer.ts | 2 +- src/livekit/TrackProcessorContext.tsx | 4 ++-- vitest.config.ts | 6 ------ 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/i18next-parser.config.ts b/i18next-parser.config.ts index e07021ae..10d748a8 100644 --- a/i18next-parser.config.ts +++ b/i18next-parser.config.ts @@ -1,9 +1,3 @@ -/* -Copyright 2024 New Vector Ltd. -SPDX-License-Identifier: AGPL-3.0-only -Please see LICENSE in the repository root for full details. -*/ - import type { UserConfig } from "i18next-parser"; const config: UserConfig = { diff --git a/src/livekit/BlurBackgroundTransformer.ts b/src/livekit/BlurBackgroundTransformer.ts index 72256fe1..c3d885ba 100644 --- a/src/livekit/BlurBackgroundTransformer.ts +++ b/src/livekit/BlurBackgroundTransformer.ts @@ -1,7 +1,7 @@ /* Copyright 2024-2025 New Vector Ltd. -SPDX-License-Identifier: AGPL-3.0-only +SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ diff --git a/src/livekit/TrackProcessorContext.tsx b/src/livekit/TrackProcessorContext.tsx index a68d7535..b37a6e3e 100644 --- a/src/livekit/TrackProcessorContext.tsx +++ b/src/livekit/TrackProcessorContext.tsx @@ -1,7 +1,7 @@ /* -Copyright 2024 New Vector Ltd. +Copyright 2024-2025 New Vector Ltd. -SPDX-License-Identifier: AGPL-3.0-only +SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ diff --git a/vitest.config.ts b/vitest.config.ts index ff8947b0..1c6f746b 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,9 +1,3 @@ -/* -Copyright 2024 New Vector Ltd. -SPDX-License-Identifier: AGPL-3.0-only -Please see LICENSE in the repository root for full details. -*/ - import { defineConfig, mergeConfig } from "vitest/config"; import viteConfig from "./vite.config";