Skip to content

Commit 52f0d57

Browse files
authored
Fix no-restricted-syntax errors (#3127)
This fixes lint violations caused by the `no-restricted-syntax` rule by suppressing these errors. We need to do additional research whether these can be fixed, as some may be used by tests.
1 parent 60a9d16 commit 52f0d57

File tree

11 files changed

+112
-0
lines changed

11 files changed

+112
-0
lines changed

packages/snaps-controllers/src/cronjob/CronjobController.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ export class CronjobController extends BaseController<
565565
*
566566
* @param snap - Basic Snap information.
567567
*/
568+
// TODO: Either fix this lint violation or explain why it's necessary to
569+
// ignore.
570+
// eslint-disable-next-line no-restricted-syntax
568571
private _handleSnapRegisterEvent(snap: TruncatedSnap) {
569572
this.register(snap.id);
570573
}
@@ -575,6 +578,9 @@ export class CronjobController extends BaseController<
575578
*
576579
* @param snap - Basic Snap information.
577580
*/
581+
// TODO: Either fix this lint violation or explain why it's necessary to
582+
// ignore.
583+
// eslint-disable-next-line no-restricted-syntax
578584
private _handleSnapEnabledEvent(snap: TruncatedSnap) {
579585
const events = this.getBackgroundEvents(snap.id);
580586
this.#rescheduleBackgroundEvents(events);
@@ -586,6 +592,9 @@ export class CronjobController extends BaseController<
586592
*
587593
* @param snap - Basic Snap information.
588594
*/
595+
// TODO: Either fix this lint violation or explain why it's necessary to
596+
// ignore.
597+
// eslint-disable-next-line no-restricted-syntax
589598
private _handleSnapUnregisterEvent(snap: TruncatedSnap) {
590599
this.unregister(snap.id);
591600
}
@@ -595,6 +604,9 @@ export class CronjobController extends BaseController<
595604
*
596605
* @param snap - Basic Snap information.
597606
*/
607+
// TODO: Either fix this lint violation or explain why it's necessary to
608+
// ignore.
609+
// eslint-disable-next-line no-restricted-syntax
598610
private _handleSnapDisabledEvent(snap: TruncatedSnap) {
599611
this.unregister(snap.id, true);
600612
}
@@ -604,6 +616,9 @@ export class CronjobController extends BaseController<
604616
*
605617
* @param snap - Basic Snap information.
606618
*/
619+
// TODO: Either fix this lint violation or explain why it's necessary to
620+
// ignore.
621+
// eslint-disable-next-line no-restricted-syntax
607622
private _handleEventSnapUpdated(snap: TruncatedSnap) {
608623
this.unregister(snap.id);
609624
this.register(snap.id);

packages/snaps-controllers/src/services/AbstractExecutionService.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export abstract class AbstractExecutionService<WorkerType>
7474
protected jobs: Map<string, Job<WorkerType>>;
7575

7676
// Cannot be hash private yet because of tests.
77+
// eslint-disable-next-line no-restricted-syntax
7778
private readonly setupSnapProvider: SetupSnapProvider;
7879

7980
readonly #snapToJobMap: Map<string, string>;
@@ -116,6 +117,9 @@ export abstract class AbstractExecutionService<WorkerType>
116117
* Constructor helper for registering the controller's messaging system
117118
* actions.
118119
*/
120+
// TODO: Either fix this lint violation or explain why it's necessary to
121+
// ignore.
122+
// eslint-disable-next-line no-restricted-syntax
119123
private registerMessageHandlers(): void {
120124
this.#messenger.registerActionHandler(
121125
`${controllerName}:handleRpcRequest`,
@@ -360,6 +364,9 @@ export abstract class AbstractExecutionService<WorkerType>
360364
* @param snapId - The id of the Snap whose message handler to get.
361365
* @returns The RPC request handler for the snap.
362366
*/
367+
// TODO: Either fix this lint violation or explain why it's necessary to
368+
// ignore.
369+
// eslint-disable-next-line no-restricted-syntax
363370
private getRpcRequestHandler(snapId: string) {
364371
return this.#snapRpcHooks.get(snapId);
365372
}
@@ -437,6 +444,7 @@ export abstract class AbstractExecutionService<WorkerType>
437444
}
438445

439446
// Cannot be hash private yet because of tests.
447+
// eslint-disable-next-line no-restricted-syntax
440448
private async command(
441449
jobId: string,
442450
message: JsonRpcRequest,

packages/snaps-controllers/src/services/webview/WebViewMessageStream.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export class WebViewMessageStream extends BasePostMessageStream {
7272
this.#webView.injectJavaScript(`window.postMessage([${bytes.toString()}])`);
7373
}
7474

75+
// TODO: Either fix this lint violation or explain why it's necessary to
76+
// ignore.
77+
// eslint-disable-next-line no-restricted-syntax
7578
private _onMessage(event: PostMessageEvent): void {
7679
if (typeof event.data !== 'string') {
7780
return;

packages/snaps-controllers/src/services/webworker/WebWorkerExecutionService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export class WebWorkerExecutionService extends AbstractExecutionService<string>
9595
*
9696
* If the document already exists, this does nothing.
9797
*/
98+
// TODO: Either fix this lint violation or explain why it's necessary to
99+
// ignore.
100+
// eslint-disable-next-line no-restricted-syntax
98101
private async createDocument() {
99102
// We only want to create a single pool.
100103
if (document.getElementById(WORKER_POOL_ID)) {

packages/snaps-controllers/src/snaps/RequestQueue.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export class RequestQueue {
22
public readonly maxQueueSize: number;
33

4+
// TODO: Either fix this lint violation or explain why it's necessary to
5+
// ignore.
6+
// eslint-disable-next-line no-restricted-syntax
47
private readonly queueSizes: Map<string, number>;
58

69
constructor(maxQueueSize: number) {

packages/snaps-controllers/src/snaps/SnapController.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ export class SnapController extends BaseController<
843843
readonly #maxIdleTime: number;
844844

845845
// This property cannot be hash private yet because of tests.
846+
// eslint-disable-next-line no-restricted-syntax
846847
private readonly maxRequestTime: number;
847848

848849
readonly #encryptor: ExportableKeyEncryptor;
@@ -2556,6 +2557,9 @@ export class SnapController extends BaseController<
25562557
* @param versionRange - The semver range of the snap to install.
25572558
* @returns The resulting snap object, or an error if something went wrong.
25582559
*/
2560+
// TODO: Either fix this lint violation or explain why it's necessary to
2561+
// ignore.
2562+
// eslint-disable-next-line no-restricted-syntax
25592563
private async processRequestedSnap(
25602564
origin: string,
25612565
snapId: SnapId,
@@ -3278,6 +3282,7 @@ export class SnapController extends BaseController<
32783282
* @param pendingApproval - Pending approval to update.
32793283
* @returns The snap's approvedPermissions.
32803284
*/
3285+
// eslint-disable-next-line no-restricted-syntax
32813286
private async authorize(
32823287
snapId: SnapId,
32833288
pendingApproval: PendingApproval,

packages/snaps-controllers/src/snaps/Timer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { assert } from '@metamask/utils';
33
export type TimerStatus = 'stopped' | 'paused' | 'running' | 'finished';
44

55
export class Timer {
6+
// TODO: Either fix this lint violation or explain why it's necessary to
7+
// ignore.
8+
// eslint-disable-next-line no-restricted-syntax
69
private state:
710
| { value: 'stopped'; remaining: number }
811
| {
@@ -129,6 +132,9 @@ export class Timer {
129132
this.state = { value: 'running', callback, remaining, start, timeout };
130133
}
131134

135+
// TODO: Either fix this lint violation or explain why it's necessary to
136+
// ignore.
137+
// eslint-disable-next-line no-restricted-syntax
132138
private onFinish(shouldCall: boolean) {
133139
assert(this.state.value === 'running' || this.state.value === 'paused');
134140

packages/snaps-controllers/src/snaps/location/http.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,29 @@ export type HttpOptions = {
2020
};
2121

2222
export class HttpLocation implements SnapLocation {
23+
// TODO: Either fix this lint violation or explain why it's necessary to
24+
// ignore.
25+
// eslint-disable-next-line no-restricted-syntax
2326
private readonly cache = new Map<string, VirtualFile>();
2427

28+
// TODO: Either fix this lint violation or explain why it's necessary to
29+
// ignore.
30+
// eslint-disable-next-line no-restricted-syntax
2531
private validatedManifest?: VirtualFile<SnapManifest>;
2632

33+
// TODO: Either fix this lint violation or explain why it's necessary to
34+
// ignore.
35+
// eslint-disable-next-line no-restricted-syntax
2736
private readonly url: URL;
2837

38+
// TODO: Either fix this lint violation or explain why it's necessary to
39+
// ignore.
40+
// eslint-disable-next-line no-restricted-syntax
2941
private readonly fetchFn: typeof fetch;
3042

43+
// TODO: Either fix this lint violation or explain why it's necessary to
44+
// ignore.
45+
// eslint-disable-next-line no-restricted-syntax
3146
private readonly fetchOptions?: RequestInit;
3247

3348
constructor(url: URL, opts: HttpOptions = {}) {
@@ -100,6 +115,9 @@ export class HttpLocation implements SnapLocation {
100115
return new URL(this.url);
101116
}
102117

118+
// TODO: Either fix this lint violation or explain why it's necessary to
119+
// ignore.
120+
// eslint-disable-next-line no-restricted-syntax
103121
private toCanonical(path: string): URL {
104122
assert(!path.startsWith('/'), 'Tried to parse absolute path.');
105123
return new URL(path, this.url);

packages/snaps-execution-environments/src/common/BaseSnapExecutor.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,39 @@ export type NotifyFunction = (
117117
) => Promise<void>;
118118

119119
export class BaseSnapExecutor {
120+
// TODO: Either fix this lint violation or explain why it's necessary to
121+
// ignore.
122+
// eslint-disable-next-line no-restricted-syntax
120123
private readonly snapData: Map<string, SnapData>;
121124

125+
// TODO: Either fix this lint violation or explain why it's necessary to
126+
// ignore.
127+
// eslint-disable-next-line no-restricted-syntax
122128
private readonly commandStream: Duplex;
123129

130+
// TODO: Either fix this lint violation or explain why it's necessary to
131+
// ignore.
132+
// eslint-disable-next-line no-restricted-syntax
124133
private readonly rpcStream: Duplex;
125134

135+
// TODO: Either fix this lint violation or explain why it's necessary to
136+
// ignore.
137+
// eslint-disable-next-line no-restricted-syntax
126138
private readonly methods: CommandMethodsMapping;
127139

140+
// TODO: Either fix this lint violation or explain why it's necessary to
141+
// ignore.
142+
// eslint-disable-next-line no-restricted-syntax
128143
private snapErrorHandler?: (event: ErrorEvent) => void;
129144

145+
// TODO: Either fix this lint violation or explain why it's necessary to
146+
// ignore.
147+
// eslint-disable-next-line no-restricted-syntax
130148
private snapPromiseErrorHandler?: (event: PromiseRejectionEvent) => void;
131149

150+
// TODO: Either fix this lint violation or explain why it's necessary to
151+
// ignore.
152+
// eslint-disable-next-line no-restricted-syntax
132153
private lastTeardown = 0;
133154

134155
protected constructor(commandStream: Duplex, rpcStream: Duplex) {
@@ -189,6 +210,9 @@ export class BaseSnapExecutor {
189210
);
190211
}
191212

213+
// TODO: Either fix this lint violation or explain why it's necessary to
214+
// ignore.
215+
// eslint-disable-next-line no-restricted-syntax
192216
private errorHandler(error: unknown, data: Record<string, Json>) {
193217
const serializedError = serializeError(error, {
194218
fallbackError: unhandledError,
@@ -214,6 +238,9 @@ export class BaseSnapExecutor {
214238
});
215239
}
216240

241+
// TODO: Either fix this lint violation or explain why it's necessary to
242+
// ignore.
243+
// eslint-disable-next-line no-restricted-syntax
217244
private async onCommandRequest(message: JsonRpcRequest) {
218245
if (!isJsonRpcRequest(message)) {
219246
if (
@@ -458,6 +485,9 @@ export class BaseSnapExecutor {
458485
this.snapData.clear();
459486
}
460487

488+
// TODO: Either fix this lint violation or explain why it's necessary to
489+
// ignore.
490+
// eslint-disable-next-line no-restricted-syntax
461491
private async registerSnapExports(snapId: string, snapModule: any) {
462492
const data = this.snapData.get(snapId);
463493
// Somebody deleted the snap before we could register.
@@ -486,6 +516,9 @@ export class BaseSnapExecutor {
486516
* @param provider - A StreamProvider connected to MetaMask.
487517
* @returns The snap provider object.
488518
*/
519+
// TODO: Either fix this lint violation or explain why it's necessary to
520+
// ignore.
521+
// eslint-disable-next-line no-restricted-syntax
489522
private createSnapGlobal(provider: StreamProvider): SnapsProvider {
490523
const originalRequest = provider.request.bind(provider);
491524

@@ -523,6 +556,9 @@ export class BaseSnapExecutor {
523556
* @param provider - A StreamProvider connected to MetaMask.
524557
* @returns The EIP-1193 Ethereum provider object.
525558
*/
559+
// TODO: Either fix this lint violation or explain why it's necessary to
560+
// ignore.
561+
// eslint-disable-next-line no-restricted-syntax
526562
private createEIP1193Provider(
527563
provider: StreamProvider,
528564
): SnapsEthereumProvider {
@@ -561,6 +597,9 @@ export class BaseSnapExecutor {
561597
*
562598
* @param snapId - The id of the snap to remove.
563599
*/
600+
// TODO: Either fix this lint violation or explain why it's necessary to
601+
// ignore.
602+
// eslint-disable-next-line no-restricted-syntax
564603
private removeSnap(snapId: string): void {
565604
this.snapData.delete(snapId);
566605
}
@@ -576,6 +615,9 @@ export class BaseSnapExecutor {
576615
* @returns The executor's return value.
577616
* @template Result - The return value of the executor.
578617
*/
618+
// TODO: Either fix this lint violation or explain why it's necessary to
619+
// ignore.
620+
// eslint-disable-next-line no-restricted-syntax
579621
private async executeInSnapContext<Result>(
580622
snapId: string,
581623
executor: () => Promise<Result> | Result,

packages/snaps-execution-environments/src/webview/WebViewExecutorStream.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export class WebViewExecutorStream extends BasePostMessageStream {
6161
);
6262
}
6363

64+
// TODO: Either fix this lint violation or explain why it's necessary to
65+
// ignore.
66+
// eslint-disable-next-line no-restricted-syntax
6467
private _onMessage(event: PostMessageEvent): void {
6568
if (!Array.isArray(event.data)) {
6669
return;

0 commit comments

Comments
 (0)