Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ritave committed Nov 18, 2022
1 parent 1ab518a commit eb04a9b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { createAsyncMiddleware, JsonRpcEngine } from 'json-rpc-engine';
import { createEngineStream } from 'json-rpc-middleware-stream';
import pump from 'pump';
import { Duplex } from 'stream';

import { NodeThreadExecutionService, setupMultiplex } from '../services';
import {
ExecutionEnvironmentStub,
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-controllers/src/snaps/SnapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1536,8 +1536,8 @@ export class SnapController extends BaseController<
await Promise.all(
Object.entries(requestedSnaps).map(
async ([snapId, { version: rawVersion }]) => {
const [err, version] = resolveVersionRange(rawVersion);
if (err) {
const [error, version] = resolveVersionRange(rawVersion);
if (error) {
result[snapId] = {
error: ethErrors.rpc.invalidParams(
`The "version" field must be a valid SemVer version range if specified. Received: "${version}".`,
Expand Down
6 changes: 3 additions & 3 deletions packages/snaps-controllers/src/snaps/utils/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ async function fetchNpmTarball(
}

const versions = Object.keys((packageMetadata as any)?.versions ?? {}).map(
(v) => {
assertIsSemVerVersion(v);
return v;
(version) => {
assertIsSemVerVersion(version);
return version;
},
);

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-utils/src/manifest/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {

import { CronjobSpecificationArrayStruct } from '../cronjob';
import { NamespacesStruct } from '../namespace';
import { VersionStruct } from '../versions';
import { NameStruct, NpmSnapFileNames } from '../types';
import { VersionStruct } from '../versions';

// 0xd36e6170 - 0x80000000
export const SIP_6_MAGIC_VALUE = `1399742832'` as `${number}'`;
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-utils/src/test-utils/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SemVerVersion } from '../versions';
import { SnapManifest } from '../manifest/validation';
import {
Chain,
Expand All @@ -7,8 +6,9 @@ import {
SessionNamespace,
} from '../namespace';
import { NpmSnapPackageJson } from '../types';
import { DEFAULT_SNAP_SHASUM } from './snap';
import { SemVerVersion } from '../versions';
import { MakeSemVer } from './common';
import { DEFAULT_SNAP_SHASUM } from './snap';

type GetSnapManifestOptions = Partial<MakeSemVer<SnapManifest>> & {
shasum?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-utils/src/test-utils/snap.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { SemVerVersion } from '../versions';
import {
getSnapSourceShasum,
PersistedSnap,
Snap,
SnapStatus,
TruncatedSnap,
} from '../snaps';
import { getSnapManifest } from './manifest';
import { SemVerVersion } from '../versions';
import { MakeSemVer } from './common';
import { getSnapManifest } from './manifest';

/**
* A mock snap source and its shasum.
Expand Down
7 changes: 4 additions & 3 deletions packages/snaps-utils/src/versions.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from '@metamask/utils';

import { getSnapPrefix } from './snaps';
import { SnapIdPrefixes } from './types';
import {
Expand Down Expand Up @@ -33,9 +34,9 @@ describe('resolveVersion', () => {
});

it.each([null, 1, {}, Error])('returns error on invalid input', (value) => {
const [err, result] = resolveVersionRange(value);
assert(err !== undefined);
expect(err.message).toMatch('Expected a string, but received: ');
const [error, result] = resolveVersionRange(value);
assert(error !== undefined);
expect(error.message).toMatch('Expected a string, but received: ');
expect(result).toBeUndefined();
});
});
Expand Down

0 comments on commit eb04a9b

Please sign in to comment.