Enable oxlint restriction ruleset (#34307)
* Remove stale max-len disablements * Remove stale camelCase & naming-convention disablements * Remove stale ban-ts-comment disablements * Remove stale no-var disablements * Remove stale no-empty-property disablements * Remove stale react rule disablements * Remove stale no-constant-condition disablements * Remove stale no-unused-vars disablements * Remove stale disablements for disabled rules * fixup camelcase * Remove dead code * Tidy code * Tweak oxlint config * Use oxlint to apply jsx/tsx extension consistently * Fix import * Fix imports * Rename affected snapshots * Update more imports * Enable restriction ruleset * Make code comply with new rules * Make code comply with react/button-has-type * Make code comply with typescript/non-nullable-type-assertion-style * Comply with node/no-process-env * Comply with unicorn/prefer-node-protocol * Comply with unicorn/import-style * Comply with unicorn/no-process-exit * Comply with no-proto * Comply with node/handle-callback-err * Comply with import/no-commonjs * Comply with node/no-path-concat * Comply with unicorn/no-length-as-slice-end * Comply with unicorn/no-document-cookie * Comply with unicorn/prefer-module * Comply with typescript/prefer-literal-enum-member * Comply with jsx-a11y/anchor-ambiguous-text * Tweak oxlint config * Fix resolves * Iterate * Iterate * Iterate * Iterate * Iterate * Iterate * Iterate
This commit is contained in:
@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import * as os from "node:os";
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import path from "node:path";
|
||||
import { type Configuration as BaseConfiguration } from "electron-builder";
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,19 +5,16 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { resolve, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { test, expect } from "../../element-desktop-test.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
test.describe("App config options", () => {
|
||||
test.describe("Should load custom config via env", () => {
|
||||
test.slow();
|
||||
test.use({
|
||||
extraEnv: {
|
||||
ELEMENT_DESKTOP_CONFIG_JSON: resolve(__dirname, "../..", "fixtures/custom-config.json"),
|
||||
ELEMENT_DESKTOP_CONFIG_JSON: fileURLToPath(import.meta.resolve("../../fixtures/custom-config.json")),
|
||||
},
|
||||
});
|
||||
test("should launch and use configured homeserver", async ({ page }) => {
|
||||
@@ -31,7 +28,7 @@ test.describe("App config options", () => {
|
||||
test.describe("Should load custom config via argument", () => {
|
||||
test.slow();
|
||||
test.use({
|
||||
extraArgs: ["--config", resolve(__dirname, "../..", "fixtures/custom-config.json")],
|
||||
extraArgs: ["--config", fileURLToPath(import.meta.resolve("../../fixtures/custom-config.json"))],
|
||||
});
|
||||
test("should launch and use configured homeserver", async ({ page }) => {
|
||||
await page.locator("#matrixchat").waitFor();
|
||||
|
||||
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { _electron as electron, test as base, expect as baseExpect, type ElectronApplication } from "@playwright/test";
|
||||
import fs from "node:fs/promises";
|
||||
import path, { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
import os from "node:os";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { PassThrough } from "node:stream";
|
||||
@@ -44,7 +44,7 @@ interface Fixtures {
|
||||
stderr: CapturedPassThrough;
|
||||
}
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export const test = base.extend<Fixtures>({
|
||||
extraEnv: {},
|
||||
|
||||
@@ -11,7 +11,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import parseArgs from "minimist";
|
||||
import * as chokidar from "chokidar";
|
||||
import * as path from "node:path";
|
||||
import path from "node:path";
|
||||
import * as fs from "node:fs";
|
||||
|
||||
const argv = parseArgs(process.argv.slice(2), {});
|
||||
|
||||
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import * as path from "node:path";
|
||||
import path from "node:path";
|
||||
import { createWriteStream, promises as fs } from "node:fs";
|
||||
import * as childProcess from "node:child_process";
|
||||
import * as tar from "tar";
|
||||
|
||||
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import path, { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import HakEnv from "./hakEnv.ts";
|
||||
@@ -28,7 +28,7 @@ const METACOMMANDS: Record<string, string[]> = {
|
||||
// Scripts valid in a hak.json 'scripts' section
|
||||
const HAKSCRIPTS = ["check", "fetch", "build"];
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const prefix = path.join(__dirname, "..", "..");
|
||||
|
||||
@@ -6,11 +6,11 @@ Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
|
||||
import { tryPaths } from "./utils.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
let asarPathPromise: Promise<string> | undefined;
|
||||
// Get the webapp resource file path, memoizes result
|
||||
|
||||
@@ -7,12 +7,12 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { expect, describe, it, beforeEach, vi } from "vitest";
|
||||
import { fs as memfs, vol } from "memfs";
|
||||
import { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { getBuildConfig } from "./build-config.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
vi.mock("node:fs", () => ({ default: memfs }));
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import path, { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { type JsonObject } from "shared-types";
|
||||
|
||||
import { loadJsonFile } from "./utils.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
let buildConfig: BuildConfig;
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { expect, describe, it, beforeEach, vi } from "vitest";
|
||||
import { fs as memfs, vol } from "memfs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dialog } from "electron";
|
||||
|
||||
import { type ConfigOptions } from "./config.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
vi.mock("node:fs", () => ({ default: memfs }));
|
||||
vi.mock("node:fs/promises", () => ({ default: memfs.promises }));
|
||||
@@ -52,7 +52,7 @@ describe("loadConfig", () => {
|
||||
});
|
||||
|
||||
it("should ignore localConfigPath if does not exist", async () => {
|
||||
const config = await loadConfig(resolve(__dirname, "../custom-config.json"));
|
||||
const config = await loadConfig("/invalid-path/custom-config.json");
|
||||
expect(config.brand).toBe("Element");
|
||||
expect(config.web_base_url).toBe("https://chat.org.com");
|
||||
expect(config.default_hs_url).toBe("https://matrix.org.com");
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
desktopCapturer,
|
||||
} from "electron";
|
||||
import * as Sentry from "@sentry/electron/main";
|
||||
import path, { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
import windowStateKeeper from "electron-window-state";
|
||||
import { URL, fileURLToPath } from "node:url";
|
||||
|
||||
@@ -48,7 +48,7 @@ import { getIconPath } from "./icon.js";
|
||||
import { getArgs } from "./args.js";
|
||||
import { type ConfigOptions, loadConfig } from "./config.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const buildConfig = getBuildConfig();
|
||||
const protocolHandler = new ProtocolHandler(buildConfig.protocol);
|
||||
|
||||
@@ -7,12 +7,9 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { expect, describe, it, beforeEach, vi } from "vitest";
|
||||
import { fs as memfs, vol } from "memfs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { getIconPath } from "./icon.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
vi.mock("node:fs/promises", () => ({ default: memfs.promises }));
|
||||
|
||||
@@ -28,20 +25,20 @@ describe("getIconPath", () => {
|
||||
"build/icon.png": "png",
|
||||
"build/icon.ico": "ico",
|
||||
},
|
||||
resolve(__dirname, "../webapp"),
|
||||
fileURLToPath(import.meta.resolve("../webapp")),
|
||||
);
|
||||
});
|
||||
|
||||
it("should use .ico on Windows", async () => {
|
||||
vi.spyOn(process, "platform", "get").mockReturnValue("win32");
|
||||
await expect(getIconPath()).resolves.toEqual(resolve(__dirname, "../build/icon.ico"));
|
||||
await expect(getIconPath()).resolves.toEqual(fileURLToPath(import.meta.resolve("../build/icon.ico")));
|
||||
});
|
||||
it("should use .png on macOS", async () => {
|
||||
vi.spyOn(process, "platform", "get").mockReturnValue("darwin");
|
||||
await expect(getIconPath()).resolves.toEqual(resolve(__dirname, "../build/icon.png"));
|
||||
await expect(getIconPath()).resolves.toEqual(fileURLToPath(import.meta.resolve("../build/icon.png")));
|
||||
});
|
||||
it("should use .png on Linux", async () => {
|
||||
vi.spyOn(process, "platform", "get").mockReturnValue("linux");
|
||||
await expect(getIconPath()).resolves.toEqual(resolve(__dirname, "../build/icon.png"));
|
||||
await expect(getIconPath()).resolves.toEqual(fileURLToPath(import.meta.resolve("../build/icon.png")));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,14 +7,14 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import counterpart from "counterpart";
|
||||
import { type TranslationKey as TKey } from "matrix-web-i18n";
|
||||
import { dirname } from "node:path";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import type EN from "./i18n/strings/en_EN.json";
|
||||
import { loadJsonFile } from "./utils.js";
|
||||
import type Store from "./store.js";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const FALLBACK_LOCALE = "en";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user