Skip to content

Commit

Permalink
Enable @typescript-eslint/consistent-type-imports lint rule
Browse files Browse the repository at this point in the history
This is to help ensure that we get proper vite/rollup lazy loading by not `import`ing more than we need to.

Revert "Enable @typescript-eslint/consistent-type-imports lint rule"

This reverts commit ba385fa.

Enable @typescript-eslint/consistent-type-imports lint rule

This is to help ensure that we get proper vite/rollup lazy loading by not `import`ing more than we need to.

.
  • Loading branch information
hughns committed Dec 9, 2024
1 parent d698705 commit 568be5a
Show file tree
Hide file tree
Showing 149 changed files with 433 additions and 425 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ module.exports = {
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/await-thenable": "error",
// To help ensure that we get proper vite/rollup lazy loading (e.g. for matrix-js-sdk):
"@typescript-eslint/consistent-type-imports": [
"error",
{ fixStyle: "inline-type-imports" },
],
// To encourage good usage of RxJS:
"rxjs/no-exposed-subjects": "error",
},
settings: {
Expand Down
2 changes: 1 addition & 1 deletion src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.

import "matrix-js-sdk/src/@types/global";
import type { DurationFormat as PolyfillDurationFormat } from "@formatjs/intl-durationformat";
import { Controls } from "../controls";
import { type Controls } from "../controls";

declare global {
interface Document {
Expand Down
2 changes: 1 addition & 1 deletion src/@types/i18next.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.

import "i18next";
// import all namespaces (for the default language, only)
import app from "../../locales/en/app.json";
import type app from "../../locales/en/app.json";

declare module "i18next" {
interface CustomTypeOptions {
Expand Down
4 changes: 2 additions & 2 deletions src/@types/matrix-js-sdk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Please see LICENSE in the repository root for full details.
*/

import {
ElementCallReactionEventType,
ECallReactionEventContent,
type ElementCallReactionEventType,
type ECallReactionEventContent,
} from "../reactions";

// Extend Matrix JS SDK types via Typescript declaration merging to support unspecced event fields and types
Expand Down
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, Suspense, useEffect, useState } from "react";
import { type FC, Suspense, useEffect, useState } from "react";
import {
BrowserRouter as Router,
Switch,
Route,
useLocation,
} from "react-router-dom";
import * as Sentry from "@sentry/react";
import { History } from "history";
import { type History } from "history";
import { TooltipProvider } from "@vector-im/compound-web";
import { logger } from "matrix-js-sdk/src/logger";

Expand Down
4 changes: 2 additions & 2 deletions src/Avatar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Please see LICENSE in the repository root for full details.

import { afterEach, expect, test, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { FC, PropsWithChildren } from "react";
import { type MatrixClient } from "matrix-js-sdk/src/client";
import { type FC, type PropsWithChildren } from "react";

import { ClientContextProvider } from "./ClientContext";
import { Avatar } from "./Avatar";
Expand Down
4 changes: 2 additions & 2 deletions src/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { useMemo, FC, CSSProperties, useState, useEffect } from "react";
import { useMemo, type FC, type CSSProperties, useState, useEffect } from "react";
import { Avatar as CompoundAvatar } from "@vector-im/compound-web";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { type MatrixClient } from "matrix-js-sdk/src/client";

import { useClientState } from "./ClientContext";

Expand Down
4 changes: 2 additions & 2 deletions src/ClientContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/

import {
FC,
type FC,
useCallback,
useEffect,
useState,
Expand All @@ -18,7 +18,7 @@ import {
import { useHistory } from "react-router-dom";
import { logger } from "matrix-js-sdk/src/logger";
import { useTranslation } from "react-i18next";
import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync";
import { type ISyncStateData, type SyncState } from "matrix-js-sdk/src/sync";
import { ClientEvent, type MatrixClient } from "matrix-js-sdk/src/client";

import type { WidgetApi } from "matrix-widget-api";
Expand Down
4 changes: 2 additions & 2 deletions src/DisconnectedBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Please see LICENSE in the repository root for full details.
*/

import classNames from "classnames";
import { FC, HTMLAttributes, ReactNode } from "react";
import { type FC, type HTMLAttributes, type ReactNode } from "react";
import { useTranslation } from "react-i18next";

import styles from "./DisconnectedBanner.module.css";
import { ValidClientState, useClientState } from "./ClientContext";
import { type ValidClientState, useClientState } from "./ClientContext";

interface Props extends HTMLAttributes<HTMLElement> {
children?: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/FullScreenView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, ReactNode, useCallback, useEffect } from "react";
import { type FC, type ReactNode, useCallback, useEffect } from "react";
import { useLocation } from "react-router-dom";
import classNames from "classnames";
import { Trans, useTranslation } from "react-i18next";
Expand Down
2 changes: 1 addition & 1 deletion src/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/

import classNames from "classnames";
import { FC, HTMLAttributes, ReactNode, forwardRef } from "react";
import { type FC, type HTMLAttributes, type ReactNode, forwardRef } from "react";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Heading, Text } from "@vector-im/compound-web";
Expand Down
2 changes: 1 addition & 1 deletion src/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.

import { expect, test } from "vitest";
import { render } from "@testing-library/react";
import { ReactNode, useState } from "react";
import { type ReactNode, useState } from "react";
import { afterEach } from "node:test";
import userEvent from "@testing-library/user-event";

Expand Down
2 changes: 1 addition & 1 deletion src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, ReactNode, useCallback } from "react";
import { type FC, type ReactNode, useCallback } from "react";
import { useTranslation } from "react-i18next";
import {
Root as DialogRoot,
Expand Down
2 changes: 1 addition & 1 deletion src/QrCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, useEffect, useState } from "react";
import { type FC, useEffect, useState } from "react";
import { toDataURL } from "qrcode";
import classNames from "classnames";
import { t } from "i18next";
Expand Down
2 changes: 1 addition & 1 deletion src/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, useCallback } from "react";
import { type FC, useCallback } from "react";
import { Root, Track, Range, Thumb } from "@radix-ui/react-slider";
import classNames from "classnames";
import { Tooltip } from "@vector-im/compound-web";
Expand Down
6 changes: 3 additions & 3 deletions src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Please see LICENSE in the repository root for full details.
*/

import {
ComponentType,
FC,
SVGAttributes,
type ComponentType,
type FC,
type SVGAttributes,
useCallback,
useEffect,
} from "react";
Expand Down
2 changes: 1 addition & 1 deletion src/UrlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useLocation } from "react-router-dom";
import { logger } from "matrix-js-sdk/src/logger";

import { Config } from "./config/Config";
import { EncryptionSystem } from "./e2ee/sharedKeyManagement";
import { type EncryptionSystem } from "./e2ee/sharedKeyManagement";
import { E2eeType } from "./e2ee/e2eeType";

interface RoomIdentifier {
Expand Down
2 changes: 1 addition & 1 deletion src/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, useMemo, useState } from "react";
import { type FC, useMemo, useState } from "react";
import { useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Menu, MenuItem } from "@vector-im/compound-web";
Expand Down
2 changes: 1 addition & 1 deletion src/UserMenuContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, useCallback, useState } from "react";
import { type FC, useCallback, useState } from "react";
import { useHistory, useLocation } from "react-router-dom";

import { useClientLegacy } from "./ClientContext";
Expand Down
2 changes: 1 addition & 1 deletion src/analytics/AnalyticsNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC } from "react";
import { type FC } from "react";
import { Trans } from "react-i18next";

import { ExternalLink } from "../button/Link";
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/PosthogAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import posthog, { CaptureOptions, PostHog, Properties } from "posthog-js";
import posthog, { type CaptureOptions, type PostHog, type Properties } from "posthog-js";
import { logger } from "matrix-js-sdk/src/logger";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
import { Buffer } from "buffer";

import { widget } from "../widget";
Expand Down
6 changes: 3 additions & 3 deletions src/analytics/PosthogEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { DisconnectReason } from "livekit-client";
import { type DisconnectReason } from "livekit-client";
import { logger } from "matrix-js-sdk/src/logger";
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc";
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc";

import {
IPosthogEvent,
type IPosthogEvent,
PosthogAnalytics,
RegistrationType,
} from "./PosthogAnalytics";
Expand Down
6 changes: 3 additions & 3 deletions src/analytics/PosthogSpanProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Please see LICENSE in the repository root for full details.
*/

import {
SpanProcessor,
ReadableSpan,
Span,
type SpanProcessor,
type ReadableSpan,
type Span,
} from "@opentelemetry/sdk-trace-base";
import { hrTimeToMilliseconds } from "@opentelemetry/core";
import { logger } from "matrix-js-sdk/src/logger";
Expand Down
8 changes: 4 additions & 4 deletions src/analytics/RageshakeSpanProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { AttributeValue, Attributes } from "@opentelemetry/api";
import { type AttributeValue, type Attributes } from "@opentelemetry/api";
import { hrTimeToMicroseconds } from "@opentelemetry/core";
import {
SpanProcessor,
ReadableSpan,
Span,
type SpanProcessor,
type ReadableSpan,
type Span,
} from "@opentelemetry/sdk-trace-base";

const dumpAttributes = (
Expand Down
2 changes: 1 addition & 1 deletion src/auth/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { FC, FormEvent, useCallback, useRef, useState } from "react";
import { type FC, type FormEvent, useCallback, useRef, useState } from "react";
import { useHistory, useLocation } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import { Button } from "@vector-im/compound-web";
Expand Down
6 changes: 3 additions & 3 deletions src/auth/RegisterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Please see LICENSE in the repository root for full details.
*/

import {
ChangeEvent,
FC,
FormEvent,
type ChangeEvent,
type FC,
type FormEvent,
useCallback,
useEffect,
useRef,
Expand Down
6 changes: 3 additions & 3 deletions src/auth/useInteractiveLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { useCallback } from "react";
import { InteractiveAuth } from "matrix-js-sdk/src/interactive-auth";
import {
createClient,
LoginResponse,
MatrixClient,
type LoginResponse,
type MatrixClient,
} from "matrix-js-sdk/src/matrix";

import { initClient } from "../utils/matrix";
import { Session } from "../ClientContext";
import { type Session } from "../ClientContext";
/**
* This provides the login method to login using user credentials.
* @param oldClient If there is an already authenticated client it should be passed to this hook
Expand Down
6 changes: 3 additions & 3 deletions src/auth/useInteractiveRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { useState, useEffect, useCallback, useRef } from "react";
import { InteractiveAuth } from "matrix-js-sdk/src/interactive-auth";
import {
createClient,
MatrixClient,
RegisterResponse,
type MatrixClient,
type RegisterResponse,
} from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";

import { initClient } from "../utils/matrix";
import { Session } from "../ClientContext";
import { type Session } from "../ClientContext";
import { Config } from "../config/Config";
import { widget } from "../widget";

Expand Down
2 changes: 1 addition & 1 deletion src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright 2022-2024 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/
import { ComponentPropsWithoutRef, FC } from "react";
import { type ComponentPropsWithoutRef, type FC } from "react";
import classNames from "classnames";
import { useTranslation } from "react-i18next";
import { Button as CpdButton, Tooltip } from "@vector-im/compound-web";
Expand Down
2 changes: 1 addition & 1 deletion src/button/InviteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { ComponentPropsWithoutRef, FC } from "react";
import { type ComponentPropsWithoutRef, type FC } from "react";
import { Button } from "@vector-im/compound-web";
import { useTranslation } from "react-i18next";
import { UserAddIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
Expand Down
6 changes: 3 additions & 3 deletions src/button/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Please see LICENSE in the repository root for full details.
*/

import {
ComponentPropsWithoutRef,
type ComponentPropsWithoutRef,
forwardRef,
MouseEvent,
type MouseEvent,
useCallback,
useMemo,
} from "react";
import { Link as CpdLink } from "@vector-im/compound-web";
import { useHistory } from "react-router-dom";
import { createPath, LocationDescriptor, Path } from "history";
import { createPath, type LocationDescriptor, type Path } from "history";
import classNames from "classnames";

import { useLatest } from "../useLatest";
Expand Down
4 changes: 2 additions & 2 deletions src/button/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
*/

import { ComponentPropsWithoutRef, forwardRef } from "react";
import { type ComponentPropsWithoutRef, forwardRef } from "react";
import { Button } from "@vector-im/compound-web";
import { LocationDescriptor } from "history";
import { type LocationDescriptor } from "history";

import { useLink } from "./Link";

Expand Down
2 changes: 1 addition & 1 deletion src/button/ReactionToggleButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { render } from "@testing-library/react";
import { expect, test } from "vitest";
import { TooltipProvider } from "@vector-im/compound-web";
import { userEvent } from "@testing-library/user-event";
import { ReactNode } from "react";
import { type ReactNode } from "react";

import {
MockRoom,
Expand Down
Loading

0 comments on commit 568be5a

Please sign in to comment.