Skip to content

Commit

Permalink
refactor(ts-ignore): use 'ts-expect-error' to keep track when annotat…
Browse files Browse the repository at this point in the history
…ion is not necessary anymore
  • Loading branch information
oscard0m committed Mar 10, 2022
1 parent dded0bb commit acf03b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/index.ts
@@ -1,4 +1,4 @@
// @ts-ignore
// @ts-expect-error
import BottleneckLight from "bottleneck/light";
import { Octokit } from "@octokit/core";
import { OctokitOptions } from "@octokit/core/dist-types/types.d";
Expand All @@ -21,7 +21,7 @@ const triggersNotification = regex.test.bind(regex);

const groups: Groups = {};

// @ts-ignore
// @ts-expect-error
const createGroups = function (Bottleneck, common) {
groups.global = new Bottleneck.Group({
id: "octokit-global",
Expand Down Expand Up @@ -109,7 +109,7 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) {

const events = {};
const emitter = new Bottleneck.Events(events);
// @ts-ignore
// @ts-expect-error
events.on(
"secondary-limit",
isUsingDeprecatedOnAbuseLimitHandler
Expand All @@ -121,14 +121,14 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) {
}
: state.onSecondaryRateLimit
);
// @ts-ignore
// @ts-expect-error
events.on("rate-limit", state.onRateLimit);
// @ts-ignore
// @ts-expect-error
events.on("error", (e) =>
octokit.log.warn("Error in throttling-plugin limit handler", e)
);

// @ts-ignore
// @ts-expect-error
state.retryLimiter.on("failed", async function (error, info) {
const options = info.args[info.args.length - 1];
const { pathname } = new URL(options.url, "http://github.test");
Expand Down Expand Up @@ -189,7 +189,7 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) {

if (wantRetry) {
options.request.retryCount++;
// @ts-ignore
// @ts-expect-error
return retryAfter * state.retryAfterBaseValue;
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/route-matcher.ts
@@ -1,16 +1,16 @@
// @ts-ignore
// @ts-expect-error
export function routeMatcher(paths) {
// EXAMPLE. For the following paths:
/* [
"/orgs/{org}/invitations",
"/repos/{owner}/{repo}/collaborators/{username}"
] */

// @ts-ignore
// @ts-expect-error
const regexes = paths.map((path) =>
path
.split("/")
// @ts-ignore
// @ts-expect-error
.map((c) => (c.startsWith("{") ? "(?:.+?)" : c))
.join("/")
);
Expand All @@ -20,7 +20,7 @@ export function routeMatcher(paths) {
'/repos/(?:.+?)/(?:.+?)/collaborators/(?:.+?)'
] */

// @ts-ignore
// @ts-expect-error
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`;
// 'regex' would contain:
/*
Expand Down
8 changes: 4 additions & 4 deletions src/wrap-request.ts
@@ -1,11 +1,11 @@
const noop = () => Promise.resolve();

// @ts-ignore
// @ts-expect-error
export function wrapRequest(state, request, options) {
return state.retryLimiter.schedule(doRequest, state, request, options);
}

// @ts-ignore
// @ts-expect-error
async function doRequest(state, request, options) {
const isWrite = options.method !== "GET" && options.method !== "HEAD";
const { pathname } = new URL(options.url, "http://github.test");
Expand All @@ -17,7 +17,7 @@ async function doRequest(state, request, options) {
if (state.clustering) {
// Remove a job from Redis if it has not completed or failed within 60s
// Examples: Node process terminated, client disconnected, etc.
// @ts-ignore
// @ts-expect-error
jobOptions.expiration = 1000 * 60;
}

Expand All @@ -43,7 +43,7 @@ async function doRequest(state, request, options) {

if (
res.data.errors != null &&
// @ts-ignore
// @ts-expect-error
res.data.errors.some((error) => error.type === "RATE_LIMITED")
) {
const error = Object.assign(new Error("GraphQL Rate Limit Exceeded"), {
Expand Down

0 comments on commit acf03b4

Please sign in to comment.