Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorLift committed Jul 12, 2024
1 parent 506b57b commit c3f2c5e
Show file tree
Hide file tree
Showing 232 changed files with 406 additions and 389 deletions.
2 changes: 1 addition & 1 deletion packages/create-snap/src/cmds/init/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { logInfo } from '@metamask/snaps-utils';
import type yargs from 'yargs';

import { initHandler } from './initHandler';
import builders from '../../builders';
import type { YargsArgs } from '../../types/yargs';
import { initHandler } from './initHandler';

export const initCommand = {
command: ['$0 [directory]'],
Expand Down
4 changes: 2 additions & 2 deletions packages/create-snap/src/cmds/init/initHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { promises as fs } from 'fs';
import pathUtils from 'path';
import semver from 'semver';

import { resetFileSystem } from '../../test-utils';
import type { YargsArgs } from '../../types/yargs';
import { initHandler } from './initHandler';
import * as initUtils from './initUtils';
import { resetFileSystem } from '../../test-utils';
import type { YargsArgs } from '../../types/yargs';

jest.mock('fs');

Expand Down
2 changes: 1 addition & 1 deletion packages/create-snap/src/cmds/init/initHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import pathUtils from 'path';
import type { SemVer } from 'semver';
import semver from 'semver';

import type { YargsArgs } from '../../types/yargs';
import {
buildSnap,
cloneTemplate,
Expand All @@ -23,6 +22,7 @@ import {
SNAP_LOCATION,
yarnInstall,
} from './initUtils';
import type { YargsArgs } from '../../types/yargs';

/**
* Creates a new snap package, based on one of the provided templates. This
Expand Down
2 changes: 1 addition & 1 deletion packages/create-snap/src/cmds/init/initUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import childProcess from 'child_process';
import { promises as fs } from 'fs';
import pathUtils from 'path';

import { resetFileSystem } from '../../test-utils';
import {
buildSnap,
cloneTemplate,
Expand All @@ -14,6 +13,7 @@ import {
yarnInstall,
TEMPLATE_GIT_URL,
} from './initUtils';
import { resetFileSystem } from '../../test-utils';

jest.mock('fs');

Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-cli/src/commands/build/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DEFAULT_SNAP_BUNDLE } from '@metamask/snaps-utils/test-utils';
import fs from 'fs';

import { getMockConfig } from '../../test-utils';
import { evaluate } from '../eval';
import { buildHandler } from './build';
import { build } from './implementation';
import { getMockConfig } from '../../test-utils';
import { evaluate } from '../eval';

jest.mock('fs');
jest.mock('../eval');
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/build/build.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { isFile } from '@metamask/snaps-utils/node';
import { resolve as pathResolve } from 'path';

import { build } from './implementation';
import type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';
import { CommandError } from '../../errors';
import type { Steps } from '../../utils';
import { executeSteps, info } from '../../utils';
import { evaluate } from '../eval';
import { build } from './implementation';

type BuildContext = {
config: ProcessedWebpackConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import normalFs from 'fs';
import { dirname, resolve } from 'path';
import type { Configuration } from 'webpack';

import { build } from './implementation';
import { getMockConfig } from '../../test-utils';
import { getCompiler } from '../../webpack';
import type * as webpack from '../../webpack';
import type * as utils from '../../webpack/utils';
import { BROWSERSLIST_FILE } from '../../webpack/utils';
import { build } from './implementation';

const { promises: fs } = normalFs;

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/build/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type yargs from 'yargs';

import { buildHandler } from './build';
import builders from '../../builders';
import type { YargsArgs } from '../../types/yargs';
import { buildHandler } from './build';

const command = {
command: ['build', 'b'],
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/eval/eval.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { isFile } from '@metamask/snaps-utils/node';
import { resolve } from 'path';

import { evaluate } from './implementation';
import type { ProcessedConfig } from '../../config';
import { CommandError } from '../../errors';
import type { Steps } from '../../utils';
import { executeSteps, getRelativePath } from '../../utils';
import { evaluate } from './implementation';

export type EvalOptions = {
input?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/eval/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import command from '.';
import { evaluateHandler } from './eval';
import { getMockConfig } from '../../test-utils';
import type { YargsArgs } from '../../types/yargs';
import { evaluateHandler } from './eval';

jest.mock('./eval');

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/eval/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type yargs from 'yargs';

import { evaluateHandler } from './eval';
import builders from '../../builders';
import type { YargsArgs } from '../../types/yargs';
import { evaluateHandler } from './eval';

const command = {
command: ['eval', 'e'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
import normalFs from 'fs';
import ora from 'ora';

import type * as webpack from '../../webpack';
import { manifest } from './implementation';
import type * as webpack from '../../webpack';

const { promises: fs } = normalFs;

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/manifest/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import command from '.';
import { manifestHandler } from './manifest';
import { getMockConfig } from '../../test-utils';
import type { YargsArgs } from '../../types/yargs';
import { manifestHandler } from './manifest';

jest.mock('./manifest');

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type yargs from 'yargs';

import { manifestHandler } from './manifest';
import builders from '../../builders';
import type { YargsArgs } from '../../types/yargs';
import { manifestHandler } from './manifest';

const command = {
command: ['manifest', 'm'],
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/manifest/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isFile } from '@metamask/snaps-utils/node';

import { manifest } from './implementation';
import type { ProcessedConfig } from '../../config';
import { CommandError } from '../../errors';
import type { Steps } from '../../utils';
import { executeSteps } from '../../utils';
import { manifest } from './implementation';

type ManifestOptions = {
fix?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/serve/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import command from '.';
import { serveHandler } from './serve';
import { getMockConfig } from '../../test-utils';
import type { YargsArgs } from '../../types/yargs';
import { serveHandler } from './serve';

jest.mock('./serve');

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/serve/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type yargs from 'yargs';

import { serveHandler } from './serve';
import builders from '../../builders';
import type { YargsArgs } from '../../types/yargs';
import { serveHandler } from './serve';

const command = {
command: ['serve', 's'],
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/serve/serve.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { serveHandler } from './serve';
import { getMockConfig } from '../../test-utils';
import * as webpack from '../../webpack';
import { serveHandler } from './serve';

jest.mock('../../webpack');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
} from '@metamask/snaps-utils/test-utils';
import normalFs from 'fs';

import { watch } from './implementation';
import { getMockConfig } from '../../test-utils';
import { getCompiler } from '../../webpack';
import type * as webpack from '../../webpack';
import { watch } from './implementation';

const { promises: fs } = normalFs;

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/watch/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import command from '.';
import { watchHandler } from './watch';
import { getMockConfig } from '../../test-utils';
import type { YargsArgs } from '../../types/yargs';
import { watchHandler } from './watch';

jest.mock('./watch');

Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/watch/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type yargs from 'yargs';

import { watchHandler } from './watch';
import builders from '../../builders';
import type { YargsArgs } from '../../types/yargs';
import { watchHandler } from './watch';

const command = {
command: ['watch', 'w'],
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/watch/watch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { getMockConfig } from '@metamask/snaps-cli/test-utils';
import { DEFAULT_SNAP_BUNDLE } from '@metamask/snaps-utils/test-utils';
import fs from 'fs';

import * as webpack from '../../webpack';
import { watch } from './implementation';
import { watchHandler } from './watch';
import * as webpack from '../../webpack';

jest.mock('fs');
jest.mock('../../webpack');
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/commands/watch/watch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { isFile } from '@metamask/snaps-utils/node';

import { watch } from './implementation';
import type { ProcessedConfig, ProcessedWebpackConfig } from '../../config';
import { CommandError } from '../../errors';
import type { Steps } from '../../utils';
import { executeSteps, info } from '../../utils';
import { getServer } from '../../webpack';
import { watch } from './implementation';

type WatchOptions = {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/utils/errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandError } from '../errors';
import { getErrorMessage, getYargsErrorMessage } from './errors';
import { CommandError } from '../errors';

describe('getYargsErrorMessage', () => {
it('returns the plain message if the error is undefined', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/utils/legacy.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getMockConfig } from '@metamask/snaps-cli/test-utils';

import { TranspilationModes } from '../builders';
import {
getDependencyRegExp,
processDependencies,
sanitizeDependencyPaths,
} from './legacy';
import { TranspilationModes } from '../builders';

describe('processDependencies', () => {
it('returns an empty array when `transpilationMode` is not `localAndDeps`', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { Configuration } from 'webpack';
import { Compiler } from 'webpack';
import merge from 'webpack-merge';

import { getMockConfig } from '../test-utils';
import { getCompiler } from './compiler';
import { getMockConfig } from '../test-utils';

jest.dontMock('fs');
jest.mock('serve-handler', () =>
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { webpack } from 'webpack';

import type { ProcessedWebpackConfig } from '../config';
import type { WebpackOptions } from './config';
import { getDefaultConfiguration } from './config';
import type { ProcessedWebpackConfig } from '../config';

/**
* Get a Webpack compiler for the given config.
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { promises as fs } from 'fs';
import ora from 'ora';
import { dirname } from 'path';

import { getMockConfig, normalizeConfig } from '../test-utils';
import { getDefaultConfiguration } from './config';
import { getMockConfig, normalizeConfig } from '../test-utils';

jest.mock('fs');
jest.mock('path', () => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import TerserPlugin from 'terser-webpack-plugin';
import type { Configuration } from 'webpack';
import { DefinePlugin, ProgressPlugin, ProvidePlugin } from 'webpack';

import type { ProcessedWebpackConfig } from '../config';
import { getFunctionLoader, wasm } from './loaders';
import {
SnapsBuiltInResolver,
Expand All @@ -22,6 +21,7 @@ import {
getImageSVG,
getProgressHandler,
} from './utils';
import type { ProcessedWebpackConfig } from '../config';

export type WebpackOptions = {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/loaders/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type FunctionLoaderOptions = {
* @param content - The input file contents as a `Uint8Array`.
* @returns The output of the function.
*/
const loader: LoaderDefinitionFunction<FunctionLoaderOptions> = function (
const loader: LoaderDefinitionFunction<FunctionLoaderOptions> = async function (
content,
) {
const { fn } = this.getOptions();
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-cli/src/webpack/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { promisify } from 'util';
import type { Compiler, Watching } from 'webpack';
import { WebpackError, ProvidePlugin } from 'webpack';

import * as evalImplementation from '../commands/eval/implementation';
import { compile, getCompiler } from '../test-utils';
import {
SnapsBuiltInResolver,
SnapsBundleWarningsPlugin,
SnapsStatsPlugin,
SnapsWatchPlugin,
} from './plugins';
import * as evalImplementation from '../commands/eval/implementation';
import { compile, getCompiler } from '../test-utils';

jest.dontMock('fs');
jest.mock('../commands/eval/implementation');
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import type {
} from 'webpack';
import { WebpackError } from 'webpack';

import { formatText, pluralize } from './utils';
import { evaluate } from '../commands/eval';
import { error, getErrorMessage, info, warn } from '../utils';
import { formatText, pluralize } from './utils';

export type SnapsStatsPluginOptions = {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-cli/src/webpack/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { dim } from 'chalk';

import type { ProcessedWebpackConfig } from '../config';
import { getMockConfig } from '../test-utils';
import { browserify } from './loaders';
import {
WEBPACK_FALLBACKS,
Expand All @@ -15,6 +13,8 @@ import {
formatText,
getImageSVG,
} from './utils';
import type { ProcessedWebpackConfig } from '../config';
import { getMockConfig } from '../test-utils';

describe('getDefaultLoader', () => {
it('returns the Browserify loader if `legacy` is set', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-cli/src/webpack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { dirname, resolve } from 'path';
import stripAnsi from 'strip-ansi';
import type { Configuration } from 'webpack';

import type { ProcessedWebpackConfig } from '../config';
import { browserify, getFunctionLoader } from './loaders';
import type { ProcessedWebpackConfig } from '../config';

export const BROWSERSLIST_FILE = resolve(
dirname(
Expand Down
Loading

0 comments on commit c3f2c5e

Please sign in to comment.