diff options
author | 2020-11-18 19:55:59 -0500 | |
---|---|---|
committer | 2020-11-18 18:55:59 -0600 | |
commit | a935456acab0c7bdc021829e18ce20230e18c752 (patch) | |
tree | e61eed13a433381ba223a4ca962e904c8740fc91 | |
parent | cab33f6f47c4eef0a3bc793f2004767f34b6abe9 (diff) | |
download | refined-github-20.11.19.tar.gz refined-github-20.11.19.tar.zst refined-github-20.11.19.zip |
Lint (#3723)20.11.19
36 files changed, 77 insertions, 83 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f961a25d..779bf90f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,6 @@ name: Bug report about: Create a report to help us improve labels: bug - --- <!-- @@ -10,7 +9,7 @@ Thanks for reporting a bug! ⛰ 1. Make sure the bug is caused by Refined GitHub. Try disabling the extension first. 2. Include a full URL where the bug appears. -3. Include a screenshot/gif +3. Include a screenshot/gif Issues without a URL/screenshot will be closed --> diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 6fea5920..9b7c7fbf 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,6 @@ name: Feature request about: Suggest an idea for Refined GitHub labels: enhancement, under discussion - --- <!-- diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aad088ea..f56f2af0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,6 @@ on: - 'test/*' jobs: - Security: runs-on: ubuntu-latest steps: diff --git a/.xo-config.js b/.xo-config.js index e57d6ffe..83fe6fda 100644 --- a/.xo-config.js +++ b/.xo-config.js @@ -20,7 +20,7 @@ module.exports = { 'ava/no-ignored-test-files': 'off', '@typescript-eslint/no-extra-non-null-assertion': 'error', - '@typescript-eslint/consistent-type-definitions':'error', + '@typescript-eslint/consistent-type-definitions': 'error', '@typescript-eslint/explicit-function-return-type': [ 'error', { diff --git a/source/features/clean-conversation-filters.tsx b/source/features/clean-conversation-filters.tsx index 9134390a..b7e4e0d7 100644 --- a/source/features/clean-conversation-filters.tsx +++ b/source/features/clean-conversation-filters.tsx @@ -5,11 +5,11 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepo, getRepoGQL} from '../github-helpers'; +import {getRepo} from '../github-helpers'; const hasAnyProjects = cache.function(async (): Promise<boolean> => { const {repository, organization} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { projects { totalCount } } organization(login: "${getRepo()!.owner}") { diff --git a/source/features/clone-branch.tsx b/source/features/clone-branch.tsx index 8e15d99d..2373ff86 100644 --- a/source/features/clone-branch.tsx +++ b/source/features/clone-branch.tsx @@ -10,11 +10,10 @@ import * as textFieldEdit from 'text-field-edit'; import features from '.'; import * as api from '../github-helpers/api'; import LoadingIcon from '../github-helpers/icon-loading'; -import {getRepoGQL} from '../github-helpers'; const getBranchBaseSha = async (branchName: string): Promise<string> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { ref(qualifiedName: "${branchName}") { target { oid diff --git a/source/features/comments-time-machine-links.tsx b/source/features/comments-time-machine-links.tsx index 9a8727aa..3b16758f 100644 --- a/source/features/comments-time-machine-links.tsx +++ b/source/features/comments-time-machine-links.tsx @@ -8,11 +8,11 @@ import features from '.'; import * as api from '../github-helpers/api'; import GitHubURL from '../github-helpers/github-url'; import {appendBefore} from '../helpers/dom-utils'; -import {buildRepoURL, isPermalink, getRepoGQL} from '../github-helpers'; +import {buildRepoURL, isPermalink} from '../github-helpers'; async function updateURLtoDatedSha(url: GitHubURL, date: string): Promise<void> { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { ref(qualifiedName: "${url.branch}") { target { ... on Commit { diff --git a/source/features/deep-reblame.tsx b/source/features/deep-reblame.tsx index 637ab008..08f96012 100644 --- a/source/features/deep-reblame.tsx +++ b/source/features/deep-reblame.tsx @@ -10,12 +10,11 @@ import features from '.'; import * as api from '../github-helpers/api'; import GitHubURL from '../github-helpers/github-url'; import LoadingIcon from '../github-helpers/icon-loading'; -import {getRepoGQL} from '../github-helpers'; import looseParseInt from '../helpers/loose-parse-int'; const getPullRequestBlameCommit = mem(async (commit: string, prNumber: number, currentFilename: string): Promise<string> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { file: object(expression: "${commit}:${currentFilename}") { id } @@ -64,7 +63,7 @@ async function redirectToBlameCommit(event: delegate.Event<MouseEvent, HTMLAncho blameElement.blur(); // Hide tooltip after click, it’s shown on :focus const blameHunk = blameElement.closest('.blame-hunk')!; - const prNumber = looseParseInt(select('.issue-link', blameHunk)!.textContent!); + const prNumber = looseParseInt(select('.issue-link', blameHunk)!); const prCommit = select<HTMLAnchorElement>('a.message', blameHunk)!.pathname.split('/').pop()!; const blameUrl = new GitHubURL(location.href); diff --git a/source/features/expand-all-hidden-comments.tsx b/source/features/expand-all-hidden-comments.tsx index d15c440b..9d379711 100644 --- a/source/features/expand-all-hidden-comments.tsx +++ b/source/features/expand-all-hidden-comments.tsx @@ -17,7 +17,7 @@ function handleAltClick(event: delegate.Event<MouseEvent, HTMLButtonElement>): v const form = event.delegateTarget.form!; const hiddenItemsCount = Math.min( 200, // https://github.com/sindresorhus/refined-github/issues/2931 - looseParseInt(form.textContent!) + looseParseInt(form) ); const url = new URL(form.action); diff --git a/source/features/highlight-non-default-base-branch.tsx b/source/features/highlight-non-default-base-branch.tsx index fb4dee82..40626e99 100644 --- a/source/features/highlight-non-default-base-branch.tsx +++ b/source/features/highlight-non-default-base-branch.tsx @@ -5,8 +5,8 @@ import PullRequestIcon from 'octicon/git-pull-request.svg'; import features from '.'; import * as api from '../github-helpers/api'; +import {buildRepoURL} from '../github-helpers'; import getDefaultBranch from '../github-helpers/get-default-branch'; -import {getRepoGQL, buildRepoURL} from '../github-helpers'; interface BranchInfo { baseRef: string; @@ -15,7 +15,7 @@ interface BranchInfo { function buildQuery(issueIds: string[]): string { return ` - repository(${getRepoGQL()}) { + repository() { ${issueIds.map(id => ` ${id}: pullRequest(number: ${id.replace(/\D/g, '')}) { baseRef {id} diff --git a/source/features/latest-tag-button.tsx b/source/features/latest-tag-button.tsx index a48937d4..3ddc6e8f 100644 --- a/source/features/latest-tag-button.tsx +++ b/source/features/latest-tag-button.tsx @@ -12,7 +12,7 @@ import pluralize from '../helpers/pluralize'; import GitHubURL from '../github-helpers/github-url'; import {groupButtons} from '../github-helpers/group-buttons'; import getDefaultBranch from '../github-helpers/get-default-branch'; -import {buildRepoURL, getCurrentBranch, getRepoGQL, getLatestVersionTag, getRepo} from '../github-helpers'; +import {buildRepoURL, getCurrentBranch, getLatestVersionTag, getRepo} from '../github-helpers'; interface RepoPublishState { latestTag: string | false; @@ -21,7 +21,7 @@ interface RepoPublishState { const getRepoPublishState = cache.function(async (): Promise<RepoPublishState> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { refs(first: 20, refPrefix: "refs/tags/", orderBy: { field: TAG_COMMIT_DATE, direction: DESC diff --git a/source/features/list-prs-for-file.tsx b/source/features/list-prs-for-file.tsx index cc459cc1..24bcd8e7 100644 --- a/source/features/list-prs-for-file.tsx +++ b/source/features/list-prs-for-file.tsx @@ -7,7 +7,7 @@ import PullRequestIcon from 'octicon/git-pull-request.svg'; import features from '.'; import * as api from '../github-helpers/api'; import getDefaultBranch from '../github-helpers/get-default-branch'; -import {buildRepoURL, getRepoGQL, getRepo} from '../github-helpers'; +import {buildRepoURL, getRepo} from '../github-helpers'; function getPRUrl(prNumber: number): string { return buildRepoURL('pull', prNumber, 'files'); @@ -53,7 +53,7 @@ function getSingleButton(prNumber: number, _?: number, prs?: number[]): HTMLElem */ const getPrsByFile = cache.function(async (): Promise<Record<string, number[]>> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { pullRequests( first: 25, states: OPEN, diff --git a/source/features/mark-merge-commits-in-list.tsx b/source/features/mark-merge-commits-in-list.tsx index d0d9ec8a..e6cbea71 100644 --- a/source/features/mark-merge-commits-in-list.tsx +++ b/source/features/mark-merge-commits-in-list.tsx @@ -6,11 +6,10 @@ import PullRequestIcon from 'octicon/git-pull-request.svg'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepoGQL} from '../github-helpers'; const filterMergeCommits = async (commits: string[]): Promise<string[]> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { ${commits.map((commit: string) => ` ${api.escapeKey(commit)}: object(expression: "${commit}") { ... on Commit { diff --git a/source/features/next-scheduled-github-action.tsx b/source/features/next-scheduled-github-action.tsx index 30dbbb20..c7f50bce 100644 --- a/source/features/next-scheduled-github-action.tsx +++ b/source/features/next-scheduled-github-action.tsx @@ -7,11 +7,11 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepoGQL, getRepo} from '../github-helpers'; +import {getRepo} from '../github-helpers'; const getScheduledWorkflows = cache.function(async (): Promise<Record<string, string> | false> => { const {repository: {object: {entries: workflows}}} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { object(expression: "HEAD:.github/workflows") { ... on Tree { entries { diff --git a/source/features/pinned-issues-update-time.tsx b/source/features/pinned-issues-update-time.tsx index 0cc428e9..5bcd6844 100644 --- a/source/features/pinned-issues-update-time.tsx +++ b/source/features/pinned-issues-update-time.tsx @@ -5,8 +5,8 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; +import {getRepo} from '../github-helpers'; import looseParseInt from '../helpers/loose-parse-int'; -import {getRepoGQL, getRepo} from '../github-helpers'; interface IssueInfo { updatedAt: string; @@ -14,7 +14,7 @@ interface IssueInfo { const getLastUpdated = cache.function(async (issueNumbers: number[]): Promise<Record<string, IssueInfo>> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { ${issueNumbers.map(number => ` ${api.escapeKey(number)}: issue(number: ${number}) { updatedAt @@ -30,7 +30,7 @@ const getLastUpdated = cache.function(async (issueNumbers: number[]): Promise<Re }); function getPinnedIssueNumber(pinnedIssue: HTMLElement): number { - return looseParseInt(select('.opened-by', pinnedIssue)!.firstChild!.textContent!); + return looseParseInt(select('.opened-by', pinnedIssue)!.firstChild!); } async function init(): Promise<void | false> { diff --git a/source/features/pr-commit-lines-changed.tsx b/source/features/pr-commit-lines-changed.tsx index 9bd9379a..c5d7ac10 100644 --- a/source/features/pr-commit-lines-changed.tsx +++ b/source/features/pr-commit-lines-changed.tsx @@ -6,11 +6,10 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; import pluralize from '../helpers/pluralize'; -import {getRepoGQL} from '../github-helpers'; const getCommitChanges = cache.function(async (commit: string): Promise<[additions: number, deletions: number]> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { object(expression: "${commit}") { ... on Commit { additions diff --git a/source/features/pr-filters.tsx b/source/features/pr-filters.tsx index 9c88f9a2..9fbfd10a 100644 --- a/source/features/pr-filters.tsx +++ b/source/features/pr-filters.tsx @@ -8,7 +8,7 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepoGQL, getRepo} from '../github-helpers'; +import {getRepo} from '../github-helpers'; const reviewsFilterSelector = '#reviews-select-menu'; @@ -64,7 +64,7 @@ function addDraftFilter({delegateTarget: reviewsFilter}: delegate.Event): void { const hasChecks = cache.function(async (): Promise<boolean> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { head: object(expression: "HEAD") { ... on Commit { history(first: 10) { diff --git a/source/features/quick-review-buttons.tsx b/source/features/quick-review-buttons.tsx index 08fd85ad..4bfee13e 100644 --- a/source/features/quick-review-buttons.tsx +++ b/source/features/quick-review-buttons.tsx @@ -74,7 +74,7 @@ function init(): false | void { // This will prevent submission when clicking "Comment" and "Request changes" without entering a comment and no other review comments are pending delegate<HTMLButtonElement>(form, 'button', 'click', ({delegateTarget: {value}}) => { - const pendingComments = looseParseInt(select('.js-reviews-toggle .js-pending-review-comment-count')!.textContent!); + const pendingComments = looseParseInt(select('.js-reviews-toggle .js-pending-review-comment-count')!); const submissionRequiresComment = pendingComments === 0 && (value === 'reject' || value === 'comment'); select('#pull_request_review_body', form)!.toggleAttribute('required', submissionRequiresComment); }); diff --git a/source/features/recently-pushed-branches-enhancements.tsx b/source/features/recently-pushed-branches-enhancements.tsx index 3c97d856..9ee72de9 100644 --- a/source/features/recently-pushed-branches-enhancements.tsx +++ b/source/features/recently-pushed-branches-enhancements.tsx @@ -7,7 +7,7 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import {getRepo} from '../github-helpers'; -const fragmentURL = `/${getRepo()!.nameWithOwner}/show_partial?partial=tree%2Frecently_touched_branches_list`; +const fragmentURL = `/${getRepo()?.nameWithOwner!}/show_partial?partial=tree%2Frecently_touched_branches_list`; const selector = `[data-url='${fragmentURL}' i], [src='${fragmentURL}' i]`; // Ajaxed pages will load a new fragment on every ajaxed load, but we only really need the one generated on the first load diff --git a/source/features/release-download-count.tsx b/source/features/release-download-count.tsx index d65479bf..7108069c 100644 --- a/source/features/release-download-count.tsx +++ b/source/features/release-download-count.tsx @@ -6,7 +6,6 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepoGQL} from '../github-helpers'; interface Asset { name: string; @@ -15,7 +14,7 @@ interface Asset { type Tag = Record<string, Asset[]>; async function getAssetsForTag(tags: string[]): Promise<Tag> { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { ${tags.map(tag => ` ${api.escapeKey(tag)}: release(tagName:"${tag}") { releaseAssets(first: 100) { diff --git a/source/features/releases-tab.tsx b/source/features/releases-tab.tsx index 855fbda6..b1e7812b 100644 --- a/source/features/releases-tab.tsx +++ b/source/features/releases-tab.tsx @@ -10,7 +10,7 @@ import * as api from '../github-helpers/api'; import looseParseInt from '../helpers/loose-parse-int'; import {appendBefore} from '../helpers/dom-utils'; import {createDropdownItem} from './more-dropdown'; -import {buildRepoURL, getRepoGQL, getRepo} from '../github-helpers'; +import {buildRepoURL, getRepo} from '../github-helpers'; const getCacheKey = (): string => `releases-count:${getRepo()!.nameWithOwner}`; @@ -31,7 +31,7 @@ function parseCountFromDom(): number { async function fetchFromApi(): Promise<number> { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { refs(refPrefix: "refs/tags/") { totalCount } @@ -136,11 +136,7 @@ async function init(): Promise<false | void> { // Update "selected" tab mark if (pageDetect.isReleasesOrTags()) { - const selected = select('.reponav-item.selected'); - if (selected) { - selected.classList.remove('js-selected-navigation-item', 'selected'); - } - + select('.reponav-item.selected')?.classList.remove('js-selected-navigation-item', 'selected'); releasesTab.classList.add('js-selected-navigation-item', 'selected'); releasesTab.dataset.selectedLinks = 'repo_releases'; // Required for ajaxLoad } diff --git a/source/features/repo-age.tsx b/source/features/repo-age.tsx index aafe6712..c02f08cc 100644 --- a/source/features/repo-age.tsx +++ b/source/features/repo-age.tsx @@ -8,7 +8,7 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepoGQL, getRepo} from '../github-helpers'; +import {getRepo} from '../github-helpers'; const dateFormatter = new Intl.DateTimeFormat('en-US', { year: 'numeric', @@ -18,7 +18,7 @@ const dateFormatter = new Intl.DateTimeFormat('en-US', { const getRepoAge = async (commitSha: string, commitsCount: number): Promise<[committedDate: string, resourcePath: string]> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { defaultBranchRef { target { ... on Commit { @@ -44,7 +44,7 @@ const getRepoAge = async (commitSha: string, commitsCount: number): Promise<[com const getFirstCommit = cache.function(async (): Promise<[committedDate: string, resourcePath: string]> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { defaultBranchRef { target { ... on Commit { diff --git a/source/features/restore-file.tsx b/source/features/restore-file.tsx index 44b881f1..67170630 100644 --- a/source/features/restore-file.tsx +++ b/source/features/restore-file.tsx @@ -8,7 +8,7 @@ import features from '.'; import * as api from '../github-helpers/api'; import fetchDom from '../helpers/fetch-dom'; import postForm from '../helpers/post-form'; -import {getConversationNumber, getRepoGQL, getCurrentBranch, getPRHeadRepo} from '../github-helpers'; +import {getConversationNumber, getCurrentBranch, getPRHeadRepo} from '../github-helpers'; function showError(menuItem: HTMLButtonElement, error: string): void { menuItem.disabled = true; @@ -22,7 +22,7 @@ This value is not consistently available on the page (appears in `/files` but no */ const getBaseReference = onetime(async (): Promise<string> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { pullRequest(number: ${getConversationNumber()!}) { baseRefOid } @@ -33,7 +33,7 @@ const getBaseReference = onetime(async (): Promise<string> => { async function getFile(filePath: string): Promise<{isTruncated: boolean; text: string} | null> { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { file: object(expression: "${await getBaseReference()}:${filePath}") { ... on Blob { isTruncated diff --git a/source/features/show-associated-branch-prs-on-fork.tsx b/source/features/show-associated-branch-prs-on-fork.tsx index 062cc3ba..049a0fa5 100644 --- a/source/features/show-associated-branch-prs-on-fork.tsx +++ b/source/features/show-associated-branch-prs-on-fork.tsx @@ -8,7 +8,7 @@ import PullRequestIcon from 'octicon/git-pull-request.svg'; import features from '.'; import * as api from '../github-helpers/api'; -import {getRepoGQL, getRepo, upperCaseFirst} from '../github-helpers'; +import {getRepo, upperCaseFirst} from '../github-helpers'; interface PullRequest { number: number; @@ -19,7 +19,7 @@ interface PullRequest { const getPullRequestsAssociatedWithBranch = cache.function(async (): Promise<Record<string, PullRequest>> => { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { refs(refPrefix: "refs/heads/", last: 100) { nodes { name diff --git a/source/features/tags-on-commits-list.tsx b/source/features/tags-on-commits-list.tsx index 2f4ebde2..31d4cc81 100644 --- a/source/features/tags-on-commits-list.tsx +++ b/source/features/tags-on-commits-list.tsx @@ -7,7 +7,7 @@ import * as pageDetect from 'github-url-detection'; import features from '.'; import * as api from '../github-helpers/api'; import {getCommitHash} from './mark-merge-commits-in-list'; -import {buildRepoURL, getRepoGQL, getRepo} from '../github-helpers'; +import {buildRepoURL, getRepo} from '../github-helpers'; type CommitTags = Record<string, string[]>; @@ -50,7 +50,7 @@ function isTagTarget(target: CommonTarget): target is TagTarget { async function getTags(lastCommit: string, after?: string): Promise<CommitTags> { const {repository} = await api.v4(` - repository(${getRepoGQL()}) { + repository() { refs( first: 100, refPrefix: "refs/tags/", diff --git a/source/features/user-profile-follower-badge.tsx b/source/features/user-profile-follower-badge.tsx index 0c5e3d29..2c5f5966 100644 --- a/source/features/user-profile-follower-badge.tsx +++ b/source/features/user-profile-follower-badge.tsx @@ -9,7 +9,7 @@ import * as api from '../github-helpers/api'; import {getUsername, getCleanPathname} from '../github-helpers'; const doesUserFollow = cache.function(async (userA: string, userB: string): Promise<boolean> => { - const {httpStatus} = await api.v3(`users/${userA}/following/${userB}`, { + const {httpStatus} = await api.v3(`/users/${userA}/following/${userB}`, { json: false, ignoreHTTPStatus: true }); diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts index 268d16d2..98b2ddf9 100644 --- a/source/github-helpers/api.ts +++ b/source/github-helpers/api.ts @@ -29,8 +29,8 @@ import mem from 'mem'; import * as pageDetect from 'github-url-detection'; import {JsonObject, AsyncReturnType} from 'type-fest'; -import optionsStorage from '../options-storage'; import {getRepo} from '.'; +import optionsStorage from '../options-storage'; interface JsonError { message: string; @@ -161,6 +161,8 @@ export const v4 = mem(async ( throw new TypeError('`query` should only be what’s inside \'query {...}\', like \'user(login: "foo") { name }\', but is \n' + query); } + query = query.replace('repository() {', () => `repository(owner: "${getRepo()!.owner}", name: "${getRepo()!.name}") {`); + const response = await fetch(api4, { headers: { 'User-Agent': 'Refined GitHub', diff --git a/source/github-helpers/dom-formatters.ts b/source/github-helpers/dom-formatters.ts index 8602b61e..1ae93211 100644 --- a/source/github-helpers/dom-formatters.ts +++ b/source/github-helpers/dom-formatters.ts @@ -14,7 +14,10 @@ export const linkifiedURLClass = 'rgh-linkified-code'; // https://github.com/sindresorhus/refined-github/issues/1305 const currentRepo = getRepo()!; -export function linkifyIssues(element: Element, options: Partial<linkifyIssuesCore.TypeDomOptions> = {}): void { +export function linkifyIssues( + element: Element, + options: Partial<linkifyIssuesCore.TypeDomOptions> = {} +): void { const linkified = linkifyIssuesCore(element.textContent!, { user: currentRepo.owner ?? '/', repository: currentRepo.name ?? '/', diff --git a/source/github-helpers/github-url.ts b/source/github-helpers/github-url.ts index 785a86c5..371b160d 100644 --- a/source/github-helpers/github-url.ts +++ b/source/github-helpers/github-url.ts @@ -33,7 +33,9 @@ export default class GitHubURL { return this; } - private disambiguateReference(ambiguousReference: string[]): {branch: string; filePath: string} { + private disambiguateReference( + ambiguousReference: string[] + ): {branch: string; filePath: string} { const branch = ambiguousReference[0]; // History pages might use search parameters const filePathFromSearch = this.searchParams.getAll('path[]').join('/'); diff --git a/source/github-helpers/group-buttons.tsx b/source/github-helpers/group-buttons.tsx index 0a0bc44d..03b23cef 100644 --- a/source/github-helpers/group-buttons.tsx +++ b/source/github-helpers/group-buttons.tsx @@ -43,4 +43,3 @@ export const groupSiblings = (button: Element): Element => { return groupButtons(siblings); }; - diff --git a/source/github-helpers/index.ts b/source/github-helpers/index.ts index 5b08dc55..b57f1fd4 100644 --- a/source/github-helpers/index.ts +++ b/source/github-helpers/index.ts @@ -51,11 +51,6 @@ export const buildRepoURL = (...pathParts: Array<string | number> & {0: string}) return [location.origin, getRepo()?.nameWithOwner, ...pathParts].join('/'); }; -export const getRepoGQL = (): string => { - const {owner, name} = getRepo()!; - return `owner: "${owner}", name: "${name}"`; -}; - export const getPRHeadRepo = (): ReturnType<typeof getRepo> => { return getRepo(select<HTMLAnchorElement>('.commit-ref.head-ref a')!); }; diff --git a/source/github-helpers/parse-backticks.tsx b/source/github-helpers/parse-backticks.tsx index a7a96723..6ec0b21b 100644 --- a/source/github-helpers/parse-backticks.tsx +++ b/source/github-helpers/parse-backticks.tsx @@ -14,9 +14,7 @@ export default function parseBackticks(description: string): DocumentFragment { // `span.sr-only` keeps the backticks copy-pastable but invisible fragment.append( <span className="sr-only">`</span>, - <code className="rgh-parse-backticks"> - {text.trim()} - </code>, + <code className="rgh-parse-backticks">{text.trim()}</code>, <span className="sr-only">`</span> ); } else if (text.length > 0) { diff --git a/source/helpers/on-element-removal.ts b/source/helpers/on-element-removal.ts index 2c94a168..27e8b3b4 100644 --- a/source/helpers/on-element-removal.ts +++ b/source/helpers/on-element-removal.ts @@ -1,15 +1,17 @@ import mem from 'mem'; -const onElementRemoval = mem(async (element: Element): Promise<void> => { - return new Promise(resolve => { - // @ts-expect-error until https://github.com/microsoft/TypeScript/issues/37861 - new ResizeObserver(([{target}], observer) => { - if (!target.isConnected) { - observer.disconnect(); - resolve(); - } - }).observe(element); - }); -}); +const onElementRemoval = mem( + async (element: Element): Promise<void> => ( + new Promise(resolve => { + // @ts-expect-error until https://github.com/microsoft/TypeScript/issues/37861 + new ResizeObserver(([{target}], observer) => { + if (!target.isConnected) { + observer.disconnect(); + resolve(); + } + }).observe(element); + }) + ) +); export default onElementRemoval; diff --git a/source/helpers/simplified-element-observer.ts b/source/helpers/simplified-element-observer.ts index 07b2f2e6..821633e3 100644 --- a/source/helpers/simplified-element-observer.ts +++ b/source/helpers/simplified-element-observer.ts @@ -19,10 +19,13 @@ export default function observeElement( return observer; } -export async function observeOneMutation(element: Element, options: MutationObserverInit = { - childList: true, - subtree: true -}): Promise<MutationRecord> { +export async function observeOneMutation( + element: Element, + options: MutationObserverInit = { + childList: true, + subtree: true + } +): Promise<MutationRecord> { return new Promise(resolve => { new MutationObserver(([change], observer) => { observer.disconnect(); diff --git a/source/helpers/smart-block-wrap.ts b/source/helpers/smart-block-wrap.ts index 10a368cd..8d51fb48 100644 --- a/source/helpers/smart-block-wrap.ts +++ b/source/helpers/smart-block-wrap.ts @@ -1,7 +1,10 @@ // Wraps string in at least two newlines on each side, // as long as the field doesn't already have them. // Code adapted from GitHub. -export default function smartBlockWrap(content: string, field: HTMLTextAreaElement): string { +export default function smartBlockWrap( + content: string, + field: HTMLTextAreaElement +): string { const before = field.value.slice(0, field.selectionStart); const after = field.value.slice(field.selectionEnd); const [whitespaceAtStart] = /\n*$/.exec(before)!; diff --git a/source/options-storage.ts b/source/options-storage.ts index d7284749..a31040ad 100644 --- a/source/options-storage.ts +++ b/source/options-storage.ts @@ -18,7 +18,6 @@ const defaults = Object.assign({ }, __featuresOptionDefaults__); // This variable is replaced at build time const migrations = [ - featureWasRenamed('sticky-conversation-sidebar', 'sticky-sidebar'), // Merged in September featureWasRenamed('add-tags-to-commits', 'tags-on-commits-list'), // Merged in October // Removed features will be automatically removed from the options as well |