Skip to content
Merged
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
25 changes: 25 additions & 0 deletions src/fetch/index.t-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,28 @@ import JSONT from "../json";
}
})();
}

{
type Spec = DefineApiEndpoints<{
"/vectorize/indexes/:indexName": {
get: {
resBody: {
200: { prop: string };
};
};
};
}>;
(async () => {
const CLOUDFLARE_API_HOST = "https://api.cloudflare.com/client/v4";
const getCloudflareAccountEndpoint = (accountId: string) =>
`${CLOUDFLARE_API_HOST}/accounts/${accountId}` as const;
const basePath = getCloudflareAccountEndpoint("accountId");
const f = fetch as FetchT<typeof basePath, Spec>;
{
const res = await f(`${basePath}/vectorize/indexes/indexA`, {});
if (res.ok) {
(await res.json()).prop;
}
}
})();
Comment on lines +199 to +211
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant block statement.

The block statement within the async IIFE does not serve any purpose and can be safely removed to simplify the code.

Apply this diff to remove the redundant block statement:

  (async () => {
    const CLOUDFLARE_API_HOST = "https://api.cloudflare.com/client/v4";
    const getCloudflareAccountEndpoint = (accountId: string) =>
      `${CLOUDFLARE_API_HOST}/accounts/${accountId}` as const;
    const basePath = getCloudflareAccountEndpoint("accountId");
    const f = fetch as FetchT<typeof basePath, Spec>;
-    {
      const res = await f(`${basePath}/vectorize/indexes/indexA`, {});
      if (res.ok) {
        (await res.json()).prop;
      }
-    }
  })();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(async () => {
const CLOUDFLARE_API_HOST = "https://api.cloudflare.com/client/v4";
const getCloudflareAccountEndpoint = (accountId: string) =>
`${CLOUDFLARE_API_HOST}/accounts/${accountId}` as const;
const basePath = getCloudflareAccountEndpoint("accountId");
const f = fetch as FetchT<typeof basePath, Spec>;
{
const res = await f(`${basePath}/vectorize/indexes/indexA`, {});
if (res.ok) {
(await res.json()).prop;
}
}
})();
(async () => {
const CLOUDFLARE_API_HOST = "https://api.cloudflare.com/client/v4";
const getCloudflareAccountEndpoint = (accountId: string) =>
`${CLOUDFLARE_API_HOST}/accounts/${accountId}` as const;
const basePath = getCloudflareAccountEndpoint("accountId");
const f = fetch as FetchT<typeof basePath, Spec>;
const res = await f(`${basePath}/vectorize/indexes/indexA`, {});
if (res.ok) {
(await res.json()).prop;
}
})();
Tools
Biome

[error] 202-208: This block statement doesn't serve any purpose and can be safely removed.

Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.

(lint/complexity/noUselessLoneBlockStatements)

}