Skip to content

Commit

Permalink
Merge pull request #1119 from neet/eliminate-ws
Browse files Browse the repository at this point in the history
fix: Eliminate direct imports from `ws`
  • Loading branch information
neet committed May 3, 2024
2 parents 331f015 + 37049df commit 409d2fb
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@
"@typescript-eslint/consistent-type-imports": [
"error",
{ "prefer": "type-imports", "fixStyle": "inline-type-imports" }
],
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "ws",
"message": "Use `isomophic-ws` instead."
}
]
}
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/async-iterable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getPort from "get-port";
import { WebSocket, WebSocketServer } from "ws";
import { WebSocket, WebSocketServer } from "isomorphic-ws";

import { toAsyncIterable } from "./async-iterable";
import { waitForOpen } from "./wait-for-events";
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/wait-for-events.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getPort from "get-port";
import WebSocket, { WebSocketServer } from "ws";
import WebSocket, { WebSocketServer } from "isomorphic-ws";

import { waitForClose, waitForOpen } from "./wait-for-events";

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/wait-for-events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import WebSocket from "ws";
import WebSocket from "isomorphic-ws";

export function waitForOpen(ws: WebSocket): Promise<void> {
if (ws.readyState === WebSocket.OPEN) {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/web-socket-connector.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getPort from "get-port";
import { WebSocketServer } from "ws";
import { WebSocketServer } from "isomorphic-ws";

import { MastoWebSocketError } from "../errors";
import { WebSocketConnectorImpl } from "./web-socket-connector";
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/web-socket-connector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import WebSocket from "ws";
import WebSocket from "isomorphic-ws";

import { type Logger, type WebSocketConnector } from "../../interfaces";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/web-socket-subscription.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getPort from "get-port";
import { WebSocketServer } from "ws";
import { WebSocketServer } from "isomorphic-ws";

import { createLogger } from "../logger";
import { SerializerNativeImpl } from "../serializers";
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/web-socket-subscription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type WebSocket from "ws";
import type WebSocket from "isomorphic-ws";

import {
type Logger,
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ws.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type WebSocket } from "ws";
import { type WebSocket } from "isomorphic-ws";

export interface WebSocketConnector {
acquire(): Promise<WebSocket>;
Expand Down

0 comments on commit 409d2fb

Please sign in to comment.