Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
},
},

// TODO: Use global `/flat` config. Currently limited to svelte files because dprint is applied to their JS

Check warning on line 268 in eslint.config.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected 'todo' comment: 'TODO: Use global `/flat` config....'
rules: eslintConfigPrettier.rules,
},
{
Expand Down Expand Up @@ -303,8 +303,8 @@
},
},
{
files: ['**/*.js', '**/*.ts'],
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
// TODO: Use global `/flat` config

Check warning on line 307 in eslint.config.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected 'todo' comment: 'TODO: Use global `/flat` config'
rules: eslintConfigPrettier.rules,
},
]);
4 changes: 1 addition & 3 deletions source/feature-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 3 additions & 5 deletions source/features/actionable-pr-view-file.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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();
}

Expand Down
4 changes: 1 addition & 3 deletions source/features/batch-mark-files-as-viewed.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
8 changes: 3 additions & 5 deletions source/features/clean-conversation-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -93,7 +91,7 @@ async function cleanSidebarLegacy(sidebar: HTMLElement): Promise<void> {
if (assignYourself) {
removeTextNodeContaining(assignYourself.previousSibling!, 'No one—');
$('[aria-label="Select assignees"] summary').append(
<span style={{fontWeight: 'normal'}}> – {assignYourself}</span>,
<span style={{fontWeight: 'normal'}}>– {assignYourself}</span>,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Still broken. Did you have a patch @SunsetTechuila?

);
$closest('.discussion-sidebar-item', assignees).classList.add('rgh-clean-sidebar');
}
Expand Down Expand Up @@ -122,7 +120,7 @@ async function cleanSidebarLegacy(sidebar: HTMLElement): Promise<void> {
if (createBranchLink && !openWorkspaceButton) {
createBranchLink.classList.add('Link--muted', 'Link--inTextBlock');
$('[aria-label="Link issues"] summary').append(
<span style={{fontWeight: 'normal'}}> – {createBranchLink}</span>,
<span style={{fontWeight: 'normal'}}>– {createBranchLink}</span>,
);
}

Expand Down
4 changes: 1 addition & 3 deletions source/features/clean-repo-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions source/features/clean-repo-tabs.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions source/features/clear-pr-merge-commit-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ async function clear(messageField: HTMLTextAreaElement): Promise<void> {
rel="noreferrer"
>
cleared
</a>
{' '}by Refined GitHub. <button type="button" className="btn-link" onClick={toggleUndoRedo}>Undo</button>
</a>{' '}
by Refined GitHub. <button type="button" className="btn-link" onClick={toggleUndoRedo}>Undo</button>
</p>
</div>
),
Expand Down
6 changes: 3 additions & 3 deletions source/features/closing-remarks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -108,8 +108,8 @@ async function addReleaseBanner(text: string | JSX.Element): Promise<void> {
}

async function init(signal: AbortSignal): Promise<void> {
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) {
Expand Down
2 changes: 1 addition & 1 deletion source/features/cmd-enter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyboardEvent>): void {
if (event.key !== 'Enter' || !(event.metaKey || event.ctrlKey)) {
Expand Down
2 changes: 1 addition & 1 deletion source/features/collapsible-content-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
14 changes: 8 additions & 6 deletions source/features/comments-time-machine-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -166,10 +165,13 @@ async function init(signal: AbortSignal): Promise<void> {
}

// 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;
Expand Down
2 changes: 0 additions & 2 deletions source/features/conventional-commits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>
&& commitTitleElement.childElementCount < 1
) {
Expand All @@ -38,7 +37,6 @@ function renderLabelInCommitTitle(commitTitleElement: HTMLElement): void {
<span className="IssueLabel hx_IssueLabel mr-2" rgh-conventional-commits={commit.rawType}>
{commit.type}
</span>,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🤷‍♂️ not a big deal though

// Keep scope outside because that's how they're rendered in release notes as well
commit.scope ? <span className="color-fg-muted">{commit.scope}</span> : '',
);
Expand Down
10 changes: 2 additions & 8 deletions source/features/conversation-activity-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 1 addition & 3 deletions source/features/cross-deleted-pr-branches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions source/features/deep-reblame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion source/features/default-branch-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ async function add(branchSelector: HTMLElement): Promise<void> {
// 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"
>
Expand Down
11 changes: 6 additions & 5 deletions source/features/embed-gist-inline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<GistData> =>
messageRuntime({fetchJson: `${url}.json`}),
async (url: string): Promise<GistData> => 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<void> {
const info = <em> (loading)</em>;
const info = <em>(loading)</em>;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will revert

link.after(info);

try {
Expand All @@ -39,7 +39,8 @@ async function embedGist(link: HTMLAnchorElement): Promise<void> {
} else {
const container = <div />;
container.attachShadow({mode: 'open'}).append(
<style>{`
<style>
{`
.gist .gist-data {
max-height: 16em;
overflow-y: auto;
Expand Down
1 change: 0 additions & 1 deletion source/features/fit-textareas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function init(signal: AbortSignal): void {
'textarea' + not(
// `anchored-position`: Exclude PR review box because it's in a `position:fixed` container; The scroll HAS to appear within the fixed element.
'anchored-position #pull_request_review_body',

// `#pull_request_body_ghost`: Special textarea that GitHub just matches to the visible textarea
'#pull_request_body_ghost',
'#pull_request_body_ghost_ruler',
Expand Down
2 changes: 1 addition & 1 deletion source/features/global-conversation-list-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './global-conversation-list-filters.css';

import React from 'dom-chef';
import * as pageDetect from 'github-url-detection';
import {elementExists, $$} from 'select-dom';
import {$$, elementExists} from 'select-dom';

import features from '../feature-manager.js';
import SearchQuery from '../github-helpers/search-query.js';
Expand Down
2 changes: 1 addition & 1 deletion source/features/hide-inactive-deployments.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as pageDetect from 'github-url-detection';
import {elementExists, $$optional} from 'select-dom';
import {$$optional, elementExists} from 'select-dom';

import features from '../feature-manager.js';

Expand Down
4 changes: 1 addition & 3 deletions source/features/hide-low-quality-comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import './hide-low-quality-comments.css';
import delegate, {type DelegateEvent} from 'delegate-it';
import React from 'dom-chef';
import * as pageDetect from 'github-url-detection';
import {
$, $$, $closest, $closestOptional, $optional, countElements, elementExists,
} from 'select-dom';
import {$, $$, $closest, $closestOptional, $optional, countElements, elementExists} from 'select-dom';

import features from '../feature-manager.js';
import delay from '../helpers/delay.js';
Expand Down
4 changes: 1 addition & 3 deletions source/features/highest-rated-comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import * as pageDetect from 'github-url-detection';
import mem from 'memoize';
import ArrowDownIcon from 'octicons-plain-react/ArrowDown';
import CheckCircleFillIcon from 'octicons-plain-react/CheckCircleFill';
import {
$, $$, $$optional, $closest, $optional,
} from 'select-dom';
import {$, $$, $$optional, $closest, $optional} from 'select-dom';

import features from '../feature-manager.js';
import isLowQualityComment from '../helpers/is-low-quality-comment.js';
Expand Down
4 changes: 2 additions & 2 deletions source/features/highlight-non-default-base-branch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function buildQuery(prsByRepo: Map<string, Pr[]>): string {
nameWithOwner
defaultBranchRef {name}
${
prs.map(pr => `
prs.map(pr => `
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Still an issue, but not a big one

${api.escapeKey('pr', pr.number)}: pullRequest(number: ${pr.number}) {
ref: baseRef {id}
refName: baseRefName
}
`).join('\n')
}
}
}
`;
}).join('\n');
Expand Down
6 changes: 2 additions & 4 deletions source/features/keyboard-navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as pageDetect from 'github-url-detection';
import {
$$, $closestOptional, $optional, elementExists,
} from 'select-dom';
import {$$, $closestOptional, $optional, elementExists} from 'select-dom';

import features from '../feature-manager.js';
import {isEditable} from '../helpers/dom-utils.js';
Expand Down Expand Up @@ -35,7 +33,7 @@ function runShortcuts(event: KeyboardEvent): void {
.filter(element =>
element.classList.contains('js-minimizable-comment-group')
? !isCommentGroupMinimized(element)
: true,
: true
);

// `j` goes to the next item, `k` goes back an item
Expand Down
4 changes: 2 additions & 2 deletions source/features/link-to-changelog-file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type FileType = {
type: string;
};

const changelogFiles
= /^(?:changelog|news|changes|history|release|whatsnew)(?:\.(?:mdx?|mkdn?|mdwn|mdown|markdown|litcoffee|txt|rst))?$/i;
const changelogFiles =
/^(?:changelog|news|changes|history|release|whatsnew)(?:\.(?:mdx?|mkdn?|mdwn|mdown|markdown|litcoffee|txt|rst))?$/i;
function findChangelogName(files: string[]): string | false {
return files.find(name => changelogFiles.test(name)) ?? false;
}
Expand Down
4 changes: 1 addition & 3 deletions source/features/linkify-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import * as pageDetect from 'github-url-detection';
import {$$optional} from 'select-dom';

import features from '../feature-manager.js';
import {
codeElementsSelector, linkifiedUrlClass, linkifyIssues, linkifyUrls,
} from '../github-helpers/dom-formatters.js';
import {codeElementsSelector, linkifiedUrlClass, linkifyIssues, linkifyUrls} from '../github-helpers/dom-formatters.js';
import {getRepo} from '../github-helpers/index.js';
import observe from '../helpers/selector-observer.js';

Expand Down
Loading
Loading