Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ritave committed Jul 25, 2024
1 parent 243a871 commit c5b114d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/snaps-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export * from './ui';
export * from './validation';
export * from './versions';
export * from './virtual-file';
export * from './promise';
3 changes: 2 additions & 1 deletion packages/snaps-utils/src/manifest/validator-types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Promisable } from '../promise';
import type { SnapFiles, UnvalidatedSnapFiles } from '../types';
import type { SnapManifest } from './validation';

// Eslint uses patch based fixing, but it's too complex for our needs.
// https://eslint.org/docs/latest/extend/custom-rules#applying-fixes
export type ValidatorFix = (files: {
manifest: SnapManifest;
}) => { manifest: SnapManifest } | Promise<{ manifest: SnapManifest }>;
}) => Promisable<{ manifest: SnapManifest }>;

export type ValidatorSeverity = 'error' | 'warning';

Expand Down
4 changes: 2 additions & 2 deletions packages/snaps-utils/src/manifest/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type ValidatorResults = {
class Context implements ValidatorContext {
reports: ValidatorReport[] = [];

#nextSeverity?: ValidatorSeverity = undefined;

report(message: string, fix?: ValidatorFix): void {
assert(this.#nextSeverity !== undefined);
this.reports.push({
Expand All @@ -34,8 +36,6 @@ class Context implements ValidatorContext {
get hasErrors() {
return this.reports.some((report) => report.severity === 'error');
}

#nextSeverity?: ValidatorSeverity = undefined;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-utils/src/promise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Promisable<Type> = Type | Promise<Type>;

0 comments on commit c5b114d

Please sign in to comment.