Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 0 additions & 95 deletions oxlint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,111 +329,16 @@
"count": 1
}
},
"src/cache-utils.ts": {
"jsdoc/require-returns": {
"count": 1
}
},
"src/changelog-check.mts": {
"typescript/explicit-function-return-type": {
"count": 1
},
"typescript/no-unsafe-argument": {
"count": 1
},
"typescript/no-unsafe-member-access": {
"count": 1
}
},
"src/error-utils.ts": {
"typescript/explicit-function-return-type": {
"count": 1
}
},
"src/fs-utils.ts": {
"typescript/no-unsafe-return": {
"count": 1
}
},
"src/get-review-metrics.ts": {
"jsdoc/require-returns": {
"count": 1
},
"typescript/explicit-function-return-type": {
"count": 1
},
"typescript/no-unnecessary-type-assertion": {
"count": 1
},
"typescript/no-unsafe-argument": {
"count": 1
},
"typescript/no-unsafe-assignment": {
"count": 1
},
"typescript/no-unsafe-member-access": {
"count": 1
}
},
"src/github/octokit.ts": {
"jsdoc/require-returns": {
"count": 1
}
},
"src/scripts/count-references-to-contributor-docs/cli.ts": {
"typescript/explicit-function-return-type": {
"count": 1
}
},
"src/segment-schema-draft-pr/analytics-model.ts": {
"unicorn/no-useless-undefined": {
"count": 1
}
},
"src/segment-schema-draft-pr/apply-changes.ts": {
"import/consistent-type-specifier-style": {
"count": 1
},
"typescript/explicit-function-return-type": {
"count": 1
},
"typescript/no-unnecessary-type-assertion": {
"count": 2
}
},
"src/segment-schema-draft-pr/cli.ts": {
"import/consistent-type-specifier-style": {
"count": 1
}
},
"src/segment-schema-draft-pr/diff-models.ts": {
"typescript/no-unsafe-assignment": {
"count": 6
}
},
"src/segment-schema-draft-pr/generate.test.ts": {
"typescript/return-await": {
"count": 2
}
},
"src/segment-schema-draft-pr/github-output.ts": {
"node/no-sync": {
"count": 1
}
},
"src/segment-schema-draft-pr/publish.test.ts": {
"import/consistent-type-specifier-style": {
"count": 1
},
"typescript/no-unsafe-member-access": {
"count": 1
}
},
"src/segment-schema-draft-pr/schema-index.ts": {
"typescript/no-unnecessary-type-assertion": {
"count": 2
}
},
"yarn.config.cjs": {
"import/unambiguous": {
"count": 1
Expand Down
1 change: 1 addition & 0 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DEFAULT_MAX_AGE = 60 * 60 * 1000; // 1 hour
* considered "fresh". Affects subsequent calls: if `fetchOrPopulateFileCache`
* is called again with the same file path within the duration specified here,
* `getDataToCache` will not get called again, otherwise it will.
* @returns The cached data if it is fresh, otherwise the newly generated data.
*/
export async function fetchOrPopulateFileCache<Data extends Json>({
filePath,
Expand Down
4 changes: 2 additions & 2 deletions src/changelog-check.mts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ async function getChangedPackages(
/**
* Main function to run the changelog check.
*/
async function main() {
async function main(): Promise<void> {
// Parse command-line arguments
const args = process.argv.slice(2);

Expand Down Expand Up @@ -623,7 +623,7 @@ async function main() {
}
}

main().catch((error) => {
main().catch((error: { message: string }) => {
logError(error.message);
// eslint-disable-next-line n/no-process-exit
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/error-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function isErrorWithCode(error: unknown): error is { code: string } {
* something throwable).
* @returns A new error object.
*/
export function wrapError(message: string, originalError: unknown) {
export function wrapError(message: string, originalError: unknown): Error {
if (isError(originalError)) {
const error: Error & { code?: string } = new Error(message, {
cause: originalError,
Expand Down
2 changes: 1 addition & 1 deletion src/fs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function readJsonFile<Value extends Json>(
): Promise<Value> {
try {
const content = await readFile(filePath);
return JSON.parse(content);
return JSON.parse(content) as Value;
} catch (error) {
throw wrapError(`Could not read JSON file '${filePath}'`, error);
}
Expand Down
7 changes: 5 additions & 2 deletions src/get-review-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const pullRequests: {
* Get all review comments for the repository specified.
*
* @param page - The page number of results to fetch.
* @returns Whether the last page of results has been reached.
*/
async function getAllComments(page = 1) {
async function getAllComments(page = 1): Promise<boolean> {
const { data } = await octokit.rest.pulls.listReviewCommentsForRepo({
owner: 'MetaMask',
repo: 'metamask-extension',
Expand Down Expand Up @@ -75,7 +76,9 @@ async function execute(): Promise<void> {
});
const pulls = Object.keys(pullRequests);
for (const pull of pulls) {
const { data } = await octokit.request(pull);
const { data } = (await octokit.request(pull)) as {
data: { user: { login: string } };
};
if (TEAM.includes(data.user.login) && pullRequests[pull]) {
(pullRequests[pull] as PullRequestData).isInternal = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/github/octokit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getRequiredEnvironmentVariable } from '../env-utils';
*
* @param args - The same arguments that
* [`graphql`](https://github.com/octokit/graphql.js) takes.
* @returns The response data of the GraphQL request.
*/
export async function graphql<ResponseData>(
...args: Parameters<typeof octokitGraphql>
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/count-references-to-contributor-docs/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ main().catch(console.error);
* This script counts the number of references to the `contributor-docs` repo
* across a selection of MetaMask repositories.
*/
async function main() {
async function main(): Promise<void> {
const spinner = ora();

console.log(
Expand Down
2 changes: 1 addition & 1 deletion src/segment-schema-draft-pr/analytics-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function extractAnalyticsModel(
filePath: string,
sourceText: string,
config: PlatformConfig,
sharedCatalog: EventCatalog | undefined = undefined,
sharedCatalog?: EventCatalog | undefined,
): AnalyticsModel {
const sourceFile = ts.createSourceFile(
filePath,
Expand Down
9 changes: 5 additions & 4 deletions src/segment-schema-draft-pr/apply-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { Document as YamlDocument } from 'yaml';

import { TODO_DESCRIPTION } from './constants';
import { uniqueKebabSlug } from './names';
import { defaultPropKeys, type SchemaIndex } from './schema-index';
import { defaultPropKeys } from './schema-index';
import type { SchemaIndex } from './schema-index';
import type {
AnalyticsChangeSet,
IntendedFileChange,
Expand Down Expand Up @@ -126,7 +127,7 @@ function newEventNames(
const names: string[] = [];
const seen = new Set<string>();

const consider = (eventName: string) => {
const consider = (eventName: string): void => {
if (seen.has(eventName) || index.eventsByName.has(eventName)) {
return;
}
Expand Down Expand Up @@ -454,7 +455,7 @@ function yamlKey(value: unknown): string | undefined {
return value;
}
if (value && typeof value === 'object' && 'value' in value) {
const inner = (value as { value: unknown }).value;
const inner = value.value;
if (typeof inner === 'string') {
return inner;
}
Expand All @@ -476,7 +477,7 @@ function isYamlMap(value: unknown): value is {
typeof value === 'object' &&
value !== null &&
'items' in value &&
Array.isArray((value as { items: unknown }).items)
Array.isArray(value.items)
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/segment-schema-draft-pr/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { botBranchName } from './config';
import { generateSchemaDraft, writeSummaryFile } from './generate';
import { createOctokitClients, parseRepo } from './github-api';
import { writeGithubOutput } from './github-output';
import { parseCliArgs, type CliArgs } from './parse-args';
import { parseCliArgs } from './parse-args';
import type { CliArgs } from './parse-args';
import { runPublish } from './publish';

main().catch((error: unknown) => {
Expand Down
7 changes: 5 additions & 2 deletions src/segment-schema-draft-pr/diff-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
AnalyticsModel,
EventChange,
PropertyChange,
PropertyType,
RemovedProperty,
RenameChange,
UnresolvedProperty,
Expand Down Expand Up @@ -54,8 +55,10 @@ export function diffModels(
continue;
}

const baseProps = base.events.get(eventName)?.properties ?? new Map();
const headProps = head.events.get(eventName)?.properties ?? new Map();
const baseProps =
base.events.get(eventName)?.properties ?? new Map<string, PropertyType>();
const headProps =
head.events.get(eventName)?.properties ?? new Map<string, PropertyType>();

for (const [key, type] of headProps) {
const previous = baseProps.get(key);
Expand Down
4 changes: 2 additions & 2 deletions src/segment-schema-draft-pr/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ function mockClientOctokit(
new Error('Not Found'),
{ status: 404 },
);
return Promise.reject(error);
return await Promise.reject(error);
}
return Promise.resolve(encodedFile(text));
return await Promise.resolve(encodedFile(text));
},
);

Expand Down
6 changes: 4 additions & 2 deletions src/segment-schema-draft-pr/publish.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Octokit } from '@octokit/rest';
import { describe, expect, it, vi, type Mock } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import type { Mock } from 'vitest';

import { PROPOSAL_MARKER } from './constants';
import type { CliArgs } from './parse-args';
Expand Down Expand Up @@ -153,7 +154,8 @@ describe('publishGenerateResult', () => {
body: expect.stringContaining(PROPOSAL_MARKER),
}),
);
expect(updateComment.mock.calls[0]?.[0].body).toContain(
const [updateArgs] = updateComment.mock.calls[0] as [{ body: string }];
expect(updateArgs.body).toContain(
'https://github.com/Consensys/segment-schema/pull/9',
);
expect(createComment).not.toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions src/segment-schema-draft-pr/schema-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function isYamlMap(value: unknown): value is {
typeof value === 'object' &&
value !== null &&
'items' in value &&
Array.isArray((value as { items: unknown }).items)
Array.isArray(value.items)
);
}

Expand All @@ -198,7 +198,7 @@ function asString(value: unknown): string | undefined {
return value;
}
if (value && typeof value === 'object' && 'value' in value) {
const inner = (value as { value: unknown }).value;
const inner = value.value;
if (typeof inner === 'string') {
return inner;
}
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default defineConfig({
thresholds: {
// Raises the thresholds in this file when coverage improves.
autoUpdate: true,
branches: 41.72,
branches: 41.69,
functions: 50.63,
lines: 41.61,
statements: 41.5,
Expand Down
Loading