Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Add rule to use import and import type #83

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
"prettier",
],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
"caughtErrorsIgnorePattern": "^_",
},
],
"no-console": ["error", { "allow": ["warn", "error"] }],
"react-refresh/only-export-components": ["warn", { "allowConstantExport": true }]
}
"react-hooks/exhaustive-deps": "error",
"react-hooks/rules-of-hooks": "error",
"react-refresh/only-export-components": ["warn", { "allowConstantExport": true }],
},
}
3 changes: 2 additions & 1 deletion examples/minimal-react/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import VideoPlayer from "./VideoPlayer";
import { SCREEN_SHARING_MEDIA_CONSTRAINTS, Client } from "@fishjam-dev/react-client";
import type { Client } from "@fishjam-dev/react-client";
import { SCREEN_SHARING_MEDIA_CONSTRAINTS } from "@fishjam-dev/react-client";
import { useState } from "react";
import { useConnect, useDisconnect, useClient, useStatus, useTracks } from "./client";

Expand Down
3 changes: 2 additions & 1 deletion examples/minimal-react/src/components/VideoPlayer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RefObject, useEffect, useRef } from "react";
import type { RefObject } from "react";
import { useEffect, useRef } from "react";

type Props = {
stream: MediaStream | null | undefined;
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal-react/src/components/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from "@fishjam-dev/react-client";
import { PeerMetadata, TrackMetadata } from "./App";
import type { PeerMetadata, TrackMetadata } from "./App";

// Create a Membrane client instance
// remember to use FishjamContextProvider
Expand Down
2 changes: 1 addition & 1 deletion examples/use-camera-and-microphone-example/src/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PeerStatus } from "@fishjam-dev/react-client";
import type { PeerStatus } from "@fishjam-dev/react-client";

type Props = {
status: PeerStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PeerStatus, UseMicrophoneResult, UseCameraResult, UseScreenShareResult } from "@fishjam-dev/react-client";
import { TrackMetadata } from "./fishjamSetup";
import type { PeerStatus, UseMicrophoneResult, UseCameraResult, UseScreenShareResult } from "@fishjam-dev/react-client";
import type { TrackMetadata } from "./fishjamSetup";

type DeviceControlsProps = {
status: PeerStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeEvent, useState } from "react";
import type { ChangeEvent } from "react";
import { useState } from "react";

type Props = {
name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RefObject, useEffect, useRef } from "react";
import type { RefObject } from "react";
import { useEffect, useRef } from "react";

type Props = {
stream: MediaStream | null | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { ClientEvents, create } from "@fishjam-dev/react-client";
import type { ClientEvents } from "@fishjam-dev/react-client";
import { create } from "@fishjam-dev/react-client";
import { useEffect, useState } from "react";

const peerMetadataSchema = z.object({
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions src/Client.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import EventEmitter from "events";
import TypedEmitter from "typed-emitter";
import {
import type TypedEmitter from "typed-emitter";
import type {
AuthErrorReason,
BandwidthLimit,
Component,
ConnectConfig,
CreateConfig,
FishjamClient,
MessageEvents,
Peer,
SimulcastConfig,
TrackBandwidthLimit,
TrackContext,
TrackEncoding,
} from "@fishjam-dev/ts-client";
import { PeerId, PeerState, PeerStatus, Track, TrackId, TrackWithOrigin } from "./state.types";
import { DeviceManager, DeviceManagerEvents } from "./DeviceManager";
import { MediaDeviceType, ScreenShareManager, ScreenShareManagerConfig } from "./ScreenShareManager";
import {
import { FishjamClient } from "@fishjam-dev/ts-client";
import type { PeerId, PeerState, PeerStatus, Track, TrackId, TrackWithOrigin } from "./state.types";
import type { DeviceManagerEvents } from "./DeviceManager";
import { DeviceManager } from "./DeviceManager";
import type { MediaDeviceType, ScreenShareManagerConfig } from "./ScreenShareManager";
import { ScreenShareManager } from "./ScreenShareManager";
import type {
DeviceManagerConfig,
DeviceState,
InitMediaConfig,
Expand Down
12 changes: 4 additions & 8 deletions src/DeviceManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AudioOrVideoType,
CurrentDevices,
DeviceError,
Expand All @@ -9,14 +9,10 @@ import {
GetMedia,
InitMediaConfig,
Media,
NOT_FOUND_ERROR,
OVERCONSTRAINED_ERROR,
parseError,
PERMISSION_DENIED,
StorageConfig,
UNHANDLED_ERROR,
UseUserMediaStartConfig,
} from "./types";
import { NOT_FOUND_ERROR, OVERCONSTRAINED_ERROR, parseError, PERMISSION_DENIED, UNHANDLED_ERROR } from "./types";

import { loadObject, saveObject } from "./localStorage";
import {
Expand All @@ -27,8 +23,8 @@ import {
} from "./constraints";

import EventEmitter from "events";
import TypedEmitter from "typed-emitter";
import { TrackType } from "./ScreenShareManager";
import type TypedEmitter from "typed-emitter";
import type { TrackType } from "./ScreenShareManager";

const removeExact = (
trackConstraints: boolean | MediaTrackConstraints | undefined,
Expand Down
5 changes: 3 additions & 2 deletions src/ScreenShareManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import EventEmitter from "events";
import TypedEmitter from "typed-emitter";
import { AudioOrVideoType, DeviceError, DevicesStatus, parseError } from "./types";
import type TypedEmitter from "typed-emitter";
import type { AudioOrVideoType, DeviceError, DevicesStatus } from "./types";
import { parseError } from "./types";

export type TrackType = "audio" | "video" | "audiovideo";
export type MediaDeviceType = "displayMedia" | "userMedia";
Expand Down
24 changes: 8 additions & 16 deletions src/create.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import {
createContext,
JSX,
ReactNode,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
useSyncExternalStore,
} from "react";
import type { JSX, ReactNode } from "react";
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
import type { Selector, State } from "./state.types";
import { PeerStatus, TrackId, TrackWithOrigin } from "./state.types";
import { ConnectConfig, CreateConfig } from "@fishjam-dev/ts-client";
import {
import type { PeerStatus, TrackId, TrackWithOrigin } from "./state.types";
import type { ConnectConfig, CreateConfig } from "@fishjam-dev/ts-client";
import type {
DeviceManagerConfig,
UseCameraAndMicrophoneResult,
UseCameraResult,
Expand All @@ -21,8 +12,9 @@ import {
UseSetupMediaConfig,
UseSetupMediaResult,
} from "./types";
import { Client, ClientApi, ClientEvents } from "./Client";
import { MediaDeviceType, ScreenShareManagerConfig } from "./ScreenShareManager";
import type { ClientApi, ClientEvents } from "./Client";
import { Client } from "./Client";
import type { MediaDeviceType, ScreenShareManagerConfig } from "./ScreenShareManager";

export type FishjamContextProviderProps = {
children: ReactNode;
Expand Down
10 changes: 5 additions & 5 deletions src/state.types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { TrackEncoding, VadStatus, SimulcastConfig } from "@fishjam-dev/ts-client";
import { UseUserMediaState } from "./types";
import { UseCameraAndMicrophoneResult } from "./types";
import { Client } from "./Client";
import { DeviceManager } from "./DeviceManager";
import { ScreenShareManager } from "./ScreenShareManager";
import type { UseUserMediaState } from "./types";
import type { UseCameraAndMicrophoneResult } from "./types";
import type { Client } from "./Client";
import type { DeviceManager } from "./DeviceManager";
import type { ScreenShareManager } from "./ScreenShareManager";

export type TrackId = string;
export type PeerId = string;
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SimulcastConfig, TrackBandwidthLimit } from "@fishjam-dev/ts-client";
import { ScreenShareManagerConfig } from "./ScreenShareManager";
import { Track } from "./state.types";
import type { SimulcastConfig, TrackBandwidthLimit } from "@fishjam-dev/ts-client";
import type { ScreenShareManagerConfig } from "./ScreenShareManager";
import type { Track } from "./state.types";

export type AudioOrVideoType = "audio" | "video";

Expand Down
2 changes: 1 addition & 1 deletion tests/globalSetupState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StartedDockerComposeEnvironment } from "testcontainers";
import type { StartedDockerComposeEnvironment } from "testcontainers";

export type SetupState = {
fishjamContainer: StartedDockerComposeEnvironment | null;
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, Page, test } from "@playwright/test";
import type { Page } from "@playwright/test";
import { expect, test } from "@playwright/test";

export const joinRoomAndAddScreenShare = async (page: Page, roomId: string): Promise<string> =>
test.step("Join room and add track", async () => {
Expand Down
Loading