Skip to content

Commit

Permalink
fix(eslint): resolve require-await issues
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Nov 12, 2024
1 parent 7ecbcab commit 5759288
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 29 deletions.
37 changes: 22 additions & 15 deletions lint/linter/test-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ const processLink = async (
errors: LinkError[],
actual: string,
regexp: string | RegExp,
matchHandler: (match: RegExpMatchArray) => Promise<{
issue: string;
expected?: string;
actualLink?: string;
} | null>,
matchHandler: (match: RegExpMatchArray) =>
| Promise<{
issue: string;
expected?: string;
actualLink?: string;
} | null>
| {
issue: string;
expected?: string;
actualLink?: string;
}
| null,
): Promise<void> => {
const re = new RegExp(regexp, 'g');
let match;
Expand Down Expand Up @@ -108,7 +115,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/bugzilla\.mozilla\.org\/show_bug\.cgi\?id=(\d+)/g,
async (match) => ({
(match) => ({
issue: 'Use shortenable URL',
expected: `https://bugzil.la/${match[1]}`,
}),
Expand All @@ -119,7 +126,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/(issues\.chromium\.org)\/issues\/(\d+)/g,
async (match) => ({
(match) => ({
issue: 'Use shortenable URL',
expected: `https://crbug.com/${match[2]}`,
}),
Expand All @@ -130,7 +137,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/(bugs\.chromium\.org|code\.google\.com)\/p\/chromium\/issues\/detail\?id=(\d+)/g,
async (match) => ({
(match) => ({
issue: 'Use shortenable URL',
expected: `https://crbug.com/${match[2]}`,
}),
Expand All @@ -141,7 +148,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/(bugs\.chromium\.org|code\.google\.com)\/p\/((?!chromium)\w+)\/issues\/detail\?id=(\d+)/g,
async (match) => ({
(match) => ({
issue: 'Use shortenable URL',
expected: `https://crbug.com/${match[2]}/${match[3]}`,
}),
Expand All @@ -152,7 +159,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/chromium\.googlesource\.com\/chromium\/src\/\+\/([\w\d]+)/g,
async (match) => ({
(match) => ({
issue: 'Use shortenable URL',
expected: `https://crrev.com/${match[1]}`,
}),
Expand All @@ -174,7 +181,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/bugs\.webkit\.org\/show_bug\.cgi\?id=(\d+)/g,
async (match) => ({
(match) => ({
issue: 'Use shortenable URL',
expected: `https://webkit.org/b/${match[1]}`,
}),
Expand All @@ -185,7 +192,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/(\w*\s?)<a href='((https?):\/\/(bugzil\.la|crbug\.com|webkit\.org\/b)\/(\d+))'>(.*?)<\/a>/g,
async (match) => {
(match) => {
const [, before, url, protocol, domain, bugId, linkText] = match;

if (protocol !== 'https') {
Expand Down Expand Up @@ -226,7 +233,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/(https?):\/\/((?:[a-z][a-z0-9-]*\.)*)?developer.mozilla.org\/(.*?)(?=["'\s])/g,
async (match) => {
(match) => {
const [, protocol, subdomain, path] = match;

if (protocol !== 'https') {
Expand Down Expand Up @@ -266,7 +273,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/https?:\/\/developer.microsoft.com\/(\w\w-\w\w)\/(.*?)(?=["'\s])/g,
async (match) => ({
(match) => ({
issue: 'Use non-localized Microsoft Developer URL',
expected: `https://developer.microsoft.com/${match[2]}`,
}),
Expand All @@ -276,7 +283,7 @@ export const processData = async (rawData: string): Promise<LinkError[]> => {
errors,
actual,
/<a href='([^'>]+)'>((?:.(?<!<\/a>))*.)<\/a>/g,
async (match) => {
(match) => {
if (new URL(match[1]).hostname === null) {
return {
issue: 'Include hostname in URL',
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const getDiff = (
* @param date The starting date to query pull requests from
* @returns The changes from all of the pull requests
*/
export const getChanges = async (date: string): Promise<Changes> => {
export const getChanges = (date: string): Changes => {
const progressBar = new cliProgress.SingleBar(
{},
cliProgress.Presets.shades_classic,
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ const main = async () => {
);

console.log(chalk`{blue Getting statistics...}`);
const stats = await getStats(lastVersion, thisVersion, lastVersionDate);
const stats = getStats(lastVersion, thisVersion, lastVersionDate);

console.log(chalk`{blue Getting lists of added/removed features...}`);
const changes = await getChanges(lastVersionDate);
const changes = getChanges(lastVersionDate);

console.log(chalk`{blue Updating release notes...}`);
const notes = getNotes(thisVersion, changes, stats, versionBump);
Expand Down
8 changes: 4 additions & 4 deletions scripts/release/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { exec, queryPRs, githubAPI } from './utils.js';
* Get stargazers for the repository
* @returns The number of stargazer
*/
const stargazers = async (): Promise<number> => {
const stargazers = (): number => {
const json = githubAPI('');
return json.stargazers_count;
};
Expand Down Expand Up @@ -137,16 +137,16 @@ export const formatStats = (details: Stats): string =>
* @param startDate The date of the last release
* @returns The release statistics
*/
export const getStats = async (
export const getStats = (
start: string,
end: string,
startDate: string,
): Promise<Stats> => ({
): Stats => ({
start,
end,
...stats(start),
releaseContributors: getReleaseContributors(startDate).size,
totalContributors: contributors(),
stars: await stargazers(),
stars: stargazers(),
features: countFeatures(),
});
2 changes: 1 addition & 1 deletion scripts/release/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const getRefDate = (ref: string, querySafe = false): string => {
* Wait for a key press
* @returns Once the key is pressed, return
*/
export const keypress = async () => {
export const keypress = (): Promise<true> => {
process.stdin.setRawMode(true);
return new Promise((resolve) =>
process.stdin.once('data', () => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-browser-releases/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const getFutureReleaseDate = async (release, releaseScheduleURL) => {
* @returns The URL of the release notes or the empty string if not found
* Throws a string in case of error
*/
const getReleaseNotesURL = async (status, fullRelease, date) => {
const getReleaseNotesURL = (status, fullRelease, date) => {
// If the status isn't stable, do not give back any release notes.
if (status !== 'Stable') {
return '';
Expand Down Expand Up @@ -270,7 +270,7 @@ export const updateEdgeReleases = async (options) => {
// Get the release notes
let releaseNotesURL = '';
try {
releaseNotesURL = await getReleaseNotesURL(
releaseNotesURL = getReleaseNotesURL(
value,
data[value].fullVersion,
data[value].versionDate,
Expand Down
8 changes: 4 additions & 4 deletions scripts/update-browser-releases/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { ReleaseStatement } from '../../types/types.js';
* @param version release version
* @returns The URL of the release notes or the empty string if not found
*/
const getFirefoxReleaseNotesURL = async (version) => {
const getFirefoxReleaseNotesURL = (version) => {
if (version === '1') {
return 'https://website-archive.mozilla.org/www.mozilla.org/firefox_releasenotes/en-US/firefox/releases/1.0.html';
}
Expand Down Expand Up @@ -54,7 +54,7 @@ export const updateFirefoxReleases = async (options) => {
const trainInfo = await fetch(`${options.firefoxScheduleURL}${value}`);
const train = await trainInfo.json();

releaseNotesURL = await getFirefoxReleaseNotesURL(
releaseNotesURL = getFirefoxReleaseNotesURL(
parseFloat(train.version).toString(),
);

Expand All @@ -72,7 +72,7 @@ export const updateFirefoxReleases = async (options) => {
stableRelease = parseFloat(key);
}
});
releaseNotesURL = await getFirefoxReleaseNotesURL(stableRelease);
releaseNotesURL = getFirefoxReleaseNotesURL(stableRelease);

data[value] = {};
data[value].version = stableRelease;
Expand Down Expand Up @@ -186,7 +186,7 @@ export const updateFirefoxReleases = async (options) => {
'planned',
'Gecko',
train.release?.substring(0, 10), // Remove the time part
await getFirefoxReleaseNotesURL(planned),
getFirefoxReleaseNotesURL(planned),
planned,
);
}
Expand Down

0 comments on commit 5759288

Please sign in to comment.