diff --git a/dprint.json b/dprint.json index a6ee10293e33..cb951c4626c1 100644 --- a/dprint.json +++ b/dprint.json @@ -9,7 +9,7 @@ "./node_modules/dprint-plugin-yaml/plugin.wasm" ], "includes": [ - "**/*.{svelte,css,gql,yml,ts,js}", + "**/*.{svelte,css,gql,yml,ts,js,tsx}", "dprint.json" ], "useTabs": true, diff --git a/eslint.config.js b/eslint.config.js index ceabd9169a04..4a8ccbf609ff 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -303,7 +303,7 @@ export default defineConfig([ }, }, { - files: ['**/*.js', '**/*.ts'], + files: ['**/*.js', '**/*.ts', '**/*.tsx'], // TODO: Use global `/flat` config rules: eslintConfigPrettier.rules, }, diff --git a/source/feature-manager.tsx b/source/feature-manager.tsx index f4927b592ed1..f9e83b3073c3 100644 --- a/source/feature-manager.tsx +++ b/source/feature-manager.tsx @@ -12,9 +12,7 @@ import {messageRuntime} from 'webext-msg'; import asyncForEach from './helpers/async-for-each.js'; import bisectFeatures from './helpers/bisect.js'; import {catchErrors, disableErrorLogging} from './helpers/errors.js'; -import { - getFeatureId, listenToAjaxedLoad, log, shortcutMap, -} from './helpers/feature-helpers.js'; +import {getFeatureId, listenToAjaxedLoad, log, shortcutMap} from './helpers/feature-helpers.js'; import {isFeaturePrivate, type RunConditions, shouldFeatureRun} from './helpers/feature-utils.js'; import { applyStyleHotfixes, diff --git a/source/features/actionable-pr-view-file.tsx b/source/features/actionable-pr-view-file.tsx index f08e48e40773..92f15eac32dc 100644 --- a/source/features/actionable-pr-view-file.tsx +++ b/source/features/actionable-pr-view-file.tsx @@ -1,13 +1,11 @@ import delegate, {type DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import { - $, $closest, $optional, elementExists, -} from 'select-dom'; +import {$, $closest, $optional, elementExists} from 'select-dom'; import features from '../feature-manager.js'; import {getBranches} from '../github-helpers/pr-branches.js'; -import observe from '../helpers/selector-observer.js'; import {frame} from '../helpers/dom-utils.js'; +import observe from '../helpers/selector-observer.js'; /** Rebuilds the "View file" link to point to the head repo and its branch instead of the base repo and the commit */ function rebuildFileLink(viewFileLink: HTMLAnchorElement, filePath: string): void { @@ -31,7 +29,7 @@ function getFilePath(fileHeader: HTMLElement): string { return ( // Tooltip doesn't exist if the file wasn't renamed renamedTooltip?.textContent.split(' renamed to ')[1] - ?? fileNameElement.textContent + ?? fileNameElement.textContent ).replaceAll(/\u200E|\u200F/g, '').trim(); } diff --git a/source/features/batch-mark-files-as-viewed.tsx b/source/features/batch-mark-files-as-viewed.tsx index 984851fdb2ef..99dbe0606df5 100644 --- a/source/features/batch-mark-files-as-viewed.tsx +++ b/source/features/batch-mark-files-as-viewed.tsx @@ -1,9 +1,7 @@ import {onAbort} from 'abort-utils'; import delegate, {type DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import { - $, $$, $closest, elementExists, -} from 'select-dom'; +import {$, $$, $closest, elementExists} from 'select-dom'; import features from '../feature-manager.js'; import showToast from '../github-helpers/toast.js'; diff --git a/source/features/clean-conversation-sidebar.tsx b/source/features/clean-conversation-sidebar.tsx index 66036a83f838..c975901c346c 100644 --- a/source/features/clean-conversation-sidebar.tsx +++ b/source/features/clean-conversation-sidebar.tsx @@ -2,9 +2,7 @@ import './clean-conversation-sidebar.css'; import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import { - $, $closest, $optional, elementExists, -} from 'select-dom'; +import {$, $closest, $optional, elementExists} from 'select-dom'; import features from '../feature-manager.js'; import {removeTextNodeContaining} from '../helpers/dom-utils.js'; @@ -93,7 +91,7 @@ async function cleanSidebarLegacy(sidebar: HTMLElement): Promise { if (assignYourself) { removeTextNodeContaining(assignYourself.previousSibling!, 'No one—'); $('[aria-label="Select assignees"] summary').append( - – {assignYourself}, + – {assignYourself}, ); $closest('.discussion-sidebar-item', assignees).classList.add('rgh-clean-sidebar'); } @@ -122,7 +120,7 @@ async function cleanSidebarLegacy(sidebar: HTMLElement): Promise { if (createBranchLink && !openWorkspaceButton) { createBranchLink.classList.add('Link--muted', 'Link--inTextBlock'); $('[aria-label="Link issues"] summary').append( - – {createBranchLink}, + – {createBranchLink}, ); } diff --git a/source/features/clean-repo-sidebar.tsx b/source/features/clean-repo-sidebar.tsx index 8ad36eda4d06..d78cd297b8c6 100644 --- a/source/features/clean-repo-sidebar.tsx +++ b/source/features/clean-repo-sidebar.tsx @@ -2,9 +2,7 @@ import './clean-repo-sidebar.css'; import domLoaded from 'dom-loaded'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import { - $, $closest, $optional, elementExists, -} from 'select-dom'; +import {$, $closest, $optional, elementExists} from 'select-dom'; import features from '../feature-manager.js'; import {buildRepoUrl} from '../github-helpers/index.js'; diff --git a/source/features/clean-repo-tabs.tsx b/source/features/clean-repo-tabs.tsx index 89b4b05c3868..fc139461df08 100644 --- a/source/features/clean-repo-tabs.tsx +++ b/source/features/clean-repo-tabs.tsx @@ -1,9 +1,7 @@ import React from 'dom-chef'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import { - $, $closest, $optional, countElements, -} from 'select-dom'; +import {$, $closest, $optional, countElements} from 'select-dom'; import {CachedFunction} from 'webext-storage-cache'; import features from '../feature-manager.js'; diff --git a/source/features/clear-pr-merge-commit-message.tsx b/source/features/clear-pr-merge-commit-message.tsx index 8bdef08f7ab0..2c854510d6ed 100644 --- a/source/features/clear-pr-merge-commit-message.tsx +++ b/source/features/clear-pr-merge-commit-message.tsx @@ -51,8 +51,8 @@ async function clear(messageField: HTMLTextAreaElement): Promise { rel="noreferrer" > cleared - - {' '}by Refined GitHub. + {' '} + by Refined GitHub.

), diff --git a/source/features/closing-remarks.tsx b/source/features/closing-remarks.tsx index f29c1fd5b904..2f6456ce2758 100644 --- a/source/features/closing-remarks.tsx +++ b/source/features/closing-remarks.tsx @@ -10,12 +10,12 @@ import waitForPrMerge from '../github-events/on-pr-merge.js'; import createBanner, {type BannerProps} from '../github-helpers/banner.js'; import {userHasPushAccess} from '../github-helpers/get-user-permission.js'; import {buildRepoUrl, getRepo, isRefinedGitHubRepo} from '../github-helpers/index.js'; +import {commentBoxHashPr} from '../github-helpers/selectors.js'; import TimelineItem from '../github-helpers/timeline-item.js'; import attachElement from '../helpers/attach-element.js'; import fetchDom from '../helpers/fetch-dom.js'; import observe from '../helpers/selector-observer.js'; import {getReleases} from './releases-tab.js'; -import {commentBoxHashPr} from '../github-helpers/selectors.js'; function excludeNightliesAndJunk({textContent}: HTMLAnchorElement): boolean { // https://github.com/refined-github/refined-github/issues/7206 @@ -108,8 +108,8 @@ async function addReleaseBanner(text: string | JSX.Element): Promise { } async function init(signal: AbortSignal): Promise { - const mergeCommit - = $(`.TimelineItem.js-details-container.Details a[href^="/${getRepo()!.nameWithOwner}/commit/" i] > code`).textContent; + const mergeCommit = + $(`.TimelineItem.js-details-container.Details a[href^="/${getRepo()!.nameWithOwner}/commit/" i] > code`).textContent; const tagName = await firstTag.get(mergeCommit); if (tagName) { diff --git a/source/features/cmd-enter.tsx b/source/features/cmd-enter.tsx index 0da91271cef4..2b7fc32b9c5e 100644 --- a/source/features/cmd-enter.tsx +++ b/source/features/cmd-enter.tsx @@ -2,8 +2,8 @@ import delegate, {type DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; import {$, $optional} from 'select-dom'; -import {legacyCommentField} from '../github-helpers/selectors.js'; import features from '../feature-manager.js'; +import {legacyCommentField} from '../github-helpers/selectors.js'; function handleKeyDown(event: DelegateEvent): void { if (event.key !== 'Enter' || !(event.metaKey || event.ctrlKey)) { diff --git a/source/features/collapsible-content-button.tsx b/source/features/collapsible-content-button.tsx index b85ed1c13035..d089961b14b0 100644 --- a/source/features/collapsible-content-button.tsx +++ b/source/features/collapsible-content-button.tsx @@ -64,7 +64,7 @@ function append(container: HTMLElement): void { // TODO: ensure it's added only once before both `table-input` and `collapsible-content-button` const divider = $([ '[data-component="ActionBar.VerticalDivider"]', // React component - '.ActionBar-divider', // Still used in gists, PRs, etc + '.ActionBar-divider', // Still used in gists, PRs, etc ], container).cloneNode(true); Object.assign(divider.style, { diff --git a/source/features/comments-time-machine-links.tsx b/source/features/comments-time-machine-links.tsx index 1fb16ede07f0..3de1f7c43adc 100644 --- a/source/features/comments-time-machine-links.tsx +++ b/source/features/comments-time-machine-links.tsx @@ -128,8 +128,7 @@ function addDropdownLink(menu: HTMLElement, timestamp: string): void { } function addDropdownLinkReact({delegateTarget: delegate}: DelegateEvent): void { - const timestamp - = $('relative-time[datetime]', $closest('[class^="Box"]', delegate)).attributes.datetime.value; + const timestamp = $('relative-time[datetime]', $closest('[class^="Box"]', delegate)).attributes.datetime.value; const menuItemList = $('[class^="prc-ActionList-ActionList"]'); const menuItem = $('[class^="prc-ActionList-ActionListItem"]', menuItemList).cloneNode(true); @@ -166,10 +165,13 @@ async function init(signal: AbortSignal): Promise { } // The timestamp of main review comments isn't in their header but in the timeline event above #5423 - const timestamp = $('relative-time', $closest([ - '.js-comment:not([id^="pullrequestreview-"])', - '.js-timeline-item', - ], menu)) + const timestamp = $( + 'relative-time', + $closest([ + '.js-comment:not([id^="pullrequestreview-"])', + '.js-timeline-item', + ], menu), + ) .attributes .datetime .value; diff --git a/source/features/conventional-commits.tsx b/source/features/conventional-commits.tsx index 32c9cdca22fe..34601227c16a 100644 --- a/source/features/conventional-commits.tsx +++ b/source/features/conventional-commits.tsx @@ -27,7 +27,6 @@ function renderLabelInCommitTitle(commitTitleElement: HTMLElement): void { // Skip commits that are _only_ "ci:" without anything else. Rare but it would be confusing to show just the label commit.raw === textNode.textContent && !commitTitleElement.nextElementSibling - // Ensure that the element contains only plain text, not stuff like && commitTitleElement.childElementCount < 1 ) { @@ -38,7 +37,6 @@ function renderLabelInCommitTitle(commitTitleElement: HTMLElement): void { {commit.type} , - // Keep scope outside because that's how they're rendered in release notes as well commit.scope ? {commit.scope} : '', ); diff --git a/source/features/conversation-activity-filter.tsx b/source/features/conversation-activity-filter.tsx index 76ba0140a923..71025c88e80f 100644 --- a/source/features/conversation-activity-filter.tsx +++ b/source/features/conversation-activity-filter.tsx @@ -7,21 +7,15 @@ import CheckIcon from 'octicons-plain-react/Check'; import EyeIcon from 'octicons-plain-react/Eye'; import EyeClosedIcon from 'octicons-plain-react/EyeClosed'; import TriangleDownIcon from 'octicons-plain-react/TriangleDown'; -import { - $, - $$, - $$optional, - $closest, - elementExists, -} from 'select-dom'; +import {$, $$, $$optional, $closest, elementExists} from 'select-dom'; import features from '../feature-manager.js'; import getCommentAuthor from '../github-helpers/get-comment-author.js'; import {registerHotkey} from '../github-helpers/hotkey.js'; import delay from '../helpers/delay.js'; import {isSmallDevice, wrap} from '../helpers/dom-utils.js'; -import observe from '../helpers/selector-observer.js'; import onetime from '../helpers/onetime.js'; +import observe from '../helpers/selector-observer.js'; const minorFixesIssuePages = [ 'https://github.com/refined-github/refined-github/issues/3686', diff --git a/source/features/cross-deleted-pr-branches.tsx b/source/features/cross-deleted-pr-branches.tsx index c25367b77c30..6da3be0fa003 100644 --- a/source/features/cross-deleted-pr-branches.tsx +++ b/source/features/cross-deleted-pr-branches.tsx @@ -2,9 +2,7 @@ import './cross-deleted-pr-branches.css'; import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import { - $, $$, $closest, $optional, lastElementOptional, -} from 'select-dom'; +import {$, $$, $closest, $optional, lastElementOptional} from 'select-dom'; import features from '../feature-manager.js'; import {wrap} from '../helpers/dom-utils.js'; diff --git a/source/features/deep-reblame.tsx b/source/features/deep-reblame.tsx index b483709a90f4..f92fed9d4e1c 100644 --- a/source/features/deep-reblame.tsx +++ b/source/features/deep-reblame.tsx @@ -5,9 +5,7 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; import mem from 'memoize'; import VersionsIcon from 'octicons-plain-react/Versions'; -import { - $, $$, $closest, $optional, -} from 'select-dom'; +import {$, $$, $closest, $optional} from 'select-dom'; import features from '../feature-manager.js'; import api from '../github-helpers/api.js'; diff --git a/source/features/default-branch-button.tsx b/source/features/default-branch-button.tsx index 3474f5f6476d..2d32ec20b30a 100644 --- a/source/features/default-branch-button.tsx +++ b/source/features/default-branch-button.tsx @@ -80,7 +80,6 @@ async function add(branchSelector: HTMLElement): Promise { // https://github.com/refined-github/refined-github/issues/6554 // Inlined listener because `mouseenter` is too heavy for `delegate` onMouseEnter={updateUrl} - // Don't enable AJAX on this behavior because we need a full page reload to drop the button, same reason as above #6554 // data-turbo-frame="repo-content-turbo-frame" > diff --git a/source/features/embed-gist-inline.tsx b/source/features/embed-gist-inline.tsx index 7d357805bd9b..a2cca15c9913 100644 --- a/source/features/embed-gist-inline.tsx +++ b/source/features/embed-gist-inline.tsx @@ -16,14 +16,14 @@ type GistData = { // Fetch via background.js due to CORB policies. Also memoize to avoid multiple requests. const fetchGist = mem( - async (url: string): Promise => - messageRuntime({fetchJson: `${url}.json`}), + async (url: string): Promise => messageRuntime({fetchJson: `${url}.json`}), ); -const isOnlyChild = (link: HTMLAnchorElement): boolean => link.textContent.trim() === link.parentElement!.textContent.trim(); +const isOnlyChild = (link: HTMLAnchorElement): boolean => + link.textContent.trim() === link.parentElement!.textContent.trim(); async function embedGist(link: HTMLAnchorElement): Promise { - const info = (loading); + const info = (loading); link.after(info); try { @@ -39,7 +39,8 @@ async function embedGist(link: HTMLAnchorElement): Promise { } else { const container =
; container.attachShadow({mode: 'open'}).append( -