Skip to content

Commit 44091ec

Browse files
committed
chore: fix the oxlint violations in src
1 parent ce699f6 commit 44091ec

16 files changed

Lines changed: 34 additions & 117 deletions

‎oxlint-suppressions.json‎

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -329,111 +329,16 @@
329329
"count": 1
330330
}
331331
},
332-
"src/cache-utils.ts": {
333-
"jsdoc/require-returns": {
334-
"count": 1
335-
}
336-
},
337-
"src/changelog-check.mts": {
338-
"typescript/explicit-function-return-type": {
339-
"count": 1
340-
},
341-
"typescript/no-unsafe-argument": {
342-
"count": 1
343-
},
344-
"typescript/no-unsafe-member-access": {
345-
"count": 1
346-
}
347-
},
348-
"src/error-utils.ts": {
349-
"typescript/explicit-function-return-type": {
350-
"count": 1
351-
}
352-
},
353-
"src/fs-utils.ts": {
354-
"typescript/no-unsafe-return": {
355-
"count": 1
356-
}
357-
},
358332
"src/get-review-metrics.ts": {
359-
"jsdoc/require-returns": {
360-
"count": 1
361-
},
362-
"typescript/explicit-function-return-type": {
363-
"count": 1
364-
},
365333
"typescript/no-unnecessary-type-assertion": {
366334
"count": 1
367-
},
368-
"typescript/no-unsafe-argument": {
369-
"count": 1
370-
},
371-
"typescript/no-unsafe-assignment": {
372-
"count": 1
373-
},
374-
"typescript/no-unsafe-member-access": {
375-
"count": 1
376-
}
377-
},
378-
"src/github/octokit.ts": {
379-
"jsdoc/require-returns": {
380-
"count": 1
381-
}
382-
},
383-
"src/scripts/count-references-to-contributor-docs/cli.ts": {
384-
"typescript/explicit-function-return-type": {
385-
"count": 1
386-
}
387-
},
388-
"src/segment-schema-draft-pr/analytics-model.ts": {
389-
"unicorn/no-useless-undefined": {
390-
"count": 1
391-
}
392-
},
393-
"src/segment-schema-draft-pr/apply-changes.ts": {
394-
"import/consistent-type-specifier-style": {
395-
"count": 1
396-
},
397-
"typescript/explicit-function-return-type": {
398-
"count": 1
399-
},
400-
"typescript/no-unnecessary-type-assertion": {
401-
"count": 2
402-
}
403-
},
404-
"src/segment-schema-draft-pr/cli.ts": {
405-
"import/consistent-type-specifier-style": {
406-
"count": 1
407-
}
408-
},
409-
"src/segment-schema-draft-pr/diff-models.ts": {
410-
"typescript/no-unsafe-assignment": {
411-
"count": 6
412-
}
413-
},
414-
"src/segment-schema-draft-pr/generate.test.ts": {
415-
"typescript/return-await": {
416-
"count": 2
417335
}
418336
},
419337
"src/segment-schema-draft-pr/github-output.ts": {
420338
"node/no-sync": {
421339
"count": 1
422340
}
423341
},
424-
"src/segment-schema-draft-pr/publish.test.ts": {
425-
"import/consistent-type-specifier-style": {
426-
"count": 1
427-
},
428-
"typescript/no-unsafe-member-access": {
429-
"count": 1
430-
}
431-
},
432-
"src/segment-schema-draft-pr/schema-index.ts": {
433-
"typescript/no-unnecessary-type-assertion": {
434-
"count": 2
435-
}
436-
},
437342
"yarn.config.cjs": {
438343
"import/unambiguous": {
439344
"count": 1

‎src/cache-utils.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const DEFAULT_MAX_AGE = 60 * 60 * 1000; // 1 hour
2828
* considered "fresh". Affects subsequent calls: if `fetchOrPopulateFileCache`
2929
* is called again with the same file path within the duration specified here,
3030
* `getDataToCache` will not get called again, otherwise it will.
31+
* @returns The cached data if it is fresh, otherwise the newly generated data.
3132
*/
3233
export async function fetchOrPopulateFileCache<Data extends Json>({
3334
filePath,

‎src/changelog-check.mts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ async function getChangedPackages(
529529
/**
530530
* Main function to run the changelog check.
531531
*/
532-
async function main() {
532+
async function main(): Promise<void> {
533533
// Parse command-line arguments
534534
const args = process.argv.slice(2);
535535

@@ -623,7 +623,7 @@ async function main() {
623623
}
624624
}
625625

626-
main().catch((error) => {
626+
main().catch((error: { message: string }) => {
627627
logError(error.message);
628628
// eslint-disable-next-line n/no-process-exit
629629
process.exit(1);

‎src/error-utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function isErrorWithCode(error: unknown): error is { code: string } {
4141
* something throwable).
4242
* @returns A new error object.
4343
*/
44-
export function wrapError(message: string, originalError: unknown) {
44+
export function wrapError(message: string, originalError: unknown): Error {
4545
if (isError(originalError)) {
4646
const error: Error & { code?: string } = new Error(message, {
4747
cause: originalError,

‎src/fs-utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function readJsonFile<Value extends Json>(
5454
): Promise<Value> {
5555
try {
5656
const content = await readFile(filePath);
57-
return JSON.parse(content);
57+
return JSON.parse(content) as Value;
5858
} catch (error) {
5959
throw wrapError(`Could not read JSON file '${filePath}'`, error);
6060
}

‎src/get-review-metrics.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const pullRequests: {
3333
* Get all review comments for the repository specified.
3434
*
3535
* @param page - The page number of results to fetch.
36+
* @returns Whether the last page of results has been reached.
3637
*/
37-
async function getAllComments(page = 1) {
38+
async function getAllComments(page = 1): Promise<boolean> {
3839
const { data } = await octokit.rest.pulls.listReviewCommentsForRepo({
3940
owner: 'MetaMask',
4041
repo: 'metamask-extension',
@@ -75,7 +76,9 @@ async function execute(): Promise<void> {
7576
});
7677
const pulls = Object.keys(pullRequests);
7778
for (const pull of pulls) {
78-
const { data } = await octokit.request(pull);
79+
const { data } = (await octokit.request(pull)) as {
80+
data: { user: { login: string } };
81+
};
7982
if (TEAM.includes(data.user.login) && pullRequests[pull]) {
8083
(pullRequests[pull] as PullRequestData).isInternal = true;
8184
}

‎src/github/octokit.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getRequiredEnvironmentVariable } from '../env-utils';
99
*
1010
* @param args - The same arguments that
1111
* [`graphql`](https://github.com/octokit/graphql.js) takes.
12+
* @returns The response data of the GraphQL request.
1213
*/
1314
export async function graphql<ResponseData>(
1415
...args: Parameters<typeof octokitGraphql>

‎src/scripts/count-references-to-contributor-docs/cli.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ main().catch(console.error);
3030
* This script counts the number of references to the `contributor-docs` repo
3131
* across a selection of MetaMask repositories.
3232
*/
33-
async function main() {
33+
async function main(): Promise<void> {
3434
const spinner = ora();
3535

3636
console.log(

‎src/segment-schema-draft-pr/analytics-model.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function extractAnalyticsModel(
2525
filePath: string,
2626
sourceText: string,
2727
config: PlatformConfig,
28-
sharedCatalog: EventCatalog | undefined = undefined,
28+
sharedCatalog?: EventCatalog | undefined,
2929
): AnalyticsModel {
3030
const sourceFile = ts.createSourceFile(
3131
filePath,

‎src/segment-schema-draft-pr/apply-changes.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import type { Document as YamlDocument } from 'yaml';
55

66
import { TODO_DESCRIPTION } from './constants';
77
import { uniqueKebabSlug } from './names';
8-
import { defaultPropKeys, type SchemaIndex } from './schema-index';
8+
import { defaultPropKeys } from './schema-index';
9+
import type { SchemaIndex } from './schema-index';
910
import type {
1011
AnalyticsChangeSet,
1112
IntendedFileChange,
@@ -126,7 +127,7 @@ function newEventNames(
126127
const names: string[] = [];
127128
const seen = new Set<string>();
128129

129-
const consider = (eventName: string) => {
130+
const consider = (eventName: string): void => {
130131
if (seen.has(eventName) || index.eventsByName.has(eventName)) {
131132
return;
132133
}
@@ -454,7 +455,7 @@ function yamlKey(value: unknown): string | undefined {
454455
return value;
455456
}
456457
if (value && typeof value === 'object' && 'value' in value) {
457-
const inner = (value as { value: unknown }).value;
458+
const inner = value.value;
458459
if (typeof inner === 'string') {
459460
return inner;
460461
}
@@ -476,7 +477,7 @@ function isYamlMap(value: unknown): value is {
476477
typeof value === 'object' &&
477478
value !== null &&
478479
'items' in value &&
479-
Array.isArray((value as { items: unknown }).items)
480+
Array.isArray(value.items)
480481
);
481482
}
482483

0 commit comments

Comments
 (0)