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:
@@ -9,10 +9,11 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { describe, it, expect } from "vitest";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { blobIsAnimated, mayBeAnimated } from "./Image";
|
||||
|
||||
const imagesDir = path.resolve(__dirname, "../../test/unit-tests/images");
|
||||
const imagesDir = fileURLToPath(import.meta.resolve("../../test/unit-tests/images"));
|
||||
|
||||
describe("Image", () => {
|
||||
describe("mayBeAnimated", () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
* @event module:utils~ResizeNotifier#"middlePanelResizedNoisy"
|
||||
*/
|
||||
|
||||
// oxlint-disable-next-line no-restricted-imports
|
||||
import { EventEmitter } from "events";
|
||||
import { throttle } from "lodash";
|
||||
|
||||
|
||||
@@ -212,17 +212,6 @@ export class UrlPreviewFetcher {
|
||||
* Convert an MSC4095 URL preview bundle item to a UrlPreview
|
||||
*/
|
||||
public previewFromBundle(single: UnstableBundledUrlPreviewSingle): UrlPreview {
|
||||
// missing fields from the bundle because backend does provide it:
|
||||
// - siteName (can be computed)
|
||||
// - favicon
|
||||
// - media is a video or audio?
|
||||
// TODO in next PR: URL previews in encrypted chat?
|
||||
const hasImage =
|
||||
typeof single["og:image"] === "string" &&
|
||||
typeof single["og:image:type"] === "string" &&
|
||||
typeof single["og:image:width"] === "number" &&
|
||||
typeof single["og:image:height"] === "number";
|
||||
|
||||
const preview: UrlPreview = {
|
||||
link: single.matched_url,
|
||||
title: single["og:title"] ?? single.matched_url,
|
||||
@@ -232,7 +221,17 @@ export class UrlPreviewFetcher {
|
||||
ogUrl: single["og:url"],
|
||||
};
|
||||
|
||||
if (hasImage) {
|
||||
// missing fields from the bundle because backend does provide it:
|
||||
// - siteName (can be computed)
|
||||
// - favicon
|
||||
// - media is a video or audio?
|
||||
// TODO in next PR: URL previews in encrypted chat?
|
||||
if (
|
||||
typeof single["og:image"] === "string" &&
|
||||
typeof single["og:image:type"] === "string" &&
|
||||
typeof single["og:image:width"] === "number" &&
|
||||
typeof single["og:image:height"] === "number"
|
||||
) {
|
||||
const media = mediaFromMxc(single["og:image"], this.client);
|
||||
const thumb = media.getThumbnailOfSourceHttp(PREVIEW_WIDTH_PX, PREVIEW_HEIGHT_PX, "scale");
|
||||
|
||||
@@ -245,10 +244,10 @@ export class UrlPreviewFetcher {
|
||||
preview.image = {
|
||||
imageThumb: thumb,
|
||||
imageFull: media.srcHttp,
|
||||
imageType: single["og:image:type"] as string,
|
||||
mxcImageFull: single["og:image"] as string,
|
||||
width: single["og:image:width"] as number,
|
||||
height: single["og:image:height"] as number,
|
||||
imageType: single["og:image:type"],
|
||||
mxcImageFull: single["og:image"],
|
||||
width: single["og:image:width"],
|
||||
height: single["og:image:height"],
|
||||
playable: false, // TODO: do we know?
|
||||
};
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ export function arrayTrimFill<T>(a: T[], len: number, seed: T[]): T[] {
|
||||
* @returns A copy of the array.
|
||||
*/
|
||||
export function arrayFastClone<T>(a: T[]): T[] {
|
||||
return a.slice(0, a.length);
|
||||
return a.slice(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,7 @@ export async function createThumbnail(
|
||||
let context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
||||
try {
|
||||
canvas = new window.OffscreenCanvas(targetWidth, targetHeight);
|
||||
context = canvas.getContext("2d") as OffscreenCanvasRenderingContext2D;
|
||||
context = canvas.getContext("2d")!;
|
||||
} catch {
|
||||
// Fallback support for other browsers (Safari and Firefox for now)
|
||||
canvas = document.createElement("canvas");
|
||||
|
||||
@@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { vi, describe, it, expect, afterAll, beforeEach } from "vitest";
|
||||
import { getMockClientWithEventEmitter } from "test-utils/client";
|
||||
|
||||
import { type EventEmitter } from "events";
|
||||
import { type EventEmitter } from "node:events";
|
||||
import { Room, RoomMember, EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user