-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: enable lint on tests for api, interactions, predictions, pubsub packages #13547
Open
HuiSF
wants to merge
9
commits into
main
Choose a base branch
from
chore/repo/lint-more-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+286
−211
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2c4b492
chore: enable linting on tests for more packages: ⤵️
HuiSF c19a19b
chore(api): run yarn lint:fix
HuiSF bfbd9bd
chore(api): manual fix linter errors
HuiSF da5fa53
chore(interactions): run yarn lint:fix
HuiSF cc6321f
chore(interactions): manual fix linter errors
HuiSF 312f04c
chore(predictions): run yarn lint:fix
HuiSF 09af5e5
chore(predictions): manual fix linter errors
HuiSF e47277e
chore(pubsub): run yarn lint:fix
HuiSF 5ff4c36
chore(pubsub): manual fix linter errors
HuiSF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ export class HubConnectionListener { | |
} | ||
|
||
/** | ||
* @returns {Observable<ConnectionState>} - The observable that emits all ConnectionState updates (past and future) | ||
* @returns `Observable<ConnectionState>` - The observable that emits all ConnectionState updates (past and future) | ||
*/ | ||
allConnectionStateObserver() { | ||
return new Observable(observer => { | ||
|
@@ -46,7 +46,7 @@ export class HubConnectionListener { | |
} | ||
|
||
/** | ||
* @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates (past and future) | ||
* @returns `Observable<ConnectionState>` - The observable that emits ConnectionState updates (past and future) | ||
*/ | ||
connectionStateObserver() { | ||
return new Observable(observer => { | ||
|
@@ -65,21 +65,21 @@ export class HubConnectionListener { | |
} | ||
|
||
async waitForConnectionState(connectionStates: CS[]) { | ||
return new Promise<void>((res, rej) => { | ||
return new Promise<void>((resolve, _reject) => { | ||
this.connectionStateObserver().subscribe(value => { | ||
if (connectionStates.includes(String(value) as CS)) { | ||
res(undefined); | ||
resolve(undefined); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async waitUntilConnectionStateIn(connectionStates: CS[]) { | ||
return new Promise<void>((res, rej) => { | ||
return new Promise<void>((resolve, _reject) => { | ||
if (connectionStates.includes(this.currentConnectionState)) { | ||
res(undefined); | ||
resolve(undefined); | ||
} | ||
res(this.waitForConnectionState(connectionStates)); | ||
resolve(this.waitForConnectionState(connectionStates)); | ||
}); | ||
} | ||
} | ||
|
@@ -98,12 +98,12 @@ export class FakeWebSocketInterface { | |
} | ||
|
||
resetWebsocket() { | ||
this.readyForUse = new Promise((res, rej) => { | ||
this.readyResolve = res; | ||
this.readyForUse = new Promise((resolve, _reject) => { | ||
this.readyResolve = resolve; | ||
}); | ||
let closeResolver: (value: PromiseLike<any>) => void; | ||
this.hasClosed = new Promise((res, rej) => { | ||
closeResolver = res; | ||
this.hasClosed = new Promise((resolve, _reject) => { | ||
closeResolver = resolve; | ||
}); | ||
this.webSocket = new FakeWebSocket(() => closeResolver); | ||
} | ||
|
@@ -233,7 +233,7 @@ export class FakeWebSocketInterface { | |
/** | ||
* Send a data message | ||
*/ | ||
async sendDataMessage(data: {}) { | ||
async sendDataMessage(data: object) { | ||
await this.sendMessage( | ||
new MessageEvent('data', { | ||
data: JSON.stringify({ | ||
|
@@ -257,7 +257,7 @@ export class FakeWebSocketInterface { | |
/** | ||
* Run a command and resolve to allow internal behavior to execute | ||
*/ | ||
async runAndResolve(fn) { | ||
async runAndResolve(fn: () => Promise<unknown> | void) { | ||
await fn(); | ||
await Promise.resolve(); | ||
} | ||
|
@@ -266,10 +266,10 @@ export class FakeWebSocketInterface { | |
* DELETE THIS? | ||
*/ | ||
async observesConnectionState(connectionState: CS) { | ||
return new Promise<void>((res, rej) => { | ||
return new Promise<void>((resolve, _reject) => { | ||
this.allConnectionStateObserver().subscribe(value => { | ||
if (value === connectionState) { | ||
res(undefined); | ||
resolve(undefined); | ||
} | ||
}); | ||
}); | ||
|
@@ -306,7 +306,7 @@ class FakeWebSocket implements WebSocket { | |
protocol!: string; | ||
readyState!: number; | ||
url!: string; | ||
close(code?: number, reason?: string): void { | ||
close(): void { | ||
const closeResolver = this.closeResolverFcn(); | ||
if (closeResolver) closeResolver(Promise.resolve(undefined)); | ||
} | ||
|
@@ -316,10 +316,10 @@ class FakeWebSocket implements WebSocket { | |
this.subscriptionId = parsedInput.id; | ||
} | ||
|
||
CONNECTING: 0 = 0; | ||
OPEN: 1 = 1; | ||
CLOSING: 2 = 2; | ||
CLOSED: 3 = 3; | ||
CONNECTING: 0 = 0 as const; | ||
OPEN: 1 = 1 as const; | ||
CLOSING: 2 = 2 as const; | ||
CLOSED: 3 = 3 as const; | ||
addEventListener<K extends keyof WebSocketEventMap>( | ||
type: K, | ||
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, | ||
|
@@ -332,7 +332,7 @@ class FakeWebSocket implements WebSocket { | |
options?: boolean | AddEventListenerOptions, | ||
): void; | ||
|
||
addEventListener(type: unknown, listener: unknown, options?: unknown): void { | ||
addEventListener(): void { | ||
throw new Error('Method not implemented addEventListener.'); | ||
} | ||
|
||
|
@@ -348,15 +348,11 @@ class FakeWebSocket implements WebSocket { | |
options?: boolean | EventListenerOptions, | ||
): void; | ||
|
||
removeEventListener( | ||
type: unknown, | ||
listener: unknown, | ||
options?: unknown, | ||
): void { | ||
removeEventListener(): void { | ||
throw new Error('Method not implemented removeEventListener.'); | ||
} | ||
|
||
dispatchEvent(event: Event): boolean { | ||
dispatchEvent(): boolean { | ||
throw new Error('Method not implemented dispatchEvent.'); | ||
} | ||
|
||
|
@@ -370,7 +366,7 @@ export async function replaceConstant( | |
replacementValue: any, | ||
testFn: () => Promise<void>, | ||
) { | ||
const initialValue = constants[name]; | ||
const initialValue = (constants as any)[name]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why cast as any than their actual types? |
||
Object.defineProperty(constants, name, { | ||
value: replacementValue, | ||
}); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Can data be a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticeably this function is not even used by the tests.