diff options
author | 2021-07-07 18:44:32 +0700 | |
---|---|---|
committer | 2021-07-07 18:44:32 +0700 | |
commit | 93899eebabea8626587cadc37b028a3c48f39228 (patch) | |
tree | a59dddeea1c6bc76b45c02ef88bba43e2800e684 /source/github-helpers/api.ts | |
parent | 40ed43f6cdd23178b6c6ee7c04a5731cb2342012 (diff) | |
download | refined-github-93899eebabea8626587cadc37b028a3c48f39228.tar.gz refined-github-93899eebabea8626587cadc37b028a3c48f39228.tar.zst refined-github-93899eebabea8626587cadc37b028a3c48f39228.zip |
Lint: Enable `comma-dangle` (#4545)
Diffstat (limited to 'source/github-helpers/api.ts')
-rw-r--r-- | source/github-helpers/api.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts index c2fa63eb..0c0abc64 100644 --- a/source/github-helpers/api.ts +++ b/source/github-helpers/api.ts @@ -99,16 +99,16 @@ const v3defaults: GHRestApiOptions = { ignoreHTTPStatus: false, method: 'GET', body: undefined, - json: true + json: true, }; const v4defaults: GHGraphQLApiOptions = { - allowErrors: false + allowErrors: false, }; export const v3 = mem(async ( query: string, - options: GHRestApiOptions = v3defaults + options: GHRestApiOptions = v3defaults, ): Promise<RestResponse> => { const {ignoreHTTPStatus, method, body, headers, json} = {...v3defaults, ...options}; const {personalToken} = await settings; @@ -125,8 +125,8 @@ export const v3 = mem(async ( 'User-Agent': 'Refined GitHub', Accept: 'application/vnd.github.v3+json', ...headers, - ...personalToken && {Authorization: `token ${personalToken}`} - } + ...personalToken && {Authorization: `token ${personalToken}`}, + }, }); const textContent = await response.text(); const apiResponse = json ? JSON.parse(textContent) : {textContent}; @@ -135,18 +135,18 @@ export const v3 = mem(async ( return Object.assign(apiResponse, { httpStatus: response.status, headers: response.headers, - ok: response.ok + ok: response.ok, }); } throw await getError(apiResponse); }, { - cacheKey: JSON.stringify + cacheKey: JSON.stringify, }); export const v3paginated = async function * ( query: string, - options?: GHRestApiOptions + options?: GHRestApiOptions, ): AsyncGenerator<AsyncReturnType<typeof v3>> { while (true) { // eslint-disable-next-line no-await-in-loop @@ -164,7 +164,7 @@ export const v3paginated = async function * ( export const v4 = mem(async ( query: string, - options: GHGraphQLApiOptions = v4defaults + options: GHGraphQLApiOptions = v4defaults, ): Promise<AnyObject> => { const personalToken = await expectToken(); @@ -177,17 +177,17 @@ export const v4 = mem(async ( const response = await fetch(api4, { headers: { 'User-Agent': 'Refined GitHub', - Authorization: `bearer ${personalToken}` + Authorization: `bearer ${personalToken}`, }, method: 'POST', - body: JSON.stringify({query: `{${query}}`}) + body: JSON.stringify({query: `{${query}}`}), }); const apiResponse: GraphQLResponse = await response.json(); const { data = {}, - errors = [] + errors = [], } = apiResponse; if (errors.length > 0 && !options.allowErrors) { @@ -200,7 +200,7 @@ export const v4 = mem(async ( throw await getError(apiResponse as JsonObject); }, { - cacheKey: JSON.stringify + cacheKey: JSON.stringify, }); export async function getError(apiResponse: JsonObject): Promise<RefinedGitHubAPIError> { @@ -211,13 +211,13 @@ export async function getError(apiResponse: JsonObject): Promise<RefinedGitHubAP 'Rate limit exceeded.', personalToken ? 'It may be time for a walk! 🍃 🌞' : - 'Set your token in the options or take a walk! 🍃 🌞' + 'Set your token in the options or take a walk! 🍃 🌞', ); } if (apiResponse.message === 'Bad credentials') { return new RefinedGitHubAPIError( - 'The token seems to be incorrect or expired. Update it in the options.' + 'The token seems to be incorrect or expired. Update it in the options.', ); } @@ -226,7 +226,7 @@ export async function getError(apiResponse: JsonObject): Promise<RefinedGitHubAP personalToken ? 'Ensure that your token has access to this repo.' : 'Maybe adding a token in the options will fix this issue.', - JSON.stringify(apiResponse, null, '\t') // Beautify + JSON.stringify(apiResponse, null, '\t'), // Beautify ); error.response = apiResponse; return error; |