diff options
237 files changed, 704 insertions, 710 deletions
diff --git a/build/readme-parser.ts b/build/readme-parser.ts index 84abcf56..aea49171 100644 --- a/build/readme-parser.ts +++ b/build/readme-parser.ts @@ -28,10 +28,10 @@ function extractDataFromMatch(match: RegExpMatchArray): FeatureMeta { } const urls: string[] = []; - const urlExtracter = (_match: string, title: string, url: string): string => { + function urlExtracter(_match: string, title: string, url: string): string { urls.push(url); return title; - }; + } const linkLessMarkdownDescription = simpleDescription.replace(/\[(.+?)]\((.+?)\)/g, urlExtracter); return { diff --git a/source/background.ts b/source/background.ts index e2ac0e04..d9d69661 100644 --- a/source/background.ts +++ b/source/background.ts @@ -5,10 +5,10 @@ import {isSafari} from 'webext-detect-page'; import {objectKeys} from 'ts-extras'; import addDomainPermissionToggle from 'webext-domain-permission-toggle'; -import optionsStorage, {isBrowserActionAPopup} from './options-storage'; -import {getRghIssueUrl} from './helpers/rgh-issue-link'; -import isDevelopmentVersion from './helpers/is-development-version'; -import getStorageBytesInUse from './helpers/used-storage'; +import optionsStorage, {isBrowserActionAPopup} from './options-storage.js'; +import {getRghIssueUrl} from './helpers/rgh-issue-link.js'; +import isDevelopmentVersion from './helpers/is-development-version.js'; +import getStorageBytesInUse from './helpers/used-storage.js'; // GHE support addDomainPermissionToggle(); diff --git a/source/feature-manager.tsx b/source/feature-manager.tsx index 17590b73..fecad60b 100644 --- a/source/feature-manager.tsx +++ b/source/feature-manager.tsx @@ -5,12 +5,12 @@ import stripIndent from 'strip-indent'; import {Promisable} from 'type-fest'; import * as pageDetect from 'github-url-detection'; -import waitFor from './helpers/wait-for'; -import onAbort from './helpers/abort-controller'; -import ArrayMap from './helpers/map-of-arrays'; -import bisectFeatures from './helpers/bisect'; -import {shouldFeatureRun} from './github-helpers'; -import optionsStorage, {RGHOptions} from './options-storage'; +import waitFor from './helpers/wait-for.js'; +import onAbort from './helpers/abort-controller.js'; +import ArrayMap from './helpers/map-of-arrays.js'; +import bisectFeatures from './helpers/bisect.js'; +import {shouldFeatureRun} from './github-helpers/index.js'; +import optionsStorage, {RGHOptions} from './options-storage.js'; import { applyStyleHotfixes, getStyleHotfix, @@ -19,7 +19,7 @@ import { updateHotfixes, updateLocalStrings, _, -} from './helpers/hotfix'; +} from './helpers/hotfix.js'; type BooleanFunction = () => boolean; export type CallerFunction = (callback: VoidFunction, signal: AbortSignal) => void | Promise<void> | Deinit; @@ -59,7 +59,7 @@ const {version} = browser.runtime.getManifest(); const currentFeatureControllers = new ArrayMap<FeatureID, AbortController>(); -const logError = (url: string, error: unknown): void => { +function logError(url: string, error: unknown): void { const id = getFeatureID(url); const message = error instanceof Error ? error.message : String(error); @@ -87,7 +87,7 @@ const logError = (url: string, error: unknown): void => { console.log('🔍 Search issue', searchIssueUrl.href); console.log('🚨 Report issue', newIssueUrl.href); console.groupEnd(); -}; +} const log = { info: console.log, @@ -157,7 +157,7 @@ function castArray<Item>(value: Item | Item[]): Item[] { return Array.isArray(value) ? value : [value]; } -const setupPageLoad = async (id: FeatureID, config: InternalRunConfig): Promise<void> => { +async function setupPageLoad(id: FeatureID, config: InternalRunConfig): Promise<void> { const {asLongAs, include, exclude, init, additionalListeners, onlyAdditionalListeners} = config; if (!shouldFeatureRun({asLongAs, include, exclude})) { @@ -196,7 +196,7 @@ const setupPageLoad = async (id: FeatureID, config: InternalRunConfig): Promise< onAbort(featureController, ...castArray(deinit)); } } -}; +} const shortcutMap = new Map<string, string>(); @@ -213,17 +213,17 @@ type FeatureHelper = { selector: string; }; -const getIdentifiers = (url: string): FeatureHelper => { +function getIdentifiers(url: string): FeatureHelper { const id = getFeatureID(url); return { id, class: 'rgh-' + id, selector: '.rgh-' + id, }; -}; +} /** Register a new feature */ -const add = async (url: string, ...loaders: FeatureLoader[]): Promise<void> => { +async function add(url: string, ...loaders: FeatureLoader[]): Promise<void> { const id = getFeatureID(url); /* Feature filtering and running */ const options = await globalReady; @@ -238,15 +238,7 @@ const add = async (url: string, ...loaders: FeatureLoader[]): Promise<void> => { for (const loader of loaders) { // Input defaults and validation const { - shortcuts = {}, - asLongAs, - include, - exclude, - init, - awaitDomReady = false, - deduplicate = false, - onlyAdditionalListeners = false, - additionalListeners = [], + shortcuts = {}, asLongAs, include, exclude, init, awaitDomReady = false, deduplicate = false, onlyAdditionalListeners = false, additionalListeners = [], } = loader; if (include?.length === 0) { @@ -279,9 +271,9 @@ const add = async (url: string, ...loaders: FeatureLoader[]): Promise<void> => { } }); } -}; +} -const addCssFeature = async (url: string, include?: BooleanFunction[]): Promise<void> => { +async function addCssFeature(url: string, include?: BooleanFunction[]): Promise<void> { const id = getFeatureID(url); void add(id, { include, @@ -289,14 +281,14 @@ const addCssFeature = async (url: string, include?: BooleanFunction[]): Promise< document.documentElement.classList.add('rgh-' + id); }, }); -}; +} -const unload = (featureUrl: string): void => { +function unload(featureUrl: string): void { const id = getFeatureID(featureUrl); for (const controller of currentFeatureControllers.get(id) ?? []) { controller.abort(); } -}; +} document.addEventListener('turbo:render', () => { for (const feature of currentFeatureControllers.values()) { diff --git a/source/features/action-used-by-link.tsx b/source/features/action-used-by-link.tsx index e7e8944d..04ec9269 100644 --- a/source/features/action-used-by-link.tsx +++ b/source/features/action-used-by-link.tsx @@ -3,8 +3,8 @@ import select from 'select-dom'; import {SearchIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import selectHas from '../helpers/select-has'; +import features from '../feature-manager.js'; +import selectHas from '../helpers/select-has.js'; function init(): void { const actionRepo = selectHas('aside a:has(.octicon-repo)')! diff --git a/source/features/align-issue-labels.tsx b/source/features/align-issue-labels.tsx index 4a1c5a09..e346bc24 100644 --- a/source/features/align-issue-labels.tsx +++ b/source/features/align-issue-labels.tsx @@ -1,6 +1,6 @@ import './align-issue-labels.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [pageDetect.isIssueOrPRList]); diff --git a/source/features/archive-forks-link.tsx b/source/features/archive-forks-link.tsx index 82b72538..75fe7a75 100644 --- a/source/features/archive-forks-link.tsx +++ b/source/features/archive-forks-link.tsx @@ -1,9 +1,9 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import {buildRepoURL} from '../github-helpers'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import {buildRepoURL} from '../github-helpers/index.js'; function addLinkToBanner(banner: HTMLElement): void { if (banner.lastChild!.textContent!.includes('repository has been archived')) { diff --git a/source/features/avoid-accidental-submissions.tsx b/source/features/avoid-accidental-submissions.tsx index c45d37ff..2aa93d13 100644 --- a/source/features/avoid-accidental-submissions.tsx +++ b/source/features/avoid-accidental-submissions.tsx @@ -3,8 +3,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import {isMac} from '../github-helpers'; -import features from '../feature-manager'; +import {isMac} from '../github-helpers/index.js'; +import features from '../feature-manager.js'; function onKeyDown(event: DelegateEvent<KeyboardEvent, HTMLInputElement>): void { const field = event.delegateTarget; diff --git a/source/features/batch-mark-files-as-viewed.tsx b/source/features/batch-mark-files-as-viewed.tsx index edba3b46..dc691b1b 100644 --- a/source/features/batch-mark-files-as-viewed.tsx +++ b/source/features/batch-mark-files-as-viewed.tsx @@ -3,11 +3,11 @@ import * as pageDetect from 'github-url-detection'; import debounceFn from 'debounce-fn'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import clickAll from '../helpers/click-all'; -import showToast from '../github-helpers/toast'; -import getItemsBetween from '../helpers/get-items-between'; -import onAbort from '../helpers/abort-controller'; +import features from '../feature-manager.js'; +import clickAll from '../helpers/click-all.js'; +import showToast from '../github-helpers/toast.js'; +import getItemsBetween from '../helpers/get-items-between.js'; +import onAbort from '../helpers/abort-controller.js'; let previousFile: HTMLElement | undefined; let runningBatch = false; diff --git a/source/features/bugs-tab.tsx b/source/features/bugs-tab.tsx index deba7c54..223cd3da 100644 --- a/source/features/bugs-tab.tsx +++ b/source/features/bugs-tab.tsx @@ -5,12 +5,12 @@ import {BugIcon} from '@primer/octicons-react'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {cacheByRepo, getRepo} from '../github-helpers'; -import SearchQuery from '../github-helpers/search-query'; -import abbreviateNumber from '../helpers/abbreviate-number'; -import {highlightTab, unhighlightTab} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {cacheByRepo, getRepo} from '../github-helpers/index.js'; +import SearchQuery from '../github-helpers/search-query.js'; +import abbreviateNumber from '../helpers/abbreviate-number.js'; +import {highlightTab, unhighlightTab} from '../helpers/dom-utils.js'; const supportedLabels = /^(bug|bug-?fix|confirmed-bug|type[:/]bug|kind[:/]bug|(:[\w-]+:|\p{Emoji})bug)$/iu; const getBugLabelCacheKey = (): string => 'bugs-label:' + getRepo()!.nameWithOwner; diff --git a/source/features/ci-link.tsx b/source/features/ci-link.tsx index 2ad11f9f..8a5aa765 100644 --- a/source/features/ci-link.tsx +++ b/source/features/ci-link.tsx @@ -3,10 +3,10 @@ import React from 'dom-chef'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {buildRepoURL} from '../github-helpers'; -import attachElement from '../helpers/attach-element'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {buildRepoURL} from '../github-helpers/index.js'; +import attachElement from '../helpers/attach-element.js'; async function getHead(): Promise<string> { const {repository} = await api.v4(` diff --git a/source/features/clean-conversation-filters.tsx b/source/features/clean-conversation-filters.tsx index b9875343..28e402c3 100644 --- a/source/features/clean-conversation-filters.tsx +++ b/source/features/clean-conversation-filters.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {cacheByRepo, getRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {cacheByRepo, getRepo} from '../github-helpers/index.js'; const hasAnyProjects = cache.function('has-projects', async (): Promise<boolean> => { const {repository, organization} = await api.v4(` diff --git a/source/features/clean-conversation-headers.tsx b/source/features/clean-conversation-headers.tsx index fdfa8ee9..4883f8c1 100644 --- a/source/features/clean-conversation-headers.tsx +++ b/source/features/clean-conversation-headers.tsx @@ -5,9 +5,9 @@ import elementReady from 'element-ready'; import {ArrowLeftIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import observe from '../helpers/selector-observer.js'; async function cleanIssueHeader(byline: HTMLElement): Promise<void> { byline.classList.add('rgh-clean-conversation-headers', 'rgh-clean-conversation-headers-hide-author'); diff --git a/source/features/clean-conversation-sidebar.tsx b/source/features/clean-conversation-sidebar.tsx index 41b6d89a..64554606 100644 --- a/source/features/clean-conversation-sidebar.tsx +++ b/source/features/clean-conversation-sidebar.tsx @@ -4,11 +4,11 @@ import select from 'select-dom'; import onetime from 'onetime'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import onElementRemoval from '../helpers/on-element-removal'; -import observe from '../helpers/selector-observer'; -import {removeTextNodeContaining} from '../helpers/dom-utils'; -import {isHasSelectorSupported} from '../helpers/select-has'; +import features from '../feature-manager.js'; +import onElementRemoval from '../helpers/on-element-removal.js'; +import observe from '../helpers/selector-observer.js'; +import {removeTextNodeContaining} from '../helpers/dom-utils.js'; +import {isHasSelectorSupported} from '../helpers/select-has.js'; const canEditSidebar = onetime((): boolean => select.exists('.discussion-sidebar-item [data-hotkey="l"]')); diff --git a/source/features/clean-pinned-issues.tsx b/source/features/clean-pinned-issues.tsx index 23408144..b75334d2 100644 --- a/source/features/clean-pinned-issues.tsx +++ b/source/features/clean-pinned-issues.tsx @@ -1,6 +1,6 @@ import './clean-pinned-issues.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [pageDetect.isRepoIssueList]); diff --git a/source/features/clean-repo-filelist-actions.tsx b/source/features/clean-repo-filelist-actions.tsx index 8c9b7bbd..4a8f4c75 100644 --- a/source/features/clean-repo-filelist-actions.tsx +++ b/source/features/clean-repo-filelist-actions.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {PlusIcon, SearchIcon, CodeIcon} from '@primer/octicons-react'; -import observe from '../helpers/selector-observer'; -import {assertNodeContent, removeTextNodeContaining, wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; +import observe from '../helpers/selector-observer.js'; +import {assertNodeContent, removeTextNodeContaining, wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; /** Add tooltip on a wrapper to avoid breaking dropdown functionality */ function addTooltipToSummary(childElement: Element, tooltip: string): void { diff --git a/source/features/clean-repo-header.tsx b/source/features/clean-repo-header.tsx index 5ee2d536..332a23d8 100644 --- a/source/features/clean-repo-header.tsx +++ b/source/features/clean-repo-header.tsx @@ -1,5 +1,5 @@ import './clean-repo-header.css'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url); diff --git a/source/features/clean-repo-sidebar.tsx b/source/features/clean-repo-sidebar.tsx index 565ccfd8..95816ce4 100644 --- a/source/features/clean-repo-sidebar.tsx +++ b/source/features/clean-repo-sidebar.tsx @@ -4,7 +4,7 @@ import domLoaded from 'dom-loaded'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; // The h2 is to avoid hiding website links that include '/releases' #4424 export const releasesSidebarSelector = '.Layout-sidebar .BorderGrid-cell h2 a[href$="/releases"]'; async function cleanReleases(): Promise<void> { diff --git a/source/features/clean-repo-tabs.tsx b/source/features/clean-repo-tabs.tsx index 6f44c1ef..32e06684 100644 --- a/source/features/clean-repo-tabs.tsx +++ b/source/features/clean-repo-tabs.tsx @@ -3,14 +3,14 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import fetchDom from '../helpers/fetch-dom'; -import * as api from '../github-helpers/api'; -import getTabCount from '../github-helpers/get-tab-count'; -import looseParseInt from '../helpers/loose-parse-int'; -import abbreviateNumber from '../helpers/abbreviate-number'; -import {buildRepoURL, cacheByRepo} from '../github-helpers'; -import {unhideOverflowDropdown} from './more-dropdown-links'; +import features from '../feature-manager.js'; +import fetchDom from '../helpers/fetch-dom.js'; +import * as api from '../github-helpers/api.js'; +import getTabCount from '../github-helpers/get-tab-count.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; +import abbreviateNumber from '../helpers/abbreviate-number.js'; +import {buildRepoURL, cacheByRepo} from '../github-helpers/index.js'; +import {unhideOverflowDropdown} from './more-dropdown-links.js'; async function canUserEditOrganization(): Promise<boolean> { return Boolean(await elementReady('.btn-primary[href$="repositories/new"]')); diff --git a/source/features/clean-rich-text-editor.tsx b/source/features/clean-rich-text-editor.tsx index 9310dff3..8e19e4f6 100644 --- a/source/features/clean-rich-text-editor.tsx +++ b/source/features/clean-rich-text-editor.tsx @@ -1,6 +1,6 @@ import './clean-rich-text-editor.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [pageDetect.hasRichTextEditor]); diff --git a/source/features/clear-pr-merge-commit-message.tsx b/source/features/clear-pr-merge-commit-message.tsx index d49ba175..d30fb16f 100644 --- a/source/features/clear-pr-merge-commit-message.tsx +++ b/source/features/clear-pr-merge-commit-message.tsx @@ -2,12 +2,12 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {getBranches} from '../github-helpers/pr-branches'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import cleanCommitMessage from '../helpers/clean-commit-message'; -import {userCanLikelyMergePR} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {getBranches} from '../github-helpers/pr-branches.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import cleanCommitMessage from '../helpers/clean-commit-message.js'; +import {userCanLikelyMergePR} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; const isPrAgainstDefaultBranch = async (): Promise<boolean> => getBranches().base.branch === await getDefaultBranch(); diff --git a/source/features/close-out-of-view-modals.tsx b/source/features/close-out-of-view-modals.tsx index ea6cc421..47eec3bc 100644 --- a/source/features/close-out-of-view-modals.tsx +++ b/source/features/close-out-of-view-modals.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import onetime from 'onetime'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; const visible = new Set(); const observer = new IntersectionObserver(entries => { diff --git a/source/features/closing-remarks.tsx b/source/features/closing-remarks.tsx index 2d8014b3..a38f12ad 100644 --- a/source/features/closing-remarks.tsx +++ b/source/features/closing-remarks.tsx @@ -4,16 +4,16 @@ import select from 'select-dom'; import {TagIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import fetchDom from '../helpers/fetch-dom'; -import onPrMerge from '../github-events/on-pr-merge'; -import createBanner from '../github-helpers/banner'; -import TimelineItem from '../github-helpers/timeline-item'; -import attachElement from '../helpers/attach-element'; -import {canEditEveryComment} from './quick-comment-edit'; -import {buildRepoURL, getRepo, isRefinedGitHubRepo} from '../github-helpers'; -import {getReleaseCount} from './releases-tab'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import fetchDom from '../helpers/fetch-dom.js'; +import onPrMerge from '../github-events/on-pr-merge.js'; +import createBanner from '../github-helpers/banner.js'; +import TimelineItem from '../github-helpers/timeline-item.js'; +import attachElement from '../helpers/attach-element.js'; +import {canEditEveryComment} from './quick-comment-edit.js'; +import {buildRepoURL, getRepo, isRefinedGitHubRepo} from '../github-helpers/index.js'; +import {getReleaseCount} from './releases-tab.js'; +import observe from '../helpers/selector-observer.js'; // TODO: Not an exact match; Moderators can edit comments but not create releases const canCreateRelease = canEditEveryComment; diff --git a/source/features/collapsible-content-button.tsx b/source/features/collapsible-content-button.tsx index bf1b7b6f..4b8776a4 100644 --- a/source/features/collapsible-content-button.tsx +++ b/source/features/collapsible-content-button.tsx @@ -4,9 +4,9 @@ import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import smartBlockWrap from '../helpers/smart-block-wrap'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import smartBlockWrap from '../helpers/smart-block-wrap.js'; +import observe from '../helpers/selector-observer.js'; function addContentToDetails({delegateTarget}: DelegateEvent<MouseEvent, HTMLButtonElement>): void { /* There's only one rich-text editor even when multiple fields are visible; the class targets it #5303 */ diff --git a/source/features/command-palette-navigation-shortcuts.tsx b/source/features/command-palette-navigation-shortcuts.tsx index 12ae6f17..132d0426 100644 --- a/source/features/command-palette-navigation-shortcuts.tsx +++ b/source/features/command-palette-navigation-shortcuts.tsx @@ -1,8 +1,8 @@ import onetime from 'onetime'; import delegate, {DelegateEvent} from 'delegate-it'; -import {isMac} from '../github-helpers'; -import features from '../feature-manager'; +import {isMac} from '../github-helpers/index.js'; +import features from '../feature-manager.js'; function commandPaletteKeydown(event: DelegateEvent<KeyboardEvent>): void { const {key, ctrlKey, delegateTarget} = event; diff --git a/source/features/comment-fields-keyboard-shortcuts.tsx b/source/features/comment-fields-keyboard-shortcuts.tsx index b297a136..b765cb3c 100644 --- a/source/features/comment-fields-keyboard-shortcuts.tsx +++ b/source/features/comment-fields-keyboard-shortcuts.tsx @@ -4,8 +4,8 @@ import {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; import filterAlteredClicks from 'filter-altered-clicks'; -import features from '../feature-manager'; -import {onCommentFieldKeydown} from '../github-events/on-field-keydown'; +import features from '../feature-manager.js'; +import {onCommentFieldKeydown} from '../github-events/on-field-keydown.js'; function handleEscapeKey(event: DelegateEvent<KeyboardEvent, HTMLTextAreaElement>, targetField: HTMLTextAreaElement): void { // Cancel buttons have different classes for inline comments and editable comments diff --git a/source/features/comment-on-draft-pr-indicator.tsx b/source/features/comment-on-draft-pr-indicator.tsx index f8625ac7..20b6a9c4 100644 --- a/source/features/comment-on-draft-pr-indicator.tsx +++ b/source/features/comment-on-draft-pr-indicator.tsx @@ -1,7 +1,7 @@ import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function addIndicator(button: HTMLElement): void { const preposition = button.textContent!.includes('Add') ? ' to ' : ' on '; diff --git a/source/features/comments-time-machine-links.tsx b/source/features/comments-time-machine-links.tsx index fb75e776..7f39de5b 100644 --- a/source/features/comments-time-machine-links.tsx +++ b/source/features/comments-time-machine-links.tsx @@ -3,14 +3,14 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import GitHubURL from '../github-helpers/github-url'; -import addNotice from '../github-widgets/notice-bar'; -import {linkifiedURLClass} from '../github-helpers/dom-formatters'; -import {buildRepoURL, isPermalink} from '../github-helpers'; -import {saveOriginalHref} from './sort-conversations-by-update-time'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import addNotice from '../github-widgets/notice-bar.js'; +import {linkifiedURLClass} from '../github-helpers/dom-formatters.js'; +import {buildRepoURL, isPermalink} from '../github-helpers/index.js'; +import {saveOriginalHref} from './sort-conversations-by-update-time.js'; +import observe from '../helpers/selector-observer.js'; async function updateURLtoDatedSha(url: GitHubURL, date: string): Promise<void> { const {repository} = await api.v4(` diff --git a/source/features/conflict-marker.tsx b/source/features/conflict-marker.tsx index 33990853..a7908a1c 100644 --- a/source/features/conflict-marker.tsx +++ b/source/features/conflict-marker.tsx @@ -5,8 +5,8 @@ import {AlertIcon} from '@primer/octicons-react'; import oneMutation from 'one-mutation'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; type PRConfig = { number: string; diff --git a/source/features/conversation-activity-filter.tsx b/source/features/conversation-activity-filter.tsx index 65ca6131..24db59f1 100644 --- a/source/features/conversation-activity-filter.tsx +++ b/source/features/conversation-activity-filter.tsx @@ -5,10 +5,10 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {CheckIcon, EyeClosedIcon, EyeIcon, XIcon} from '@primer/octicons-react'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import {registerHotkey} from '../github-helpers/hotkey'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import {registerHotkey} from '../github-helpers/hotkey.js'; +import observe from '../helpers/selector-observer.js'; const expectedDropdownWidth = 270; diff --git a/source/features/conversation-links-on-repo-lists.tsx b/source/features/conversation-links-on-repo-lists.tsx index 07068206..1b07b11c 100644 --- a/source/features/conversation-links-on-repo-lists.tsx +++ b/source/features/conversation-links-on-repo-lists.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {GitPullRequestIcon, IssueOpenedIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import {assertNodeContent} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import {assertNodeContent} from '../helpers/dom-utils.js'; function addConversationLinks(repositoryLink: HTMLAnchorElement): void { const repository = repositoryLink.closest('li')!; diff --git a/source/features/convert-pr-to-draft-improvements.tsx b/source/features/convert-pr-to-draft-improvements.tsx index 6c725aea..def1efbc 100644 --- a/source/features/convert-pr-to-draft-improvements.tsx +++ b/source/features/convert-pr-to-draft-improvements.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import IconLoading from '../github-helpers/icon-loading'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import IconLoading from '../github-helpers/icon-loading.js'; function closeModal({delegateTarget: button}: DelegateEvent<MouseEvent, HTMLButtonElement>): void { button.append(' ', <IconLoading className="v-align-middle"/>); diff --git a/source/features/convert-release-to-draft.tsx b/source/features/convert-release-to-draft.tsx index 3e1d9b32..4a6f4144 100644 --- a/source/features/convert-release-to-draft.tsx +++ b/source/features/convert-release-to-draft.tsx @@ -3,11 +3,11 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate from 'delegate-it'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; -import showToast from '../github-helpers/toast'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; +import showToast from '../github-helpers/toast.js'; const getReleaseEditLinkSelector = (): 'a' => `a[href^="/${getRepo()!.nameWithOwner}/releases/edit"]` as 'a'; diff --git a/source/features/copy-on-y.tsx b/source/features/copy-on-y.tsx index 2fc3c567..8a6d05b7 100644 --- a/source/features/copy-on-y.tsx +++ b/source/features/copy-on-y.tsx @@ -1,5 +1,5 @@ -import features from '../feature-manager'; -import {isEditable} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import {isEditable} from '../helpers/dom-utils.js'; async function handler({key, target}: KeyboardEvent): Promise<void> { if (key === 'y' && !isEditable(target)) { diff --git a/source/features/create-release-shortcut.tsx b/source/features/create-release-shortcut.tsx index ba10ecd2..4a7b0cd8 100644 --- a/source/features/create-release-shortcut.tsx +++ b/source/features/create-release-shortcut.tsx @@ -1,8 +1,8 @@ import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {registerHotkey} from '../github-helpers/hotkey'; -import {buildRepoURL} from '../github-helpers'; +import features from '../feature-manager.js'; +import {registerHotkey} from '../github-helpers/hotkey.js'; +import {buildRepoURL} from '../github-helpers/index.js'; function init(): void { // Reasoning for this feature: #1254 diff --git a/source/features/cross-deleted-pr-branches.tsx b/source/features/cross-deleted-pr-branches.tsx index 6b95799a..c980d255 100644 --- a/source/features/cross-deleted-pr-branches.tsx +++ b/source/features/cross-deleted-pr-branches.tsx @@ -3,8 +3,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; function init(): void | false { const lastBranchAction = select.last('.TimelineItem-body .user-select-contain.commit-ref'); diff --git a/source/features/deep-reblame.tsx b/source/features/deep-reblame.tsx index 614fa2b4..b4664c4e 100644 --- a/source/features/deep-reblame.tsx +++ b/source/features/deep-reblame.tsx @@ -6,12 +6,12 @@ import {VersionsIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import GitHubURL from '../github-helpers/github-url'; -import showToast from '../github-helpers/toast'; -import looseParseInt from '../helpers/loose-parse-int'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import showToast from '../github-helpers/toast.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; +import observe from '../helpers/selector-observer.js'; const getPullRequestBlameCommit = mem(async (commit: string, prNumbers: number[], currentFilename: string): Promise<string> => { const {repository} = await api.v4(` diff --git a/source/features/default-branch-button.tsx b/source/features/default-branch-button.tsx index 8208a9ab..ea5288db 100644 --- a/source/features/default-branch-button.tsx +++ b/source/features/default-branch-button.tsx @@ -3,12 +3,12 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; import {ChevronLeftIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; -import {groupButtons} from '../github-helpers/group-buttons'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {getCurrentCommittish} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import {groupButtons} from '../github-helpers/group-buttons.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {getCurrentCommittish} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; async function add(branchSelector: HTMLElement): Promise<void> { const defaultBranch = await getDefaultBranch(); diff --git a/source/features/dim-bots.tsx b/source/features/dim-bots.tsx index 7329b99b..807bba6a 100644 --- a/source/features/dim-bots.tsx +++ b/source/features/dim-bots.tsx @@ -3,8 +3,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate from 'delegate-it'; -import features from '../feature-manager'; -import preserveScroll from '../helpers/preserve-scroll'; +import features from '../feature-manager.js'; +import preserveScroll from '../helpers/preserve-scroll.js'; const botNames = [ 'actions-user', diff --git a/source/features/download-folder-button.tsx b/source/features/download-folder-button.tsx index 69c3fe6e..95e0fdf3 100644 --- a/source/features/download-folder-button.tsx +++ b/source/features/download-folder-button.tsx @@ -4,8 +4,8 @@ import React from 'dom-chef'; import {DownloadIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function add(folderDropdown: HTMLElement): void { const downloadUrl = new URL('https://download-directory.github.io/'); diff --git a/source/features/easy-toggle-commit-messages.tsx b/source/features/easy-toggle-commit-messages.tsx index b102f728..2197439c 100644 --- a/source/features/easy-toggle-commit-messages.tsx +++ b/source/features/easy-toggle-commit-messages.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function toggleCommitMessage(event: DelegateEvent<MouseEvent>): void { const elementClicked = event.target as HTMLElement; diff --git a/source/features/easy-toggle-files.tsx b/source/features/easy-toggle-files.tsx index aed7c3a5..a6a30c48 100644 --- a/source/features/easy-toggle-files.tsx +++ b/source/features/easy-toggle-files.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import delegate, {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function toggleFile(event: DelegateEvent<MouseEvent>): void { const elementClicked = event.target as HTMLElement; diff --git a/source/features/edit-readme.tsx b/source/features/edit-readme.tsx index fca517e6..51346fa0 100644 --- a/source/features/edit-readme.tsx +++ b/source/features/edit-readme.tsx @@ -3,10 +3,10 @@ import select from 'select-dom'; import {PencilIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; -import {isPermalink} from '../github-helpers'; -import getDefaultBranch from '../github-helpers/get-default-branch'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import {isPermalink} from '../github-helpers/index.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; async function init(): Promise<void | false> { const readmeHeader = select('#readme :is(.Box-header, .js-sticky)'); diff --git a/source/features/embed-gist-inline.tsx b/source/features/embed-gist-inline.tsx index b0fed002..f84653cf 100644 --- a/source/features/embed-gist-inline.tsx +++ b/source/features/embed-gist-inline.tsx @@ -3,9 +3,9 @@ import domify from 'doma'; import * as pageDetect from 'github-url-detection'; import mem from 'mem'; -import features from '../feature-manager'; -import {getCleanPathname} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {getCleanPathname} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; type GistData = { div: string; diff --git a/source/features/embed-gist-via-iframe.tsx b/source/features/embed-gist-via-iframe.tsx index 49d0accf..b6ed04ca 100644 --- a/source/features/embed-gist-via-iframe.tsx +++ b/source/features/embed-gist-via-iframe.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import onetime from 'onetime'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function init(): void { const embedViaScript = select('.file-navigation-option button[value^="<script"]')!; diff --git a/source/features/emphasize-draft-pr-label.tsx b/source/features/emphasize-draft-pr-label.tsx index 970d6af0..db2062d6 100644 --- a/source/features/emphasize-draft-pr-label.tsx +++ b/source/features/emphasize-draft-pr-label.tsx @@ -1,5 +1,5 @@ import './emphasize-draft-pr-label.css'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url); diff --git a/source/features/enable-file-links-in-compare-view.tsx b/source/features/enable-file-links-in-compare-view.tsx index e59dc4fb..5dfaab2b 100644 --- a/source/features/enable-file-links-in-compare-view.tsx +++ b/source/features/enable-file-links-in-compare-view.tsx @@ -4,9 +4,9 @@ import {GitBranchIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; -import {getBranches} from '../github-helpers/pr-branches'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import {getBranches} from '../github-helpers/pr-branches.js'; /** Rebuilds the "View file" link because it points to the base repo and to the commit, instead of the head repo and its branch */ function handlePRMenuOpening({delegateTarget: dropdown}: DelegateEvent): void { diff --git a/source/features/esc-to-cancel.tsx b/source/features/esc-to-cancel.tsx index fe422d46..f22cfb31 100644 --- a/source/features/esc-to-cancel.tsx +++ b/source/features/esc-to-cancel.tsx @@ -2,8 +2,8 @@ import select from 'select-dom'; import {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {onConversationTitleFieldKeydown} from '../github-events/on-field-keydown'; +import features from '../feature-manager.js'; +import {onConversationTitleFieldKeydown} from '../github-events/on-field-keydown.js'; function handleEscPress(event: DelegateEvent<KeyboardEvent>): void { if (event.key === 'Escape') { diff --git a/source/features/esc-to-deselect-line.tsx b/source/features/esc-to-deselect-line.tsx index 17ba6f52..838e7a89 100644 --- a/source/features/esc-to-deselect-line.tsx +++ b/source/features/esc-to-deselect-line.tsx @@ -1,7 +1,7 @@ import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {isEditable} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import {isEditable} from '../helpers/dom-utils.js'; function isLineSelected(): boolean { // Example hashes: diff --git a/source/features/expand-all-hidden-comments.tsx b/source/features/expand-all-hidden-comments.tsx index b99e4952..8f65fac4 100644 --- a/source/features/expand-all-hidden-comments.tsx +++ b/source/features/expand-all-hidden-comments.tsx @@ -3,8 +3,8 @@ import oneEvent from 'one-event'; import delegate, {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import showToast from '../github-helpers/toast'; +import features from '../feature-manager.js'; +import showToast from '../github-helpers/toast.js'; const paginationButtonSelector = '.ajax-pagination-form button[type="submit"]'; diff --git a/source/features/extend-conversation-status-filters.tsx b/source/features/extend-conversation-status-filters.tsx index cf88a236..b0b84a97 100644 --- a/source/features/extend-conversation-status-filters.tsx +++ b/source/features/extend-conversation-status-filters.tsx @@ -4,8 +4,8 @@ import {CheckIcon} from '@primer/octicons-react'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import SearchQuery from '../github-helpers/search-query'; +import features from '../feature-manager.js'; +import SearchQuery from '../github-helpers/search-query.js'; function addMergeLink(): void { if (!pageDetect.isPRList()) { diff --git a/source/features/extend-diff-expander.tsx b/source/features/extend-diff-expander.tsx index 0850a55f..2c6de210 100644 --- a/source/features/extend-diff-expander.tsx +++ b/source/features/extend-diff-expander.tsx @@ -3,7 +3,7 @@ import select from 'select-dom'; import delegate, {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function expandDiff(event: DelegateEvent): void { // Skip if the user clicked directly on the icon diff --git a/source/features/file-age-color.tsx b/source/features/file-age-color.tsx index 6f459a88..a305ac32 100644 --- a/source/features/file-age-color.tsx +++ b/source/features/file-age-color.tsx @@ -1,8 +1,8 @@ import * as pageDetect from 'github-url-detection'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import {createHeatIndexFunction} from '../helpers/math'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import {createHeatIndexFunction} from '../helpers/math.js'; const calculateHeatIndex = createHeatIndexFunction([0, -2_000_000_000]); diff --git a/source/features/fit-textareas.tsx b/source/features/fit-textareas.tsx index e4c5f206..d468a35f 100644 --- a/source/features/fit-textareas.tsx +++ b/source/features/fit-textareas.tsx @@ -3,8 +3,8 @@ import {isSafari} from 'webext-detect-page'; import fitTextarea from 'fit-textarea'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function inputListener({target}: Event): void { fitTextarea(target as HTMLTextAreaElement); diff --git a/source/features/fork-source-link-same-view.tsx b/source/features/fork-source-link-same-view.tsx index fe7fc2d4..bfe4de90 100644 --- a/source/features/fork-source-link-same-view.tsx +++ b/source/features/fork-source-link-same-view.tsx @@ -1,11 +1,11 @@ import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; -import doesFileExist from '../github-helpers/does-file-exist'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {getRepo, getForkedRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import doesFileExist from '../github-helpers/does-file-exist.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {getRepo, getForkedRepo} from '../github-helpers/index.js'; const isFilePath = (): boolean => pageDetect.isSingleFile() diff --git a/source/features/github-actions-indicators.tsx b/source/features/github-actions-indicators.tsx index a73b9df6..8fecf4d3 100644 --- a/source/features/github-actions-indicators.tsx +++ b/source/features/github-actions-indicators.tsx @@ -5,10 +5,10 @@ import {StopIcon, PlayIcon} from '@primer/octicons-react'; import {parseCron} from '@cheap-glitch/mi-cron'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {cacheByRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {cacheByRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; type Workflow = { name: string; @@ -31,7 +31,7 @@ function addTooltip(element: HTMLElement, tooltip: string): void { } // There is no way to get a workflow list in the v4 API #6543 -const getWorkflows = async (): Promise<Workflow[]> => { +async function getWorkflows(): Promise<Workflow[]> { const response = await api.v3('actions/workflows'); const workflows = response.workflows as any[]; @@ -42,9 +42,9 @@ const getWorkflows = async (): Promise<Workflow[]> => { name: workflow.path.split('/').pop()!, isEnabled: workflow.state === 'active', })); -}; +} -const getFilesInWorkflowPath = async (): Promise<Record<string, string>> => { +async function getFilesInWorkflowPath(): Promise<Record<string, string>> { const {repository: {workflowFiles}} = await api.v4(` repository() { workflowFiles: object(expression: "HEAD:.github/workflows") { @@ -70,7 +70,7 @@ const getFilesInWorkflowPath = async (): Promise<Record<string, string>> => { } return result; -}; +} const getWorkflowsDetails = cache.function('workflows-details', async (): Promise<Record<string, Workflow & WorkflowDetails>> => { const [workflows, workflowFiles] = await Promise.all([getWorkflows(), getFilesInWorkflowPath()]); diff --git a/source/features/global-conversation-list-filters.tsx b/source/features/global-conversation-list-filters.tsx index 93a14b3d..b324bfb6 100644 --- a/source/features/global-conversation-list-filters.tsx +++ b/source/features/global-conversation-list-filters.tsx @@ -3,9 +3,9 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import SearchQuery from '../github-helpers/search-query'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import SearchQuery from '../github-helpers/search-query.js'; +import observe from '../helpers/selector-observer.js'; function addLinks(container: HTMLElement): void { const defaultQuery = 'is:open archived:false'; diff --git a/source/features/hidden-review-comments-indicator.tsx b/source/features/hidden-review-comments-indicator.tsx index 7377dfe3..07eb6131 100644 --- a/source/features/hidden-review-comments-indicator.tsx +++ b/source/features/hidden-review-comments-indicator.tsx @@ -6,13 +6,13 @@ import {CommentIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import preserveScroll from '../helpers/preserve-scroll'; -import onAbort from '../helpers/abort-controller'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import preserveScroll from '../helpers/preserve-scroll.js'; +import onAbort from '../helpers/abort-controller.js'; +import observe from '../helpers/selector-observer.js'; // When an indicator is clicked, this will show comments on the current file -const handleIndicatorClick = ({delegateTarget}: DelegateEvent): void => { +function handleIndicatorClick({delegateTarget}: DelegateEvent): void { const commentedLine = delegateTarget.closest('tr')!.previousElementSibling!; const resetScroll = preserveScroll(commentedLine); delegateTarget @@ -21,7 +21,7 @@ const handleIndicatorClick = ({delegateTarget}: DelegateEvent): void => { .click(); resetScroll(); -}; +} // `mem` avoids adding the indicator twice to the same thread const addIndicator = mem((commentThread: HTMLElement): void => { diff --git a/source/features/hide-diff-signs.tsx b/source/features/hide-diff-signs.tsx index b0c9f44a..044e3cc6 100644 --- a/source/features/hide-diff-signs.tsx +++ b/source/features/hide-diff-signs.tsx @@ -1,7 +1,7 @@ import './hide-diff-signs.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [ pageDetect.hasCode, diff --git a/source/features/hide-disabled-milestone-sorter.tsx b/source/features/hide-disabled-milestone-sorter.tsx index 09701f9a..112b35a6 100644 --- a/source/features/hide-disabled-milestone-sorter.tsx +++ b/source/features/hide-disabled-milestone-sorter.tsx @@ -1,7 +1,7 @@ import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; // TODO: CSS-only feature via :has selector function init(signal: AbortSignal): void { diff --git a/source/features/hide-inactive-deployments.tsx b/source/features/hide-inactive-deployments.tsx index 2f329d6a..4f762c29 100644 --- a/source/features/hide-inactive-deployments.tsx +++ b/source/features/hide-inactive-deployments.tsx @@ -1,7 +1,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; // This feature doesn't need an active observer function init(): void { diff --git a/source/features/hide-issue-list-autocomplete.tsx b/source/features/hide-issue-list-autocomplete.tsx index 2ffacbab..acad714b 100644 --- a/source/features/hide-issue-list-autocomplete.tsx +++ b/source/features/hide-issue-list-autocomplete.tsx @@ -1,7 +1,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function init(): void { select('.subnav-search')!.setAttribute('autocomplete', 'off'); diff --git a/source/features/hide-low-quality-comments.tsx b/source/features/hide-low-quality-comments.tsx index 7360e924..e50a83ba 100644 --- a/source/features/hide-low-quality-comments.tsx +++ b/source/features/hide-low-quality-comments.tsx @@ -5,8 +5,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import isLowQualityComment from '../helpers/is-low-quality-comment'; +import features from '../feature-manager.js'; +import isLowQualityComment from '../helpers/is-low-quality-comment.js'; export const singleParagraphCommentSelector = '.comment-body > p:only-child'; diff --git a/source/features/hide-navigation-hover-highlight.tsx b/source/features/hide-navigation-hover-highlight.tsx index eae38de2..792cf491 100644 --- a/source/features/hide-navigation-hover-highlight.tsx +++ b/source/features/hide-navigation-hover-highlight.tsx @@ -1,7 +1,7 @@ import './hide-navigation-hover-highlight.css'; import onetime from 'onetime'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; const className = 'rgh-no-navigation-highlight'; diff --git a/source/features/hide-newsfeed-noise.tsx b/source/features/hide-newsfeed-noise.tsx index 829b9ac7..fff2a083 100644 --- a/source/features/hide-newsfeed-noise.tsx +++ b/source/features/hide-newsfeed-noise.tsx @@ -1,6 +1,6 @@ import './hide-newsfeed-noise.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [pageDetect.isDashboard]); diff --git a/source/features/hide-own-stars.tsx b/source/features/hide-own-stars.tsx index 155eedbb..b9e02787 100644 --- a/source/features/hide-own-stars.tsx +++ b/source/features/hide-own-stars.tsx @@ -1,9 +1,9 @@ import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {getUsername} from '../github-helpers'; -import {isHasSelectorSupported} from '../helpers/select-has'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {getUsername} from '../github-helpers/index.js'; +import {isHasSelectorSupported} from '../helpers/select-has.js'; +import observe from '../helpers/selector-observer.js'; function hide(item: HTMLElement): void { item.hidden = true; diff --git a/source/features/hide-user-forks.tsx b/source/features/hide-user-forks.tsx index 5d253808..6dfdaeec 100644 --- a/source/features/hide-user-forks.tsx +++ b/source/features/hide-user-forks.tsx @@ -1,5 +1,5 @@ -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function addSourceTypeToLink(link: HTMLAnchorElement): void { const search = new URLSearchParams(link.search); diff --git a/source/features/highest-rated-comment.tsx b/source/features/highest-rated-comment.tsx index d6db3e76..09a174aa 100644 --- a/source/features/highest-rated-comment.tsx +++ b/source/features/highest-rated-comment.tsx @@ -5,10 +5,10 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {ArrowDownIcon, CheckCircleFillIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import looseParseInt from '../helpers/loose-parse-int'; -import isLowQualityComment from '../helpers/is-low-quality-comment'; -import {singleParagraphCommentSelector} from './hide-low-quality-comments'; +import features from '../feature-manager.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; +import isLowQualityComment from '../helpers/is-low-quality-comment.js'; +import {singleParagraphCommentSelector} from './hide-low-quality-comments.js'; // `.js-timeline-item` gets the nearest comment excluding the very first comment (OP post) const commentSelector = '.js-timeline-item'; diff --git a/source/features/highlight-collaborators-and-own-conversations.tsx b/source/features/highlight-collaborators-and-own-conversations.tsx index c208f043..bac7c828 100644 --- a/source/features/highlight-collaborators-and-own-conversations.tsx +++ b/source/features/highlight-collaborators-and-own-conversations.tsx @@ -4,9 +4,9 @@ import select from 'select-dom'; import domLoaded from 'dom-loaded'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import fetchDom from '../helpers/fetch-dom'; -import {buildRepoURL, cacheByRepo, getUsername} from '../github-helpers'; +import features from '../feature-manager.js'; +import fetchDom from '../helpers/fetch-dom.js'; +import {buildRepoURL, cacheByRepo, getUsername} from '../github-helpers/index.js'; const getCollaborators = cache.function('repo-collaborators', async (): Promise<string[]> => { const dom = await fetchDom(buildRepoURL('issues/show_menu_content?partial=issues/filters/authors_content')); diff --git a/source/features/highlight-deleted-and-added-files-in-diffs.tsx b/source/features/highlight-deleted-and-added-files-in-diffs.tsx index cfb0ba0e..1acf46b9 100644 --- a/source/features/highlight-deleted-and-added-files-in-diffs.tsx +++ b/source/features/highlight-deleted-and-added-files-in-diffs.tsx @@ -4,8 +4,8 @@ import oneMutation from 'one-mutation'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; async function loadDeferred(jumpList: Element): Promise<void> { // This event will trigger the loading, but if run too early, GitHub might not have attached the listener yet, so we try multiple times. diff --git a/source/features/highlight-non-default-base-branch.tsx b/source/features/highlight-non-default-base-branch.tsx index dd6268fb..f1e2efb6 100644 --- a/source/features/highlight-non-default-base-branch.tsx +++ b/source/features/highlight-non-default-base-branch.tsx @@ -3,10 +3,10 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {GitPullRequestIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {buildRepoURL} from '../github-helpers'; -import getDefaultBranch from '../github-helpers/get-default-branch'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {buildRepoURL} from '../github-helpers/index.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; type BranchInfo = { baseRef: string; diff --git a/source/features/html-preview-link.tsx b/source/features/html-preview-link.tsx index a61a6be8..d59f608d 100644 --- a/source/features/html-preview-link.tsx +++ b/source/features/html-preview-link.tsx @@ -1,8 +1,8 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; const isSingleHTMLFile = (): boolean => pageDetect.isSingleFile() && /\.html?$/.test(location.pathname); diff --git a/source/features/improve-shortcut-help.tsx b/source/features/improve-shortcut-help.tsx index 1a31b504..4a9ee78c 100644 --- a/source/features/improve-shortcut-help.tsx +++ b/source/features/improve-shortcut-help.tsx @@ -2,8 +2,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import onetime from 'onetime'; -import features from '../feature-manager'; -import {isEditable} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import {isEditable} from '../helpers/dom-utils.js'; function splitKeys(keys: string): DocumentFragment[] { return keys.split(' ').map(key => <> <kbd>{key}</kbd></>); diff --git a/source/features/infinite-scroll.tsx b/source/features/infinite-scroll.tsx index 0cd8dd71..46cdce26 100644 --- a/source/features/infinite-scroll.tsx +++ b/source/features/infinite-scroll.tsx @@ -4,9 +4,9 @@ import select from 'select-dom'; import debounce from 'debounce-fn'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import onAbort from '../helpers/abort-controller'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import onAbort from '../helpers/abort-controller.js'; const loadMore = debounce(() => { const button = select('[role="tabpanel"]:not([hidden]) button.ajax-pagination-btn')!; diff --git a/source/features/jump-to-change-requested-comment.tsx b/source/features/jump-to-change-requested-comment.tsx index 212561c4..3a6b72c4 100644 --- a/source/features/jump-to-change-requested-comment.tsx +++ b/source/features/jump-to-change-requested-comment.tsx @@ -2,9 +2,9 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function linkify(textLine: HTMLElement): void { const url = select('a.dropdown-item[href^="#pullrequestreview-"]', textLine.parentElement!); diff --git a/source/features/jump-to-conversation-close-event.tsx b/source/features/jump-to-conversation-close-event.tsx index 23630f3a..6ca8b97b 100644 --- a/source/features/jump-to-conversation-close-event.tsx +++ b/source/features/jump-to-conversation-close-event.tsx @@ -3,9 +3,9 @@ import {css} from 'code-tag'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; export const closedOrMergedMarkerSelector = css` #partial-discussion-header :is( diff --git a/source/features/keyboard-navigation.tsx b/source/features/keyboard-navigation.tsx index 79b11596..ed781bd3 100644 --- a/source/features/keyboard-navigation.tsx +++ b/source/features/keyboard-navigation.tsx @@ -1,8 +1,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {isEditable} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import {isEditable} from '../helpers/dom-utils.js'; const isCommentGroupMinimized = (comment: HTMLElement): boolean => select.exists('.minimized-comment:not(.d-none)', comment) diff --git a/source/features/last-notification-page-button.tsx b/source/features/last-notification-page-button.tsx index 910b0640..93479b03 100644 --- a/source/features/last-notification-page-button.tsx +++ b/source/features/last-notification-page-button.tsx @@ -2,10 +2,10 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import looseParseInt from '../helpers/loose-parse-int'; -import {assertNodeContent} from '../helpers/dom-utils'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; +import {assertNodeContent} from '../helpers/dom-utils.js'; +import observe from '../helpers/selector-observer.js'; const itemsPerNotificationsPage = 25; diff --git a/source/features/link-to-changelog-file.tsx b/source/features/link-to-changelog-file.tsx index c37c0d09..4c8489a2 100644 --- a/source/features/link-to-changelog-file.tsx +++ b/source/features/link-to-changelog-file.tsx @@ -5,10 +5,10 @@ import {BookIcon} from '@primer/octicons-react'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {wrapAll} from '../helpers/dom-utils'; -import {buildRepoURL, cacheByRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {wrapAll} from '../helpers/dom-utils.js'; +import {buildRepoURL, cacheByRepo} from '../github-helpers/index.js'; type FileType = { name: string; diff --git a/source/features/link-to-compare-diff.tsx b/source/features/link-to-compare-diff.tsx index af5e3fb6..e1fecce8 100644 --- a/source/features/link-to-compare-diff.tsx +++ b/source/features/link-to-compare-diff.tsx @@ -3,9 +3,9 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {wrapAll} from '../helpers/dom-utils'; -import selectHas from '../helpers/select-has'; +import features from '../feature-manager.js'; +import {wrapAll} from '../helpers/dom-utils.js'; +import selectHas from '../helpers/select-has.js'; function init(): void { const changedFilesSummary = selectHas('.Box li:has(.octicon-file-diff)')!; diff --git a/source/features/link-to-github-io.tsx b/source/features/link-to-github-io.tsx index 16cae5c8..c161150b 100644 --- a/source/features/link-to-github-io.tsx +++ b/source/features/link-to-github-io.tsx @@ -2,9 +2,9 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; import {LinkIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import {getRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {getRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; function getLinkToGitHubIo(repoTitle: HTMLElement, className?: string): JSX.Element { return ( diff --git a/source/features/linkify-branch-references.tsx b/source/features/linkify-branch-references.tsx index 7298973f..855c46ba 100644 --- a/source/features/linkify-branch-references.tsx +++ b/source/features/linkify-branch-references.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; -import {buildRepoURL} from '../github-helpers'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import {buildRepoURL} from '../github-helpers/index.js'; async function init(): Promise<void | false> { const element = await elementReady(pageDetect.isQuickPR() ? '.branch-name' : '.commit-form .branch-name'); diff --git a/source/features/linkify-code.tsx b/source/features/linkify-code.tsx index a62cae53..4aa52414 100644 --- a/source/features/linkify-code.tsx +++ b/source/features/linkify-code.tsx @@ -1,10 +1,10 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import {getRepo} from '../github-helpers'; -import {codeElementsSelector, linkifiedURLClass, linkifyURLs, linkifyIssues} from '../github-helpers/dom-formatters'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import {getRepo} from '../github-helpers/index.js'; +import {codeElementsSelector, linkifiedURLClass, linkifyURLs, linkifyIssues} from '../github-helpers/dom-formatters.js'; function initTitle(signal: AbortSignal): void { // If we are not in a repo, relative issue references won't make sense but `user`/`repo` needs to be set to avoid breaking errors in `linkify-issues` diff --git a/source/features/linkify-commit-sha.tsx b/source/features/linkify-commit-sha.tsx index 43f47e33..d33ffdca 100644 --- a/source/features/linkify-commit-sha.tsx +++ b/source/features/linkify-commit-sha.tsx @@ -2,8 +2,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; function init(): void { const element = select('.sha.user-select-contain:not(a *)'); diff --git a/source/features/linkify-labels-on-dashboard.tsx b/source/features/linkify-labels-on-dashboard.tsx index ff7c48c4..a37326b6 100644 --- a/source/features/linkify-labels-on-dashboard.tsx +++ b/source/features/linkify-labels-on-dashboard.tsx @@ -2,9 +2,9 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function linkifyLabel(label: Element): void { const activity = label.closest('div:not([class])')!; diff --git a/source/features/linkify-notification-repository-header.tsx b/source/features/linkify-notification-repository-header.tsx index 5f25d82c..fc6dc8c3 100644 --- a/source/features/linkify-notification-repository-header.tsx +++ b/source/features/linkify-notification-repository-header.tsx @@ -1,8 +1,8 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function linkify(header: HTMLElement): void { header.append( diff --git a/source/features/linkify-symbolic-links.tsx b/source/features/linkify-symbolic-links.tsx index 502de089..527a52ea 100644 --- a/source/features/linkify-symbolic-links.tsx +++ b/source/features/linkify-symbolic-links.tsx @@ -2,8 +2,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; function init(): void { if (select('.file-mode')?.textContent === 'symbolic link') { diff --git a/source/features/linkify-user-edit-history-popup.tsx b/source/features/linkify-user-edit-history-popup.tsx index cafc67e2..2b945cdd 100644 --- a/source/features/linkify-user-edit-history-popup.tsx +++ b/source/features/linkify-user-edit-history-popup.tsx @@ -1,9 +1,9 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function linkify(avatar: HTMLImageElement): void { const userName = avatar.alt.slice(1); diff --git a/source/features/linkify-user-labels.tsx b/source/features/linkify-user-labels.tsx index 65c830aa..91aff7b1 100644 --- a/source/features/linkify-user-labels.tsx +++ b/source/features/linkify-user-labels.tsx @@ -1,11 +1,11 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import {buildRepoURL} from '../github-helpers'; -import getCommentAuthor from '../github-helpers/get-comment-author'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import {buildRepoURL} from '../github-helpers/index.js'; +import getCommentAuthor from '../github-helpers/get-comment-author.js'; +import observe from '../helpers/selector-observer.js'; function linkify(label: Element): void { if (label.closest('a')) { diff --git a/source/features/linkify-user-location.tsx b/source/features/linkify-user-location.tsx index aa87a116..5b5238c4 100644 --- a/source/features/linkify-user-location.tsx +++ b/source/features/linkify-user-location.tsx @@ -1,8 +1,8 @@ import React from 'dom-chef'; -import features from '../feature-manager'; -import {wrap} from '../helpers/dom-utils'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {wrap} from '../helpers/dom-utils.js'; +import observe from '../helpers/selector-observer.js'; function addLocation({nextElementSibling, nextSibling}: SVGElement): Element { // `nextSibling` alone might point to an empty TextNode before an element, if there’s an element diff --git a/source/features/list-prs-for-branch.tsx b/source/features/list-prs-for-branch.tsx index 7a19ce42..368038bf 100644 --- a/source/features/list-prs-for-branch.tsx +++ b/source/features/list-prs-for-branch.tsx @@ -1,11 +1,11 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {getCurrentCommittish} from '../github-helpers'; -import addAfterBranchSelector from '../helpers/add-after-branch-selector'; -import {getPullRequestsAssociatedWithBranch, stateIcon} from './show-associated-branch-prs-on-fork'; +import features from '../feature-manager.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {getCurrentCommittish} from '../github-helpers/index.js'; +import addAfterBranchSelector from '../helpers/add-after-branch-selector.js'; +import {getPullRequestsAssociatedWithBranch, stateIcon} from './show-associated-branch-prs-on-fork.js'; // Taken from https://github.com/fregante/github-issue-link-status/blob/98792f2837352bacbf80664f3edbcec8e579ed17/source/github-issue-link-status.js#L10 const stateColorMap = { diff --git a/source/features/list-prs-for-file.tsx b/source/features/list-prs-for-file.tsx index 169b3069..4e30fbab 100644 --- a/source/features/list-prs-for-file.tsx +++ b/source/features/list-prs-for-file.tsx @@ -4,12 +4,12 @@ import {isFirefox} from 'webext-detect-page'; import * as pageDetect from 'github-url-detection'; import {AlertIcon, GitPullRequestIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {buildRepoURL, cacheByRepo} from '../github-helpers'; -import GitHubURL from '../github-helpers/github-url'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {buildRepoURL, cacheByRepo} from '../github-helpers/index.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import observe from '../helpers/selector-observer.js'; function getPRUrl(prNumber: number): string { // https://caniuse.com/url-scroll-to-text-fragment diff --git a/source/features/mark-merge-commits-in-list.tsx b/source/features/mark-merge-commits-in-list.tsx index 0a00a151..a9efce84 100644 --- a/source/features/mark-merge-commits-in-list.tsx +++ b/source/features/mark-merge-commits-in-list.tsx @@ -5,9 +5,9 @@ import {GitMergeIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import {objectEntries} from 'ts-extras'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {isHasSelectorSupported} from '../helpers/select-has'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {isHasSelectorSupported} from '../helpers/select-has.js'; const filterMergeCommits = async (commits: string[]): Promise<string[]> => { const {repository} = await api.v4(` diff --git a/source/features/mark-private-orgs.tsx b/source/features/mark-private-orgs.tsx index 12bbc0b6..0219d1e3 100644 --- a/source/features/mark-private-orgs.tsx +++ b/source/features/mark-private-orgs.tsx @@ -5,9 +5,9 @@ import select from 'select-dom'; import {EyeClosedIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getUsername} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getUsername} from '../github-helpers/index.js'; const getPublicOrganizationsNames = cache.function('public-organizations', async (username: string): Promise<string[]> => { // API v4 seems to *require* `org:read` permission AND it includes private organizations as well, which defeats the purpose. There's no way to filter them. diff --git a/source/features/minimize-upload-bar.tsx b/source/features/minimize-upload-bar.tsx index 9a78c698..75464565 100644 --- a/source/features/minimize-upload-bar.tsx +++ b/source/features/minimize-upload-bar.tsx @@ -1,6 +1,6 @@ import './minimize-upload-bar.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [pageDetect.hasRichTextEditor]); diff --git a/source/features/more-conversation-filters.tsx b/source/features/more-conversation-filters.tsx index 35710b66..37387a04 100644 --- a/source/features/more-conversation-filters.tsx +++ b/source/features/more-conversation-filters.tsx @@ -1,8 +1,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import SearchQuery from '../github-helpers/search-query'; +import features from '../feature-manager.js'; +import SearchQuery from '../github-helpers/search-query.js'; function init(): void { const sourceItem = select('#filters-select-menu a:nth-last-child(2)')!; diff --git a/source/features/more-dropdown-links.tsx b/source/features/more-dropdown-links.tsx index 209fc12a..62a61e25 100644 --- a/source/features/more-dropdown-links.tsx +++ b/source/features/more-dropdown-links.tsx @@ -4,10 +4,10 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import createDropdownItem from '../github-helpers/create-dropdown-item'; -import {buildRepoURL, getCurrentCommittish} from '../github-helpers'; +import features from '../feature-manager.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import createDropdownItem from '../github-helpers/create-dropdown-item.js'; +import {buildRepoURL, getCurrentCommittish} from '../github-helpers/index.js'; export async function unhideOverflowDropdown(): Promise<boolean> { // Wait for the tab bar to be loaded diff --git a/source/features/more-file-links.tsx b/source/features/more-file-links.tsx index 82a4c572..004b3a53 100644 --- a/source/features/more-file-links.tsx +++ b/source/features/more-file-links.tsx @@ -3,8 +3,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; function handleMenuOpening({delegateTarget: dropdown}: DelegateEvent): void { dropdown.classList.add('rgh-more-file-links'); // Mark this as processed diff --git a/source/features/netiquette.tsx b/source/features/netiquette.tsx index 2397bddc..0117f76a 100644 --- a/source/features/netiquette.tsx +++ b/source/features/netiquette.tsx @@ -5,11 +5,11 @@ import select from 'select-dom'; import twas from 'twas'; import {InfoIcon} from '@primer/octicons-react'; -import createBanner from '../github-helpers/banner'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import {buildRepoURL, isAnyRefinedGitHubRepo} from '../github-helpers'; -import {closedOrMergedMarkerSelector, getLastCloseEvent} from './jump-to-conversation-close-event'; +import createBanner from '../github-helpers/banner.js'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import {buildRepoURL, isAnyRefinedGitHubRepo} from '../github-helpers/index.js'; +import {closedOrMergedMarkerSelector, getLastCloseEvent} from './jump-to-conversation-close-event.js'; const isClosedOrMerged = (): boolean => select.exists(closedOrMergedMarkerSelector); diff --git a/source/features/new-repo-disable-projects-and-wikis.tsx b/source/features/new-repo-disable-projects-and-wikis.tsx index 9320c79d..76c2a125 100644 --- a/source/features/new-repo-disable-projects-and-wikis.tsx +++ b/source/features/new-repo-disable-projects-and-wikis.tsx @@ -5,10 +5,10 @@ import delegate from 'delegate-it'; import domLoaded from 'dom-loaded'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import selectHas from '../helpers/select-has'; -import attachElement from '../helpers/attach-element'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import selectHas from '../helpers/select-has.js'; +import attachElement from '../helpers/attach-element.js'; const documentation = 'https://github.com/refined-github/refined-github/wiki/Extended-feature-descriptions#new-repo-disable-projects-and-wikis'; diff --git a/source/features/no-duplicate-list-update-time.tsx b/source/features/no-duplicate-list-update-time.tsx index 8855cb9b..1effedeb 100644 --- a/source/features/no-duplicate-list-update-time.tsx +++ b/source/features/no-duplicate-list-update-time.tsx @@ -1,8 +1,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function parseTime(element: HTMLElement): number { return new Date(element.getAttribute('datetime')!).getTime(); diff --git a/source/features/no-unnecessary-split-diff-view.tsx b/source/features/no-unnecessary-split-diff-view.tsx index 6cc667df..30e05147 100644 --- a/source/features/no-unnecessary-split-diff-view.tsx +++ b/source/features/no-unnecessary-split-diff-view.tsx @@ -1,7 +1,7 @@ import './no-unnecessary-split-diff-view.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url, [ pageDetect.hasFiles, diff --git a/source/features/one-click-diff-options.tsx b/source/features/one-click-diff-options.tsx index 1c494352..ea131473 100644 --- a/source/features/one-click-diff-options.tsx +++ b/source/features/one-click-diff-options.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {BookIcon, CheckIcon, DiffIcon, DiffModifiedIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import {removeTextNodeContaining} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import {removeTextNodeContaining} from '../helpers/dom-utils.js'; function isHidingWhitespace(): boolean { // The selector is the native button diff --git a/source/features/one-click-pr-or-gist.tsx b/source/features/one-click-pr-or-gist.tsx index 824b3f30..70d34796 100644 --- a/source/features/one-click-pr-or-gist.tsx +++ b/source/features/one-click-pr-or-gist.tsx @@ -3,8 +3,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import selectHas from '../helpers/select-has'; +import features from '../feature-manager.js'; +import selectHas from '../helpers/select-has.js'; function init(): void | false { const initialGroupedButtons = selectHas('.BtnGroup:has([name="draft"], [name="gist[public]"])'); diff --git a/source/features/one-click-review-submission.tsx b/source/features/one-click-review-submission.tsx index 8c10c4ce..1952fa80 100644 --- a/source/features/one-click-review-submission.tsx +++ b/source/features/one-click-review-submission.tsx @@ -4,8 +4,8 @@ import delegate, {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; import {CheckIcon, FileDiffIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import looseParseInt from '../helpers/loose-parse-int'; +import features from '../feature-manager.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; function addButtons(radios: HTMLInputElement[]): void { const form = radios[0].form!; diff --git a/source/features/one-key-formatting.tsx b/source/features/one-key-formatting.tsx index fdae1aa6..6ad937cb 100644 --- a/source/features/one-key-formatting.tsx +++ b/source/features/one-key-formatting.tsx @@ -2,8 +2,8 @@ import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import {onCommentFieldKeydown, onConversationTitleFieldKeydown, onCommitTitleFieldKeydown} from '../github-events/on-field-keydown'; +import features from '../feature-manager.js'; +import {onCommentFieldKeydown, onConversationTitleFieldKeydown, onCommitTitleFieldKeydown} from '../github-events/on-field-keydown.js'; const formattingCharacters = ['`', '\'', '"', '[', '(', '{', '*', '_', '~', '“', '‘']; const matchingCharacters = ['`', '\'', '"', ']', ')', '}', '*', '_', '~', '”', '’']; diff --git a/source/features/open-all-conversations.tsx b/source/features/open-all-conversations.tsx index 4b1797c2..c45cadbe 100644 --- a/source/features/open-all-conversations.tsx +++ b/source/features/open-all-conversations.tsx @@ -4,9 +4,9 @@ import delegate, {DelegateEvent} from 'delegate-it'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import openTabs from '../helpers/open-tabs'; -import {attachElements} from '../helpers/attach-element'; +import features from '../feature-manager.js'; +import openTabs from '../helpers/open-tabs.js'; +import {attachElements} from '../helpers/attach-element.js'; function getUrlFromItem(issue: Element): string { return issue diff --git a/source/features/open-all-notifications.tsx b/source/features/open-all-notifications.tsx index 3b648e60..8d4cfecf 100644 --- a/source/features/open-all-notifications.tsx +++ b/source/features/open-all-notifications.tsx @@ -5,12 +5,12 @@ import * as pageDetect from 'github-url-detection'; import {LinkExternalIcon} from '@primer/octicons-react'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import openTabs from '../helpers/open-tabs'; -import {appendBefore} from '../helpers/dom-utils'; -import showToast from '../github-helpers/toast'; -import pluralize from '../helpers/pluralize'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import openTabs from '../helpers/open-tabs.js'; +import {appendBefore} from '../helpers/dom-utils.js'; +import showToast from '../github-helpers/toast.js'; +import pluralize from '../helpers/pluralize.js'; +import observe from '../helpers/selector-observer.js'; // Selector works on: // https://github.com/notifications (Grouped by date) diff --git a/source/features/open-issue-to-latest-comment.tsx b/source/features/open-issue-to-latest-comment.tsx index de5842dd..070f960c 100644 --- a/source/features/open-issue-to-latest-comment.tsx +++ b/source/features/open-issue-to-latest-comment.tsx @@ -1,7 +1,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; const selector = ` :is(.js-issue-row, .js-pinned-issue-list-item) diff --git a/source/features/pagination-hotkey.tsx b/source/features/pagination-hotkey.tsx index ca59a01d..ae4f5d52 100644 --- a/source/features/pagination-hotkey.tsx +++ b/source/features/pagination-hotkey.tsx @@ -1,8 +1,8 @@ import * as pageDetect from 'github-url-detection'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import {addHotkey} from '../github-helpers/hotkey'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import {addHotkey} from '../github-helpers/hotkey.js'; const previous = [ 'a[rel="prev"]', // `isIssueOrPRList`, `isGlobalSearchResults`, `isReleases`, `isUserProfileRepoTab`, `isDiscussionList` diff --git a/source/features/parse-backticks.tsx b/source/features/parse-backticks.tsx index 92975763..98261f79 100644 --- a/source/features/parse-backticks.tsx +++ b/source/features/parse-backticks.tsx @@ -1,9 +1,9 @@ import './parse-backticks.css'; import onetime from 'onetime'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import {parseBackticks} from '../github-helpers/dom-formatters'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import {parseBackticks} from '../github-helpers/dom-formatters.js'; // TODO: Review again, this feature presumaly should not apply to so many places const selectors = [ diff --git a/source/features/patch-diff-links.tsx b/source/features/patch-diff-links.tsx index 7a114634..cd1c84d9 100644 --- a/source/features/patch-diff-links.tsx +++ b/source/features/patch-diff-links.tsx @@ -2,8 +2,8 @@ import React from 'dom-chef'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {getCleanPathname} from '../github-helpers'; +import features from '../feature-manager.js'; +import {getCleanPathname} from '../github-helpers/index.js'; async function init(): Promise<void> { let commitUrl = '/' + getCleanPathname(); diff --git a/source/features/pinned-issues-update-time.tsx b/source/features/pinned-issues-update-time.tsx index 6bf4d177..480e0585 100644 --- a/source/features/pinned-issues-update-time.tsx +++ b/source/features/pinned-issues-update-time.tsx @@ -3,10 +3,10 @@ import cache from 'webext-storage-cache'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getRepo} from '../github-helpers'; -import looseParseInt from '../helpers/loose-parse-int'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getRepo} from '../github-helpers/index.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; type IssueInfo = { updatedAt: string; diff --git a/source/features/pr-base-commit.tsx b/source/features/pr-base-commit.tsx index 42d3e3a6..aa4541e5 100644 --- a/source/features/pr-base-commit.tsx +++ b/source/features/pr-base-commit.tsx @@ -3,15 +3,15 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import * as api from '../github-helpers/api'; -import {getBranches} from '../github-helpers/pr-branches'; -import getPrInfo, {PullRequestInfo} from '../github-helpers/get-pr-info'; -import pluralize from '../helpers/pluralize'; -import {buildRepoURL} from '../github-helpers'; -import {linkifyCommit} from '../github-helpers/dom-formatters'; -import {removeTextNodeContaining} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import * as api from '../github-helpers/api.js'; +import {getBranches} from '../github-helpers/pr-branches.js'; +import getPrInfo, {PullRequestInfo} from '../github-helpers/get-pr-info.js'; +import pluralize from '../helpers/pluralize.js'; +import {buildRepoURL} from '../github-helpers/index.js'; +import {linkifyCommit} from '../github-helpers/dom-formatters.js'; +import {removeTextNodeContaining} from '../helpers/dom-utils.js'; function getBaseCommitNotice(prInfo: PullRequestInfo): JSX.Element { const {base} = getBranches(); diff --git a/source/features/pr-branch-auto-delete.tsx b/source/features/pr-branch-auto-delete.tsx index 5ec19eb9..ca798774 100644 --- a/source/features/pr-branch-auto-delete.tsx +++ b/source/features/pr-branch-auto-delete.tsx @@ -4,11 +4,11 @@ import {InfoIcon} from '@primer/octicons-react'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import onPrMerge from '../github-events/on-pr-merge'; -import featureLink from '../helpers/feature-link'; -import attachElement from '../helpers/attach-element'; -import {canEditEveryComment} from './quick-comment-edit'; +import features from '../feature-manager.js'; +import onPrMerge from '../github-events/on-pr-merge.js'; +import featureLink from '../helpers/feature-link.js'; +import attachElement from '../helpers/attach-element.js'; +import {canEditEveryComment} from './quick-comment-edit.js'; // TODO: Not an exact match; Moderators can edit comments but not create releases const canCreateRelease = canEditEveryComment; diff --git a/source/features/pr-commit-lines-changed.tsx b/source/features/pr-commit-lines-changed.tsx index 0d341cc6..3a6d2009 100644 --- a/source/features/pr-commit-lines-changed.tsx +++ b/source/features/pr-commit-lines-changed.tsx @@ -3,9 +3,9 @@ import cache from 'webext-storage-cache'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import pluralize from '../helpers/pluralize'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import pluralize from '../helpers/pluralize.js'; const getCommitChanges = cache.function('commit-changes', async (commit: string): Promise<[additions: number, deletions: number]> => { const {repository} = await api.v4(` diff --git a/source/features/pr-filters.tsx b/source/features/pr-filters.tsx index 2af1148f..40060af4 100644 --- a/source/features/pr-filters.tsx +++ b/source/features/pr-filters.tsx @@ -4,10 +4,10 @@ import select from 'select-dom'; import {CheckIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import observe from '../helpers/selector-observer'; -import {cacheByRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import observe from '../helpers/selector-observer.js'; +import {cacheByRepo} from '../github-helpers/index.js'; const reviewsFilterSelector = '#reviews-select-menu'; diff --git a/source/features/pr-jump-to-first-non-viewed-file.tsx b/source/features/pr-jump-to-first-non-viewed-file.tsx index 68960ce7..119a4c13 100644 --- a/source/features/pr-jump-to-first-non-viewed-file.tsx +++ b/source/features/pr-jump-to-first-non-viewed-file.tsx @@ -3,7 +3,7 @@ import elementReady from 'element-ready'; import delegate from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function jumpToFirstNonViewed(): void { const firstNonViewedFile = select('.file:not([data-file-user-viewed])')!; diff --git a/source/features/prevent-duplicate-pr-submission.tsx b/source/features/prevent-duplicate-pr-submission.tsx index fcb5e231..7829a374 100644 --- a/source/features/prevent-duplicate-pr-submission.tsx +++ b/source/features/prevent-duplicate-pr-submission.tsx @@ -1,7 +1,7 @@ import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; let previousSubmission = 0; diff --git a/source/features/prevent-link-loss.tsx b/source/features/prevent-link-loss.tsx index 87b7d117..bb0e1ad9 100644 --- a/source/features/prevent-link-loss.tsx +++ b/source/features/prevent-link-loss.tsx @@ -6,7 +6,7 @@ import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; import { prCommitUrlRegex, preventPrCommitLinkLoss, @@ -14,7 +14,7 @@ import { preventPrCompareLinkLoss, discussionUrlRegex, preventDiscussionLinkLoss, -} from '../github-helpers/prevent-link-loss'; +} from '../github-helpers/prevent-link-loss.js'; const documentation = 'https://github.com/refined-github/refined-github/wiki/GitHub-markdown-linkifier-bug'; diff --git a/source/features/prevent-pr-merge-panel-opening.tsx b/source/features/prevent-pr-merge-panel-opening.tsx index 3b0bb73f..13bd7db7 100644 --- a/source/features/prevent-pr-merge-panel-opening.tsx +++ b/source/features/prevent-pr-merge-panel-opening.tsx @@ -1,7 +1,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; async function sessionResumeHandler(): Promise<void> { await Promise.resolve(); // The `session:resume` event fires a bit too early diff --git a/source/features/preview-hidden-comments.tsx b/source/features/preview-hidden-comments.tsx index f5731090..e92bb167 100644 --- a/source/features/preview-hidden-comments.tsx +++ b/source/features/preview-hidden-comments.tsx @@ -3,9 +3,9 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {upperCaseFirst} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {upperCaseFirst} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; function preview(hiddenCommentHeader: HTMLElement): void { const details = hiddenCommentHeader.closest('details')!; diff --git a/source/features/previous-next-commit-buttons.tsx b/source/features/previous-next-commit-buttons.tsx index 8ffd8d15..b967e70a 100644 --- a/source/features/previous-next-commit-buttons.tsx +++ b/source/features/previous-next-commit-buttons.tsx @@ -2,7 +2,7 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function init(): false | void { const originalPreviousNext = select('.commit .BtnGroup.float-right'); diff --git a/source/features/profile-gists-link.tsx b/source/features/profile-gists-link.tsx index ad149a96..b755190e 100644 --- a/source/features/profile-gists-link.tsx +++ b/source/features/profile-gists-link.tsx @@ -4,11 +4,11 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {CodeSquareIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getCleanPathname} from '../github-helpers'; -import createDropdownItem from '../github-helpers/create-dropdown-item'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getCleanPathname} from '../github-helpers/index.js'; +import createDropdownItem from '../github-helpers/create-dropdown-item.js'; +import observe from '../helpers/selector-observer.js'; const getGistCount = cache.function('gist-count', async (username: string): Promise<number> => { const {user} = await api.v4(` diff --git a/source/features/profile-hotkey.tsx b/source/features/profile-hotkey.tsx index 5fa7e0e5..e8572cd1 100644 --- a/source/features/profile-hotkey.tsx +++ b/source/features/profile-hotkey.tsx @@ -2,8 +2,8 @@ import React from 'dom-chef'; import onetime from 'onetime'; import {isEnterprise} from 'github-url-detection'; -import features from '../feature-manager'; -import {getUsername} from '../github-helpers'; +import features from '../feature-manager.js'; +import {getUsername} from '../github-helpers/index.js'; function init(): void { const profileLink = (isEnterprise() ? location.origin : 'https://github.com') + '/' + getUsername()!; diff --git a/source/features/pull-request-hotkeys.tsx b/source/features/pull-request-hotkeys.tsx index 2011e37b..64929964 100644 --- a/source/features/pull-request-hotkeys.tsx +++ b/source/features/pull-request-hotkeys.tsx @@ -2,8 +2,8 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {addHotkey} from '../github-helpers/hotkey'; +import features from '../feature-manager.js'; +import {addHotkey} from '../github-helpers/hotkey.js'; async function init(): Promise<void> { const tabnav = await elementReady('#partial-discussion-header + .tabnav'); diff --git a/source/features/quick-comment-edit.tsx b/source/features/quick-comment-edit.tsx index 6bee5bfb..a9d343a6 100644 --- a/source/features/quick-comment-edit.tsx +++ b/source/features/quick-comment-edit.tsx @@ -4,9 +4,9 @@ import select from 'select-dom'; import {PencilIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import {isArchivedRepoAsync} from '../github-helpers'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import {isArchivedRepoAsync} from '../github-helpers/index.js'; function addQuickEditButton(commentForm: Element): void { const commentBody = commentForm.closest('.js-comment')!; diff --git a/source/features/quick-comment-hiding.tsx b/source/features/quick-comment-hiding.tsx index a2f29b2c..3f87911f 100644 --- a/source/features/quick-comment-hiding.tsx +++ b/source/features/quick-comment-hiding.tsx @@ -3,7 +3,7 @@ import select from 'select-dom'; import delegate, {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; const formSelector = [ 'form[action$="/minimize-comment"]', diff --git a/source/features/quick-file-edit.tsx b/source/features/quick-file-edit.tsx index 7819418b..3a696550 100644 --- a/source/features/quick-file-edit.tsx +++ b/source/features/quick-file-edit.tsx @@ -6,12 +6,12 @@ import React from 'dom-chef'; import {PencilIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import GitHubURL from '../github-helpers/github-url'; -import {isArchivedRepoAsync, isPermalink} from '../github-helpers'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import {isArchivedRepoAsync, isPermalink} from '../github-helpers/index.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import observe from '../helpers/selector-observer.js'; // For https://github.com/refined-github/refined-github/issues/5821 // TODO: Maybe drop it after `isPermalink` accepts a value thanks to https://github.com/refined-github/github-url-detection/issues/85 diff --git a/source/features/quick-label-removal.tsx b/source/features/quick-label-removal.tsx index d32c8021..0d31c8cc 100644 --- a/source/features/quick-label-removal.tsx +++ b/source/features/quick-label-removal.tsx @@ -7,11 +7,11 @@ import {assertError} from 'ts-extras'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import showToast from '../github-helpers/toast'; -import {getConversationNumber} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import showToast from '../github-helpers/toast.js'; +import {getConversationNumber} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; const canNotEditLabels = onetime((): boolean => !select.exists('.label-select-menu .octicon-gear')); diff --git a/source/features/quick-mention.tsx b/source/features/quick-mention.tsx index 84c359d5..c04eb94c 100644 --- a/source/features/quick-mention.tsx +++ b/source/features/quick-mention.tsx @@ -6,10 +6,10 @@ import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; import delegate, {DelegateEvent} from 'delegate-it'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import {getUsername, isArchivedRepoAsync} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import {getUsername, isArchivedRepoAsync} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; function prefixUserMention(userMention: string): string { // The alt may or may not have it #4859 diff --git a/source/features/quick-new-issue.tsx b/source/features/quick-new-issue.tsx index 1c269b66..3822beed 100644 --- a/source/features/quick-new-issue.tsx +++ b/source/features/quick-new-issue.tsx @@ -1,10 +1,10 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {buildRepoURL, getRepo, isArchivedRepoAsync} from '../github-helpers'; -import {isHasSelectorSupported} from '../helpers/select-has'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {buildRepoURL, getRepo, isArchivedRepoAsync} from '../github-helpers/index.js'; +import {isHasSelectorSupported} from '../helpers/select-has.js'; +import observe from '../helpers/selector-observer.js'; function add(dropdownMenu: HTMLElement): void { dropdownMenu.append( diff --git a/source/features/quick-repo-deletion.tsx b/source/features/quick-repo-deletion.tsx index 6671061c..0b1f5cd1 100644 --- a/source/features/quick-repo-deletion.tsx +++ b/source/features/quick-repo-deletion.tsx @@ -8,14 +8,14 @@ import {assertError} from 'ts-extras'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getForkedRepo, getRepo} from '../github-helpers'; -import pluralize from '../helpers/pluralize'; -import addNotice from '../github-widgets/notice-bar'; -import looseParseInt from '../helpers/loose-parse-int'; -import parseBackticks from '../github-helpers/parse-backticks'; -import attachElement from '../helpers/attach-element'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getForkedRepo, getRepo} from '../github-helpers/index.js'; +import pluralize from '../helpers/pluralize.js'; +import addNotice from '../github-widgets/notice-bar.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; +import parseBackticks from '../github-helpers/parse-backticks.js'; +import attachElement from '../helpers/attach-element.js'; function handleToggle(event: DelegateEvent<Event, HTMLDetailsElement>): void { const hasContent = select.exists([ diff --git a/source/features/quick-review-comment-deletion.tsx b/source/features/quick-review-comment-deletion.tsx index 2521fe93..447acfb5 100644 --- a/source/features/quick-review-comment-deletion.tsx +++ b/source/features/quick-review-comment-deletion.tsx @@ -4,10 +4,10 @@ import {TrashIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import loadDetailsMenu from '../github-helpers/load-details-menu'; -import showToast from '../github-helpers/toast'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import loadDetailsMenu from '../github-helpers/load-details-menu.js'; +import showToast from '../github-helpers/toast.js'; function onButtonClick({delegateTarget: button}: DelegateEvent): void { try { diff --git a/source/features/quick-review.tsx b/source/features/quick-review.tsx index 50763893..be6e54f5 100644 --- a/source/features/quick-review.tsx +++ b/source/features/quick-review.tsx @@ -4,8 +4,8 @@ import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function addSidebarReviewButton(reviewersSection: Element): void { const reviewFormUrl = new URL(location.href); diff --git a/source/features/reactions-avatars.tsx b/source/features/reactions-avatars.tsx index 9de1a53e..1038f19c 100644 --- a/source/features/reactions-avatars.tsx +++ b/source/features/reactions-avatars.tsx @@ -4,11 +4,11 @@ import select from 'select-dom'; import {flatZip} from 'flat-zip'; import * as pageDetect from 'github-url-detection'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import {getUsername} from '../github-helpers'; -import getUserAvatar from '../github-helpers/get-user-avatar'; -import onAbort from '../helpers/abort-controller'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import {getUsername} from '../github-helpers/index.js'; +import getUserAvatar from '../github-helpers/get-user-avatar.js'; +import onAbort from '../helpers/abort-controller.js'; const arbitraryAvatarLimit = 36; const approximateHeaderLength = 3; // Each button header takes about as much as 3 avatars diff --git a/source/features/release-download-count.tsx b/source/features/release-download-count.tsx index 9d5303f0..2f63a344 100644 --- a/source/features/release-download-count.tsx +++ b/source/features/release-download-count.tsx @@ -5,10 +5,10 @@ import {DownloadIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import {abbreviateNumber} from 'js-abbreviation-number'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import observe from '../helpers/selector-observer'; -import {createHeatIndexFunction} from '../helpers/math'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import observe from '../helpers/selector-observer.js'; +import {createHeatIndexFunction} from '../helpers/math.js'; type Release = { releaseAssets: { diff --git a/source/features/releases-dropdown.tsx b/source/features/releases-dropdown.tsx index 400cf2a7..a417ea88 100644 --- a/source/features/releases-dropdown.tsx +++ b/source/features/releases-dropdown.tsx @@ -3,10 +3,10 @@ import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; import cache from 'webext-storage-cache'; -import * as api from '../github-helpers/api'; -import features from '../feature-manager'; -import {buildRepoURL, cacheByRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import * as api from '../github-helpers/api.js'; +import features from '../feature-manager.js'; +import {buildRepoURL, cacheByRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; const gql = ` repository() { diff --git a/source/features/releases-tab.tsx b/source/features/releases-tab.tsx index 8598bbeb..c56eeccf 100644 --- a/source/features/releases-tab.tsx +++ b/source/features/releases-tab.tsx @@ -5,16 +5,16 @@ import {TagIcon} from '@primer/octicons-react'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import looseParseInt from '../helpers/loose-parse-int'; -import abbreviateNumber from '../helpers/abbreviate-number'; -import createDropdownItem from '../github-helpers/create-dropdown-item'; -import {buildRepoURL, cacheByRepo} from '../github-helpers'; -import {releasesSidebarSelector} from './clean-repo-sidebar'; -import {appendBefore, highlightTab, unhighlightTab} from '../helpers/dom-utils'; -import {underlineNavDropdownUl} from '../github-helpers/selectors'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; +import abbreviateNumber from '../helpers/abbreviate-number.js'; +import createDropdownItem from '../github-helpers/create-dropdown-item.js'; +import {buildRepoURL, cacheByRepo} from '../github-helpers/index.js'; +import {releasesSidebarSelector} from './clean-repo-sidebar.js'; +import {appendBefore, highlightTab, unhighlightTab} from '../helpers/dom-utils.js'; +import {underlineNavDropdownUl} from '../github-helpers/selectors.js'; const cacheName = 'releases-count'; diff --git a/source/features/reload-failed-proxied-images.tsx b/source/features/reload-failed-proxied-images.tsx index cb217364..a78c54b8 100644 --- a/source/features/reload-failed-proxied-images.tsx +++ b/source/features/reload-failed-proxied-images.tsx @@ -3,7 +3,7 @@ import onetime from 'onetime'; import loadImage from 'image-promise'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; async function handleErroredImage({delegateTarget}: DelegateEvent<ErrorEvent, HTMLImageElement>): Promise<void> { console.log('Refined GitHub: image failed loading, will retry', delegateTarget.src); diff --git a/source/features/repo-age.tsx b/source/features/repo-age.tsx index 349644c6..60cf305f 100644 --- a/source/features/repo-age.tsx +++ b/source/features/repo-age.tsx @@ -5,9 +5,9 @@ import {RepoIcon} from '@primer/octicons-react'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {cacheByRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {cacheByRepo} from '../github-helpers/index.js'; type CommitTarget = { oid: string; @@ -40,7 +40,7 @@ const dateFormatter = new Intl.DateTimeFormat('en-US', { day: 'numeric', }); -const getRepoAge = async (commitSha: string, commitsCount: number): Promise<[committedDate: string, resourcePath: string]> => { +async function getRepoAge(commitSha: string, commitsCount: number): Promise<[committedDate: string, resourcePath: string]> { const {repository} = await api.v4(` repository() { defaultBranchRef { @@ -64,7 +64,7 @@ const getRepoAge = async (commitSha: string, commitsCount: number): Promise<[com .find((commit: CommitTarget) => new Date(commit.committedDate).getFullYear() > 1970); return [committedDate, resourcePath]; -}; +} const getFirstCommit = cache.function('first-commit', async (): Promise<[committedDate: string, resourcePath: string]> => { const {repository} = await api.v4(` diff --git a/source/features/repo-avatars.tsx b/source/features/repo-avatars.tsx index 18ab95b0..42583502 100644 --- a/source/features/repo-avatars.tsx +++ b/source/features/repo-avatars.tsx @@ -3,9 +3,9 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {getRepo} from '../github-helpers'; -import getUserAvatar from '../github-helpers/get-user-avatar'; +import features from '../feature-manager.js'; +import {getRepo} from '../github-helpers/index.js'; +import getUserAvatar from '../github-helpers/get-user-avatar.js'; async function init(): Promise<void> { // Icon for public but not template/fork/etc. repos diff --git a/source/features/repo-wide-file-finder.tsx b/source/features/repo-wide-file-finder.tsx index c681365f..edc27e57 100644 --- a/source/features/repo-wide-file-finder.tsx +++ b/source/features/repo-wide-file-finder.tsx @@ -1,10 +1,10 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {buildRepoURL, getCurrentCommittish} from '../github-helpers'; -import {registerHotkey} from '../github-helpers/hotkey'; +import features from '../feature-manager.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {buildRepoURL, getCurrentCommittish} from '../github-helpers/index.js'; +import {registerHotkey} from '../github-helpers/hotkey.js'; async function init(): Promise<void> { registerHotkey('t', buildRepoURL('tree', getCurrentCommittish() ?? await getDefaultBranch()) + '?search=1'); diff --git a/source/features/resolve-conflicts.tsx b/source/features/resolve-conflicts.tsx index ac022744..d1f1fb90 100644 --- a/source/features/resolve-conflicts.tsx +++ b/source/features/resolve-conflicts.tsx @@ -3,7 +3,7 @@ import React from 'dom-chef'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; async function init(): Promise<void> { await elementReady('.CodeMirror', { diff --git a/source/features/restore-file.tsx b/source/features/restore-file.tsx index a0d5bc41..c4de4814 100644 --- a/source/features/restore-file.tsx +++ b/source/features/restore-file.tsx @@ -4,11 +4,11 @@ import onetime from 'onetime'; import delegate, {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import showToast from '../github-helpers/toast'; -import {getConversationNumber} from '../github-helpers'; -import {getBranches} from '../github-helpers/pr-branches'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import showToast from '../github-helpers/toast.js'; +import {getConversationNumber} from '../github-helpers/index.js'; +import {getBranches} from '../github-helpers/pr-branches.js'; // Get the current base commit of this PR. It should change after rebases and merges in this PR. // This value is not consistently available on the page (appears in `/files` but not when only 1 commit is selected) diff --git a/source/features/rgh-feature-descriptions.tsx b/source/features/rgh-feature-descriptions.tsx index 6e258173..d1a7d655 100644 --- a/source/features/rgh-feature-descriptions.tsx +++ b/source/features/rgh-feature-descriptions.tsx @@ -4,13 +4,13 @@ import * as pageDetect from 'github-url-detection'; import {CopyIcon} from '@primer/octicons-react'; import cache from 'webext-storage-cache'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; import {featuresMeta} from '../../readme.md'; -import {getNewFeatureName} from '../options-storage'; -import {isRefinedGitHubRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; -import {HotfixStorage} from '../helpers/hotfix'; -import {createRghIssueLink} from '../helpers/rgh-issue-link'; +import {getNewFeatureName} from '../options-storage.js'; +import {isRefinedGitHubRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; +import {HotfixStorage} from '../helpers/hotfix.js'; +import {createRghIssueLink} from '../helpers/rgh-issue-link.js'; async function add(infoBanner: HTMLElement): Promise<void> { const [, currentFeature] = /source\/features\/([^.]+)/.exec(location.pathname) ?? []; diff --git a/source/features/rgh-improve-new-issue-form.tsx b/source/features/rgh-improve-new-issue-form.tsx index d5f81b8a..7fd42bb0 100644 --- a/source/features/rgh-improve-new-issue-form.tsx +++ b/source/features/rgh-improve-new-issue-form.tsx @@ -2,11 +2,11 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import openOptions from '../helpers/open-options'; -import clearCacheHandler from '../helpers/clear-cache-handler'; -import {expectToken, expectTokenScope} from '../github-helpers/api'; -import {isRefinedGitHubRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import openOptions from '../helpers/open-options.js'; +import clearCacheHandler from '../helpers/clear-cache-handler.js'; +import {expectToken, expectTokenScope} from '../github-helpers/api.js'; +import {isRefinedGitHubRepo} from '../github-helpers/index.js'; function addNotice(adjective: JSX.Element | string): void { select('#issue_body_template_name')!.before( diff --git a/source/features/rgh-linkify-features.tsx b/source/features/rgh-linkify-features.tsx index 28edd023..9a6f2ad4 100644 --- a/source/features/rgh-linkify-features.tsx +++ b/source/features/rgh-linkify-features.tsx @@ -1,12 +1,12 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import {wrap} from '../helpers/dom-utils'; -import features from '../feature-manager'; -import featureLink from '../helpers/feature-link'; -import {getNewFeatureName} from '../options-storage'; -import {isAnyRefinedGitHubRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; +import {wrap} from '../helpers/dom-utils.js'; +import features from '../feature-manager.js'; +import featureLink from '../helpers/feature-link.js'; +import {getNewFeatureName} from '../options-storage.js'; +import {isAnyRefinedGitHubRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; function linkifyFeature(possibleFeature: HTMLElement): void { const id = getNewFeatureName(possibleFeature.textContent!); diff --git a/source/features/rgh-linkify-yolo-issues.tsx b/source/features/rgh-linkify-yolo-issues.tsx index 87cc8444..cabd6a29 100644 --- a/source/features/rgh-linkify-yolo-issues.tsx +++ b/source/features/rgh-linkify-yolo-issues.tsx @@ -1,9 +1,9 @@ import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {isRefinedGitHubYoloRepo} from '../github-helpers'; -import observe from '../helpers/selector-observer'; -import {linkifyIssues} from '../github-helpers/dom-formatters'; +import features from '../feature-manager.js'; +import {isRefinedGitHubYoloRepo} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; +import {linkifyIssues} from '../github-helpers/dom-formatters.js'; // Linkify with hovercards function linkify(issueCell: HTMLElement): void { diff --git a/source/features/rgh-netiquette.tsx b/source/features/rgh-netiquette.tsx index 753a91be..6b66ef37 100644 --- a/source/features/rgh-netiquette.tsx +++ b/source/features/rgh-netiquette.tsx @@ -2,13 +2,13 @@ import React from 'dom-chef'; import {InfoIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; -import createBanner from '../github-helpers/banner'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import {isAnyRefinedGitHubRepo} from '../github-helpers'; -import {getNoticeText, shouldDisplayNotice} from './netiquette'; -import TimelineItem from '../github-helpers/timeline-item'; -import {isHasSelectorSupported} from '../helpers/select-has'; +import createBanner from '../github-helpers/banner.js'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import {isAnyRefinedGitHubRepo} from '../github-helpers/index.js'; +import {getNoticeText, shouldDisplayNotice} from './netiquette.js'; +import TimelineItem from '../github-helpers/timeline-item.js'; +import {isHasSelectorSupported} from '../helpers/select-has.js'; function addConversationBanner(newCommentBox: HTMLElement): void { const button = ( diff --git a/source/features/rgh-sponsor-button.tsx b/source/features/rgh-sponsor-button.tsx index d73fc65e..c6d03f5f 100644 --- a/source/features/rgh-sponsor-button.tsx +++ b/source/features/rgh-sponsor-button.tsx @@ -27,8 +27,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import {getRepo, getUsername} from '../github-helpers'; +import features from '../feature-manager.js'; +import {getRepo, getUsername} from '../github-helpers/index.js'; async function wiggleWiggleWiggle(): Promise<void> { await cache.set('did-it-wiggle', 'yup', {days: 7}); diff --git a/source/features/rgh-welcome-issue.tsx b/source/features/rgh-welcome-issue.tsx index 40f8a255..86a2de2f 100644 --- a/source/features/rgh-welcome-issue.tsx +++ b/source/features/rgh-welcome-issue.tsx @@ -2,8 +2,8 @@ import './rgh-welcome-issue.css'; import select from 'select-dom'; import delegate from 'delegate-it'; -import features from '../feature-manager'; -import openOptions from '../helpers/open-options'; +import features from '../feature-manager.js'; +import openOptions from '../helpers/open-options.js'; /** @file This issue has specific hidden links to wrap the text and then this feature creates a visible link only when the extension is installed. diff --git a/source/features/same-branch-author-commits.tsx b/source/features/same-branch-author-commits.tsx index f988c55d..84afda1c 100644 --- a/source/features/same-branch-author-commits.tsx +++ b/source/features/same-branch-author-commits.tsx @@ -1,7 +1,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function init(): void { for (const author of select.all('.js-navigation-container a.commit-author')) { diff --git a/source/features/scrollable-areas.tsx b/source/features/scrollable-areas.tsx index ef232525..d49da827 100644 --- a/source/features/scrollable-areas.tsx +++ b/source/features/scrollable-areas.tsx @@ -1,5 +1,5 @@ import './scrollable-areas.css'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; void features.addCssFeature(import.meta.url); diff --git a/source/features/select-all-notifications-shortcut.tsx b/source/features/select-all-notifications-shortcut.tsx index 91f46805..96b2d4d8 100644 --- a/source/features/select-all-notifications-shortcut.tsx +++ b/source/features/select-all-notifications-shortcut.tsx @@ -1,8 +1,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {registerHotkey} from '../github-helpers/hotkey'; +import features from '../feature-manager.js'; +import {registerHotkey} from '../github-helpers/hotkey.js'; function selectAllNotifications(): void { select('.js-notifications-mark-all-prompt')!.click(); diff --git a/source/features/select-notifications.tsx b/source/features/select-notifications.tsx index 628ac88f..f45670eb 100644 --- a/source/features/select-notifications.tsx +++ b/source/features/select-notifications.tsx @@ -16,8 +16,8 @@ import { XCircleIcon, } from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; const filters = { 'Pull requests': ':is(.octicon-git-pull-request, .octicon-git-pull-request-closed, .octicon-git-pull-request-draft, .octicon-git-merge)', diff --git a/source/features/selection-in-new-tab.tsx b/source/features/selection-in-new-tab.tsx index 6d6ddc9d..5864289b 100644 --- a/source/features/selection-in-new-tab.tsx +++ b/source/features/selection-in-new-tab.tsx @@ -1,8 +1,8 @@ import select from 'select-dom'; import onetime from 'onetime'; -import features from '../feature-manager'; -import {registerHotkey} from '../github-helpers/hotkey'; +import features from '../feature-manager.js'; +import {registerHotkey} from '../github-helpers/hotkey.js'; function openInNewTab(): void { const selected = select('.navigation-focus a.js-navigation-open[href]'); diff --git a/source/features/shorten-links.tsx b/source/features/shorten-links.tsx index 8e7fcebf..1d95ef9c 100644 --- a/source/features/shorten-links.tsx +++ b/source/features/shorten-links.tsx @@ -1,8 +1,8 @@ import onetime from 'onetime'; -import features from '../feature-manager'; -import {linkifiedURLClass, shortenLink} from '../github-helpers/dom-formatters'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {linkifiedURLClass, shortenLink} from '../github-helpers/dom-formatters.js'; +import observe from '../helpers/selector-observer.js'; /* This feature is currently so broad that it's not de-inited via signal, it's just run once for all pageloads #5889 */ function init(): void { diff --git a/source/features/show-associated-branch-prs-on-fork.tsx b/source/features/show-associated-branch-prs-on-fork.tsx index e692706f..3e52c9e4 100644 --- a/source/features/show-associated-branch-prs-on-fork.tsx +++ b/source/features/show-associated-branch-prs-on-fork.tsx @@ -3,10 +3,10 @@ import cache from 'webext-storage-cache'; import * as pageDetect from 'github-url-detection'; import {GitMergeIcon, GitPullRequestIcon, GitPullRequestClosedIcon, GitPullRequestDraftIcon} from '@primer/octicons-react'; -import observe from '../helpers/selector-observer'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {cacheByRepo, upperCaseFirst} from '../github-helpers'; +import observe from '../helpers/selector-observer.js'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {cacheByRepo, upperCaseFirst} from '../github-helpers/index.js'; type PullRequest = { timelineItems: { diff --git a/source/features/show-names.tsx b/source/features/show-names.tsx index 4567f6e3..852b2910 100644 --- a/source/features/show-names.tsx +++ b/source/features/show-names.tsx @@ -3,11 +3,11 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; import batchedFunction from 'batched-function'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getUsername, compareNames} from '../github-helpers'; -import observe from '../helpers/selector-observer'; -import {removeTextNodeContaining} from '../helpers/dom-utils'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getUsername, compareNames} from '../github-helpers/index.js'; +import observe from '../helpers/selector-observer.js'; +import {removeTextNodeContaining} from '../helpers/dom-utils.js'; // The selector observer calls this function several times, but we want to batch them into a single GraphQL API call const batchUpdateLinks = batchedFunction(async (batchedUsernameElements: HTMLAnchorElement[]): Promise<void> => { diff --git a/source/features/show-open-prs-of-forks.tsx b/source/features/show-open-prs-of-forks.tsx index fe18d809..ef27062a 100644 --- a/source/features/show-open-prs-of-forks.tsx +++ b/source/features/show-open-prs-of-forks.tsx @@ -4,10 +4,10 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import pluralize from '../helpers/pluralize'; -import {getForkedRepo, getUsername, getRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import pluralize from '../helpers/pluralize.js'; +import {getForkedRepo, getUsername, getRepo} from '../github-helpers/index.js'; function getLinkCopy(count: number): string { return pluralize(count, 'one open pull request', 'at least $$ open pull requests'); diff --git a/source/features/show-user-top-repositories.tsx b/source/features/show-user-top-repositories.tsx index d59d59c6..7885fe07 100644 --- a/source/features/show-user-top-repositories.tsx +++ b/source/features/show-user-top-repositories.tsx @@ -1,8 +1,8 @@ import React from 'dom-chef'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function addLink(showCaseTitle: Element): void { const url = new URL(location.pathname, location.href); diff --git a/source/features/show-whitespace.tsx b/source/features/show-whitespace.tsx index 9f1b60cc..520c316f 100644 --- a/source/features/show-whitespace.tsx +++ b/source/features/show-whitespace.tsx @@ -1,11 +1,11 @@ import './show-whitespace.css'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {codeElementsSelector} from '../github-helpers/dom-formatters'; -import showWhiteSpacesOnLine from '../helpers/show-whitespace-on-line'; -import onAbort from '../helpers/abort-controller'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import {codeElementsSelector} from '../github-helpers/dom-formatters.js'; +import showWhiteSpacesOnLine from '../helpers/show-whitespace-on-line.js'; +import onAbort from '../helpers/abort-controller.js'; +import observe from '../helpers/selector-observer.js'; const viewportObserver = new IntersectionObserver(changes => { for (const {target: line, isIntersecting} of changes) { diff --git a/source/features/small-user-avatars.tsx b/source/features/small-user-avatars.tsx index 45156bc7..38f20e5c 100644 --- a/source/features/small-user-avatars.tsx +++ b/source/features/small-user-avatars.tsx @@ -3,8 +3,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import getUserAvatarURL from '../github-helpers/get-user-avatar'; +import features from '../feature-manager.js'; +import getUserAvatarURL from '../github-helpers/get-user-avatar.js'; function init(): void { for (const link of select.all( diff --git a/source/features/sort-conversations-by-update-time.tsx b/source/features/sort-conversations-by-update-time.tsx index 9fa2dddb..a63292f6 100644 --- a/source/features/sort-conversations-by-update-time.tsx +++ b/source/features/sort-conversations-by-update-time.tsx @@ -2,9 +2,9 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import elementReady from 'element-ready'; -import features from '../feature-manager'; -import SearchQuery from '../github-helpers/search-query'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import SearchQuery from '../github-helpers/search-query.js'; +import observe from '../helpers/selector-observer.js'; /** Keep the original URL on the element so that `shorten-links` can use it reliably #5890 */ export function saveOriginalHref(link: HTMLAnchorElement): void { diff --git a/source/features/sticky-sidebar.tsx b/source/features/sticky-sidebar.tsx index efc8746c..1fff60f3 100644 --- a/source/features/sticky-sidebar.tsx +++ b/source/features/sticky-sidebar.tsx @@ -2,10 +2,10 @@ import './sticky-sidebar.css'; import debounce from 'debounce-fn'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import onAbort from '../helpers/abort-controller'; -import calculateCssCalcString from '../helpers/calculate-css-calc-string'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import onAbort from '../helpers/abort-controller.js'; +import calculateCssCalcString from '../helpers/calculate-css-calc-string.js'; const minimumViewportWidthForSidebar = 768; // Less than this, the layout is single-column diff --git a/source/features/stop-redirecting-in-notification-bar.tsx b/source/features/stop-redirecting-in-notification-bar.tsx index 562f1ad4..c97b0a20 100644 --- a/source/features/stop-redirecting-in-notification-bar.tsx +++ b/source/features/stop-redirecting-in-notification-bar.tsx @@ -1,6 +1,6 @@ import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; const hasNotificationBar = (): boolean => location.search.startsWith('?notification_referrer_id=') diff --git a/source/features/submission-via-ctrl-enter-everywhere.tsx b/source/features/submission-via-ctrl-enter-everywhere.tsx index 36450826..1472b9ea 100644 --- a/source/features/submission-via-ctrl-enter-everywhere.tsx +++ b/source/features/submission-via-ctrl-enter-everywhere.tsx @@ -1,7 +1,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; function addQuickSubmit(): void { select([ diff --git a/source/features/suggest-commit-title-limit.tsx b/source/features/suggest-commit-title-limit.tsx index 6f175785..8d9d7090 100644 --- a/source/features/suggest-commit-title-limit.tsx +++ b/source/features/suggest-commit-title-limit.tsx @@ -2,8 +2,8 @@ import './suggest-commit-title-limit.css'; import type {DelegateEvent} from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import onCommitTitleUpdate from '../github-events/on-commit-title-update'; +import features from '../feature-manager.js'; +import onCommitTitleUpdate from '../github-events/on-commit-title-update.js'; function validateInput({delegateTarget: field}: DelegateEvent<Event, HTMLInputElement>): void { field.classList.toggle('rgh-title-over-limit', field.value.length > 72); diff --git a/source/features/swap-branches-on-compare.tsx b/source/features/swap-branches-on-compare.tsx index f7a2baa6..ea29df1d 100644 --- a/source/features/swap-branches-on-compare.tsx +++ b/source/features/swap-branches-on-compare.tsx @@ -2,8 +2,8 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {buildRepoURL, getRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import {buildRepoURL, getRepo} from '../github-helpers/index.js'; const isTwoDotDiff = (): boolean => /\.\.+/.exec(location.pathname)?.[0]!.length === 2; diff --git a/source/features/sync-pr-commit-title.tsx b/source/features/sync-pr-commit-title.tsx index 80116198..c01d65b5 100644 --- a/source/features/sync-pr-commit-title.tsx +++ b/source/features/sync-pr-commit-title.tsx @@ -3,12 +3,12 @@ import select from 'select-dom'; import delegate from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import * as api from '../github-helpers/api'; -import features from '../feature-manager'; -import {getConversationNumber, userCanLikelyMergePR} from '../github-helpers'; -import onCommitTitleUpdate from '../github-events/on-commit-title-update'; -import observe from '../helpers/selector-observer'; -import cleanPrCommitTitle from '../helpers/pr-commit-cleaner'; +import * as api from '../github-helpers/api.js'; +import features from '../feature-manager.js'; +import {getConversationNumber, userCanLikelyMergePR} from '../github-helpers/index.js'; +import onCommitTitleUpdate from '../github-events/on-commit-title-update.js'; +import observe from '../helpers/selector-observer.js'; +import cleanPrCommitTitle from '../helpers/pr-commit-cleaner.js'; const prTitleFieldSelector = 'input#issue_title'; const commitTitleFieldSelector = '.is-squashing form:not([hidden]) input#merge_title_field'; diff --git a/source/features/tab-to-indent.tsx b/source/features/tab-to-indent.tsx index e326ff5e..e4bbeb6c 100644 --- a/source/features/tab-to-indent.tsx +++ b/source/features/tab-to-indent.tsx @@ -1,8 +1,8 @@ import {eventHandler} from 'indent-textarea'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import {onCommentFieldKeydown} from '../github-events/on-field-keydown'; +import features from '../feature-manager.js'; +import {onCommentFieldKeydown} from '../github-events/on-field-keydown.js'; function init(signal: AbortSignal): void { onCommentFieldKeydown(eventHandler, signal); diff --git a/source/features/table-input.tsx b/source/features/table-input.tsx index f145129c..3dd2cced 100644 --- a/source/features/table-input.tsx +++ b/source/features/table-input.tsx @@ -5,10 +5,10 @@ import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import smartBlockWrap from '../helpers/smart-block-wrap'; -import observe from '../helpers/selector-observer'; -import {isHasSelectorSupported} from '../helpers/select-has'; +import features from '../feature-manager.js'; +import smartBlockWrap from '../helpers/smart-block-wrap.js'; +import observe from '../helpers/selector-observer.js'; +import {isHasSelectorSupported} from '../helpers/select-has.js'; function addTable({delegateTarget: square}: DelegateEvent<MouseEvent, HTMLButtonElement>): void { /* There's only one rich-text editor even when multiple fields are visible; the class targets it #5303 */ diff --git a/source/features/tag-changes-link.tsx b/source/features/tag-changes-link.tsx index 26ab4275..fd1232b8 100644 --- a/source/features/tag-changes-link.tsx +++ b/source/features/tag-changes-link.tsx @@ -6,9 +6,9 @@ import {DiffIcon} from '@primer/octicons-react'; import * as pageDetect from 'github-url-detection'; import tinyVersionCompare from 'tiny-version-compare'; -import features from '../feature-manager'; -import fetchDom from '../helpers/fetch-dom'; -import {buildRepoURL, getRepo, parseTag} from '../github-helpers'; +import features from '../feature-manager.js'; +import fetchDom from '../helpers/fetch-dom.js'; +import {buildRepoURL, getRepo, parseTag} from '../github-helpers/index.js'; type TagDetails = { element: HTMLElement; @@ -45,7 +45,7 @@ function parseTags(element: HTMLElement): TagDetails { }; } -const getPreviousTag = (current: number, allTags: TagDetails[]): string | undefined => { +function getPreviousTag(current: number, allTags: TagDetails[]): string | undefined { let unmatchedNamespaceTag: string | undefined; for (let next = current + 1; next < allTags.length; next++) { @@ -70,7 +70,7 @@ const getPreviousTag = (current: number, allTags: TagDetails[]): string | undefi } return unmatchedNamespaceTag; -}; +} async function init(): Promise<void> { document.documentElement.classList.add('rgh-tag-changes-link'); diff --git a/source/features/tags-on-commits-list.tsx b/source/features/tags-on-commits-list.tsx index 1d8d47af..ce192665 100644 --- a/source/features/tags-on-commits-list.tsx +++ b/source/features/tags-on-commits-list.tsx @@ -5,10 +5,10 @@ import {TagIcon} from '@primer/octicons-react'; import arrayUnion from 'array-union'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getCommitHash} from './mark-merge-commits-in-list'; -import {buildRepoURL, getRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getCommitHash} from './mark-merge-commits-in-list.js'; +import {buildRepoURL, getRepo} from '../github-helpers/index.js'; type CommitTags = Record<string, string[]>; diff --git a/source/features/toggle-everything-with-alt.tsx b/source/features/toggle-everything-with-alt.tsx index 1c590381..487014da 100644 --- a/source/features/toggle-everything-with-alt.tsx +++ b/source/features/toggle-everything-with-alt.tsx @@ -1,8 +1,8 @@ import delegate from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import clickAll from '../helpers/click-all'; +import features from '../feature-manager.js'; +import clickAll from '../helpers/click-all.js'; function minimizedCommentsSelector(clickedItem: HTMLElement): string { const open = (clickedItem.parentElement as HTMLDetailsElement).open ? '[open]' : ':not([open])'; diff --git a/source/features/toggle-files-button.tsx b/source/features/toggle-files-button.tsx index ed8043d8..d81e94b3 100644 --- a/source/features/toggle-files-button.tsx +++ b/source/features/toggle-files-button.tsx @@ -6,10 +6,10 @@ import delegate from 'delegate-it'; import * as pageDetect from 'github-url-detection'; import {FoldIcon, UnfoldIcon, ArrowUpIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import selectHas from '../helpers/select-has'; -import attachElement from '../helpers/attach-element'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import selectHas from '../helpers/select-has.js'; +import attachElement from '../helpers/attach-element.js'; +import observe from '../helpers/selector-observer.js'; const cacheKey = 'files-hidden'; const hiddenFilesClass = 'rgh-files-hidden'; diff --git a/source/features/unfinished-comments.tsx b/source/features/unfinished-comments.tsx index a8d5858d..2e824ec1 100644 --- a/source/features/unfinished-comments.tsx +++ b/source/features/unfinished-comments.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import delegate from 'delegate-it'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; let documentTitle: string | undefined; let submitting: number | undefined; diff --git a/source/features/unreleased-commits.tsx b/source/features/unreleased-commits.tsx index 5932bdec..c789624e 100644 --- a/source/features/unreleased-commits.tsx +++ b/source/features/unreleased-commits.tsx @@ -3,12 +3,12 @@ import cache from 'webext-storage-cache'; import * as pageDetect from 'github-url-detection'; import {TagIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import * as api from '../github-helpers/api'; -import {buildRepoURL, cacheByRepo, getCurrentCommittish, getLatestVersionTag} from '../github-helpers'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import pluralize from '../helpers/pluralize'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import * as api from '../github-helpers/api.js'; +import {buildRepoURL, cacheByRepo, getCurrentCommittish, getLatestVersionTag} from '../github-helpers/index.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import pluralize from '../helpers/pluralize.js'; type RepoPublishState = { latestTag: string | false; diff --git a/source/features/unwrap-unnecessary-dropdowns.tsx b/source/features/unwrap-unnecessary-dropdowns.tsx index a324f3e1..08f0b1f0 100644 --- a/source/features/unwrap-unnecessary-dropdowns.tsx +++ b/source/features/unwrap-unnecessary-dropdowns.tsx @@ -2,7 +2,7 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; // Replace dropdown while keeping its sizing/positioning classes function replaceDropdownInPlace(dropdown: Element, form: Element): void { diff --git a/source/features/update-pr-from-base-branch.tsx b/source/features/update-pr-from-base-branch.tsx index ea0004a2..8d5812a9 100644 --- a/source/features/update-pr-from-base-branch.tsx +++ b/source/features/update-pr-from-base-branch.tsx @@ -6,15 +6,15 @@ import delegate, {DelegateEvent} from 'delegate-it'; import {CheckIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import * as api from '../github-helpers/api'; -import {getBranches} from '../github-helpers/pr-branches'; -import getPrInfo from '../github-helpers/get-pr-info'; -import showToast from '../github-helpers/toast'; -import {getConversationNumber} from '../github-helpers'; -import createMergeabilityRow from '../github-widgets/mergeability-row'; -import selectHas from '../helpers/select-has'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import * as api from '../github-helpers/api.js'; +import {getBranches} from '../github-helpers/pr-branches.js'; +import getPrInfo from '../github-helpers/get-pr-info.js'; +import showToast from '../github-helpers/toast.js'; +import {getConversationNumber} from '../github-helpers/index.js'; +import createMergeabilityRow from '../github-widgets/mergeability-row.js'; +import selectHas from '../helpers/select-has.js'; const canMerge = '.merge-pr > .color-fg-muted:first-child'; const canNativelyUpdate = '.js-update-branch-form'; diff --git a/source/features/use-first-commit-message-for-new-prs.tsx b/source/features/use-first-commit-message-for-new-prs.tsx index fe3d9a5d..c952e98c 100644 --- a/source/features/use-first-commit-message-for-new-prs.tsx +++ b/source/features/use-first-commit-message-for-new-prs.tsx @@ -3,8 +3,8 @@ import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; -import features from '../feature-manager'; -import looseParseInt from '../helpers/loose-parse-int'; +import features from '../feature-manager.js'; +import looseParseInt from '../helpers/loose-parse-int.js'; function interpretNode(node: ChildNode): string | void { switch (node instanceof Element && node.tagName) { diff --git a/source/features/useful-not-found-page.tsx b/source/features/useful-not-found-page.tsx index 0cd30fad..6c28fd27 100644 --- a/source/features/useful-not-found-page.tsx +++ b/source/features/useful-not-found-page.tsx @@ -4,11 +4,11 @@ import onetime from 'onetime'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import GitHubURL from '../github-helpers/github-url'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {getCleanPathname} from '../github-helpers'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import GitHubURL from '../github-helpers/github-url.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {getCleanPathname} from '../github-helpers/index.js'; type File = { previous_filename?: string; diff --git a/source/features/user-local-time.tsx b/source/features/user-local-time.tsx index 215aeb92..6e940b98 100644 --- a/source/features/user-local-time.tsx +++ b/source/features/user-local-time.tsx @@ -7,10 +7,10 @@ import delay from 'delay'; import select from 'select-dom'; import {ClockIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; -import * as api from '../github-helpers/api'; -import {getUsername} from '../github-helpers'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; +import * as api from '../github-helpers/api.js'; +import {getUsername} from '../github-helpers/index.js'; type Commit = { url: string; diff --git a/source/features/user-profile-follower-badge.tsx b/source/features/user-profile-follower-badge.tsx index 8bc05299..353729ad 100644 --- a/source/features/user-profile-follower-badge.tsx +++ b/source/features/user-profile-follower-badge.tsx @@ -3,10 +3,10 @@ import cache from 'webext-storage-cache'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import * as api from '../github-helpers/api'; -import {getUsername, getCleanPathname} from '../github-helpers'; -import attachElement from '../helpers/attach-element'; +import features from '../feature-manager.js'; +import * as api from '../github-helpers/api.js'; +import {getUsername, getCleanPathname} from '../github-helpers/index.js'; +import attachElement from '../helpers/attach-element.js'; const doesUserFollow = cache.function('user-follows', async (userA: string, userB: string): Promise<boolean> => { const {httpStatus} = await api.v3(`/users/${userA}/following/${userB}`, { diff --git a/source/features/vertical-front-matter.tsx b/source/features/vertical-front-matter.tsx index 3277570e..f26ab3a0 100644 --- a/source/features/vertical-front-matter.tsx +++ b/source/features/vertical-front-matter.tsx @@ -4,7 +4,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import elementReady from 'element-ready'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; // https://github.com/github/markup/blob/cd01f9ec87c86ce5a7c70188a74ef40fc4669c5b/lib/github/markup/markdown.rb#L34 const hasFrontMatter = (): boolean => pageDetect.isSingleFile() && /\.(mdx?|mkdn?|mdwn|mdown|markdown|litcoffee)$/.test(location.pathname); diff --git a/source/features/view-last-pr-deployment.tsx b/source/features/view-last-pr-deployment.tsx index b99d948e..c70b3991 100644 --- a/source/features/view-last-pr-deployment.tsx +++ b/source/features/view-last-pr-deployment.tsx @@ -3,8 +3,8 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import {RocketIcon} from '@primer/octicons-react'; -import features from '../feature-manager'; -import observe from '../helpers/selector-observer'; +import features from '../feature-manager.js'; +import observe from '../helpers/selector-observer.js'; function addLink(header: HTMLElement): void { const lastDeployment = select.last('.js-timeline-item a[title="Deployment has completed"]'); diff --git a/source/features/wait-for-attachments.tsx b/source/features/wait-for-attachments.tsx index 8f211113..49d1e403 100644 --- a/source/features/wait-for-attachments.tsx +++ b/source/features/wait-for-attachments.tsx @@ -5,7 +5,7 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; const attribute = 'data-required-trimmed'; const attributeBackup = 'data-rgh-required-trimmed'; diff --git a/source/features/wait-for-checks.tsx b/source/features/wait-for-checks.tsx index 89186e23..c595fdcb 100644 --- a/source/features/wait-for-checks.tsx +++ b/source/features/wait-for-checks.tsx @@ -7,13 +7,13 @@ import * as pageDetect from 'github-url-detection'; import pRetry, {AbortError} from 'p-retry'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import observeElement from '../helpers/simplified-element-observer'; -import * as prCiStatus from '../github-helpers/pr-ci-status'; -import onPrMergePanelOpen from '../github-events/on-pr-merge-panel-open'; -import {onPrMergePanelLoad} from '../github-events/on-fragment-load'; -import onAbort from '../helpers/abort-controller'; -import {userCanLikelyMergePR} from '../github-helpers'; +import features from '../feature-manager.js'; +import observeElement from '../helpers/simplified-element-observer.js'; +import * as prCiStatus from '../github-helpers/pr-ci-status.js'; +import onPrMergePanelOpen from '../github-events/on-pr-merge-panel-open.js'; +import {onPrMergePanelLoad} from '../github-events/on-fragment-load.js'; +import onAbort from '../helpers/abort-controller.js'; +import {userCanLikelyMergePR} from '../github-helpers/index.js'; // Reuse the same checkbox to preserve its status const generateCheckbox = onetime(() => ( diff --git a/source/features/warn-pr-from-master.tsx b/source/features/warn-pr-from-master.tsx index e4033bb4..34f53c21 100644 --- a/source/features/warn-pr-from-master.tsx +++ b/source/features/warn-pr-from-master.tsx @@ -2,9 +2,9 @@ import React from 'dom-chef'; import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; -import features from '../feature-manager'; -import getDefaultBranch from '../github-helpers/get-default-branch'; -import {getRepo} from '../github-helpers'; +import features from '../feature-manager.js'; +import getDefaultBranch from '../github-helpers/get-default-branch.js'; +import {getRepo} from '../github-helpers/index.js'; async function init(): Promise<false | void> { let defaultBranch; diff --git a/source/features/warning-for-disallow-edits.tsx b/source/features/warning-for-disallow-edits.tsx index bc8e8d9d..6aba8e1b 100644 --- a/source/features/warning-for-disallow-edits.tsx +++ b/source/features/warning-for-disallow-edits.tsx @@ -5,8 +5,8 @@ import onetime from 'onetime'; import * as pageDetect from 'github-url-detection'; import delegate, {DelegateEvent} from 'delegate-it'; -import features from '../feature-manager'; -import attachElement from '../helpers/attach-element'; +import features from '../feature-manager.js'; +import attachElement from '../helpers/attach-element.js'; const getWarning = onetime(() => ( <div className="flash flash-error mt-3 rgh-warning-for-disallow-edits"> diff --git a/source/github-events/on-pr-merge.ts b/source/github-events/on-pr-merge.ts index ed1436fe..16b49f2b 100644 --- a/source/github-events/on-pr-merge.ts +++ b/source/github-events/on-pr-merge.ts @@ -1,6 +1,6 @@ import {oneEvent} from 'delegate-it'; -import observe from '../helpers/selector-observer'; +import observe from '../helpers/selector-observer.js'; // This event ensures that the callback appears exclusively to the person that merged the PR and not anyone who was on the page at the time of the merge export default async function onPrMerge(callback: VoidFunction, signal: AbortSignal): Promise<void> { diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts index dc22f1ec..d0fd1043 100644 --- a/source/github-helpers/api.ts +++ b/source/github-helpers/api.ts @@ -5,7 +5,7 @@ next to the name of the feature that caused them. Usage: -import * as api from '../github-helpers/api'; +import * as api from '../github-helpers/api.js'; const user = await api.v3(`/users/${username}`); const repositoryCommits = await api.v3('commits'); // Without a leading `/`, this is equivalent to `/repo/$current-repository/commits` const data = await api.v4('{user(login: "user") {name}}'); @@ -29,9 +29,9 @@ import mem from 'mem'; import * as pageDetect from 'github-url-detection'; import {JsonObject, AsyncReturnType} from 'type-fest'; -import features from '../feature-manager'; -import {getRepo} from '.'; -import optionsStorage from '../options-storage'; +import features from '../feature-manager.js'; +import {getRepo} from './index.js'; +import optionsStorage from '../options-storage.js'; type JsonError = { message: string; diff --git a/source/github-helpers/does-file-exist.tsx b/source/github-helpers/does-file-exist.tsx index e0ed727b..b3709241 100644 --- a/source/github-helpers/does-file-exist.tsx +++ b/source/github-helpers/does-file-exist.tsx @@ -1,5 +1,5 @@ -import * as api from './api'; -import GitHubURL from './github-url'; +import * as api from './api.js'; +import GitHubURL from './github-url.js'; export default async function doesFileExist(url: GitHubURL): Promise<boolean> { const {repository} = await api.v4(` diff --git a/source/github-helpers/dom-formatters.tsx b/source/github-helpers/dom-formatters.tsx index 0ee063ad..5968b3e3 100644 --- a/source/github-helpers/dom-formatters.tsx +++ b/source/github-helpers/dom-formatters.tsx @@ -5,9 +5,9 @@ import {applyToLink} from 'shorten-repo-url'; import linkifyURLsCore from 'linkify-urls'; import linkifyIssuesCore from 'linkify-issues'; -import getTextNodes from '../helpers/get-text-nodes'; -import parseBackticksCore from './parse-backticks'; -import {buildRepoURL} from '.'; +import getTextNodes from '../helpers/get-text-nodes.js'; +import parseBackticksCore from './parse-backticks.js'; +import {buildRepoURL} from './index.js'; // Shared class necessary to avoid also shortening the links export const linkifiedURLClass = 'rgh-linkified-code'; diff --git a/source/github-helpers/get-default-branch.ts b/source/github-helpers/get-default-branch.ts index b8e13dcb..20e1992f 100644 --- a/source/github-helpers/get-default-branch.ts +++ b/source/github-helpers/get-default-branch.ts @@ -3,8 +3,8 @@ import select from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; -import * as api from './api'; -import {getRepo, getCurrentBranchFromFeed} from '.'; +import * as api from './api.js'; +import {getRepo, getCurrentBranchFromFeed} from './index.js'; // This regex should match all of these combinations: // "This branch is even with master." diff --git a/source/github-helpers/get-pr-info.ts b/source/github-helpers/get-pr-info.ts index 13c93d96..da2b05ca 100644 --- a/source/github-helpers/get-pr-info.ts +++ b/source/github-helpers/get-pr-info.ts @@ -1,5 +1,5 @@ -import * as api from './api'; -import {getConversationNumber} from '.'; +import * as api from './api.js'; +import {getConversationNumber} from './index.js'; export type PullRequestInfo = { // TODO: Use this for `restore-file` diff --git a/source/github-helpers/github-url.test.ts b/source/github-helpers/github-url.test.ts index 0f2674d6..ba934a55 100644 --- a/source/github-helpers/github-url.test.ts +++ b/source/github-helpers/github-url.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import GitHubURL from './github-url'; +import GitHubURL from './github-url.js'; test('branch', () => { const url = new GitHubURL('https://github.com/microsoft/TypeScript/tree/master'); diff --git a/source/github-helpers/github-url.ts b/source/github-helpers/github-url.ts index c06d2256..2f592f50 100644 --- a/source/github-helpers/github-url.ts +++ b/source/github-helpers/github-url.ts @@ -1,4 +1,4 @@ -import {getCurrentCommittish} from '.'; +import {getCurrentCommittish} from './index.js'; export default class GitHubURL { user = ''; diff --git a/source/github-helpers/group-buttons.tsx b/source/github-helpers/group-buttons.tsx index 5a94156a..79fed128 100644 --- a/source/github-helpers/group-buttons.tsx +++ b/source/github-helpers/group-buttons.tsx @@ -1,9 +1,9 @@ import React from 'dom-chef'; -import {wrapAll} from '../helpers/dom-utils'; +import {wrapAll} from '../helpers/dom-utils.js'; // Wrap a list of elements with BtnGroup + ensure each has BtnGroup-item -export const groupButtons = (buttons: Element[]): Element => { +export function groupButtons(buttons: Element[]): Element { // Ensure every button has this class for (let button of buttons) { if (!button.matches('button, .btn')) { @@ -24,10 +24,10 @@ export const groupButtons = (buttons: Element[]): Element => { } return group; -}; +} // Find immediate `.btn` siblings of `button` and wrap them with groupButtons -export const groupSiblings = (button: Element): Element => { +export function groupSiblings(button: Element): Element { const siblings = [button]; let previous = button.previousElementSibling; while (previous?.classList.contains('btn')) { @@ -42,4 +42,4 @@ export const groupSiblings = (button: Element): Element => { } return groupButtons(siblings); -}; +} diff --git a/source/github-helpers/hotkey.tsx b/source/github-helpers/hotkey.tsx index 771f3907..fac94972 100644 --- a/source/github-helpers/hotkey.tsx +++ b/source/github-helpers/hotkey.tsx @@ -13,10 +13,10 @@ export function registerHotkey(hotkey: string, action: VoidFunction | string): D } /** Safely add a hotkey to an element, preserving any existing ones and avoiding duplicates */ -export const addHotkey = (button: HTMLAnchorElement | HTMLButtonElement | undefined, hotkey: string): void => { +export function addHotkey(button: HTMLAnchorElement | HTMLButtonElement | undefined, hotkey: string): void { if (button) { const hotkeys = new Set(button.dataset.hotkey?.split(',')); hotkeys.add(hotkey); button.dataset.hotkey = [...hotkeys].join(','); } -}; +} diff --git a/source/github-helpers/hotkeys.test.ts b/source/github-helpers/hotkeys.test.ts index 9535b29a..887263f9 100644 --- a/source/github-helpers/hotkeys.test.ts +++ b/source/github-helpers/hotkeys.test.ts @@ -2,9 +2,9 @@ import {test, assert} from 'vitest'; import { addHotkey, -} from './hotkey'; +} from './hotkey.js'; -const testAddHotkey = (existing: string | undefined, added: string, final: string): void => { +function testAddHotkey(existing: string | undefined, added: string, final: string): void { const link = document.createElement('a'); if (existing) { link.setAttribute('data-hotkey', existing); @@ -12,7 +12,7 @@ const testAddHotkey = (existing: string | undefined, added: string, final: strin addHotkey(link, added); assert.equal(link.dataset.hotkey, final); -}; +} test('addHotkey if one is specified', testAddHotkey.bind(null, 'T-REX', diff --git a/source/github-helpers/index.test.ts b/source/github-helpers/index.test.ts index 4f1a9d08..04f8a08c 100644 --- a/source/github-helpers/index.test.ts +++ b/source/github-helpers/index.test.ts @@ -6,7 +6,7 @@ import { compareNames, getLatestVersionTag, shouldFeatureRun, -} from '.'; +} from './index.js'; test('getConversationNumber', () => { const pairs = new Map<string, number | undefined>([ diff --git a/source/github-helpers/index.ts b/source/github-helpers/index.ts index c42790a6..9b15454f 100644 --- a/source/github-helpers/index.ts +++ b/source/github-helpers/index.ts @@ -9,13 +9,13 @@ import * as pageDetect from 'github-url-detection'; export const getUsername = onetime(pageDetect.utils.getUsername); export const {getRepositoryInfo: getRepo, getCleanPathname} = pageDetect.utils; -export const getConversationNumber = (): number | undefined => { +export function getConversationNumber(): number | undefined { if (pageDetect.isPR() || pageDetect.isIssue()) { return Number(location.pathname.split('/')[4]); } return undefined; -}; +} export function getCurrentBranchFromFeed(): string | void { // Not `isRepoCommitList` because this works exclusively on the default branch @@ -76,9 +76,7 @@ export const isMac = navigator.userAgent.includes('Macintosh'); type Not<Yes, Not> = Yes extends Not ? never : Yes; type UnslashedString<S extends string> = Not<S, `/${string}` | `${string}/`>; -export const buildRepoURL = <S extends string>( - ...pathParts: RequireAtLeastOne<Array<UnslashedString<S> | number>, 0> -): string => { +export function buildRepoURL<S extends string>(...pathParts: RequireAtLeastOne<Array<UnslashedString<S> | number>, 0>): string { // TODO: Drop after https://github.com/sindresorhus/type-fest/issues/417 for (const part of pathParts) { if (typeof part === 'string' && /^\/|\/$/.test(part)) { @@ -87,16 +85,16 @@ export const buildRepoURL = <S extends string>( } return [location.origin, getRepo()?.nameWithOwner, ...pathParts].join('/'); -}; +} export function getForkedRepo(): string | undefined { return select('meta[name="octolytics-dimension-repository_parent_nwo"]')?.content; } -export const parseTag = (tag: string): {version: string; namespace: string} => { +export function parseTag(tag: string): {version: string; namespace: string} { const [, namespace = '', version = ''] = /(?:(.*)@)?([^@]+)/.exec(tag) ?? []; return {namespace, version}; -}; +} export function compareNames(username: string, realname: string): boolean { return username.replace(/-/g, '').toLowerCase() === realname.normalize('NFD').replace(/[\u0300-\u036F\W.]/g, '').toLowerCase(); diff --git a/source/github-helpers/parse-backticks.test.ts b/source/github-helpers/parse-backticks.test.ts index 1925925e..8c342cfd 100644 --- a/source/github-helpers/parse-backticks.test.ts +++ b/source/github-helpers/parse-backticks.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import {getParsedBackticksParts} from './parse-backticks'; +import {getParsedBackticksParts} from './parse-backticks.js'; function parseBackticks(string: string): string { return getParsedBackticksParts(string).map( diff --git a/source/github-helpers/pr-branches.test.ts b/source/github-helpers/pr-branches.test.ts index 486fc562..de9cbfba 100644 --- a/source/github-helpers/pr-branches.test.ts +++ b/source/github-helpers/pr-branches.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import {parseReferenceRaw} from './pr-branches'; +import {parseReferenceRaw} from './pr-branches.js'; test('parseReferenceRaw', () => { assert.deepEqual(parseReferenceRaw('fregante/mem:main', 'main'), { diff --git a/source/github-helpers/pr-ci-status.ts b/source/github-helpers/pr-ci-status.ts index 75ca6392..a49fe065 100644 --- a/source/github-helpers/pr-ci-status.ts +++ b/source/github-helpers/pr-ci-status.ts @@ -1,6 +1,6 @@ import select from 'select-dom'; -import * as api from './api'; +import * as api from './api.js'; export const SUCCESS = Symbol('Success'); export const FAILURE = Symbol('Failure'); diff --git a/source/github-helpers/prevent-link-loss.test.ts b/source/github-helpers/prevent-link-loss.test.ts index b882c288..02f8ca9f 100644 --- a/source/github-helpers/prevent-link-loss.test.ts +++ b/source/github-helpers/prevent-link-loss.test.ts @@ -7,7 +7,7 @@ import { prCommitUrlRegex, prCompareUrlRegex, discussionUrlRegex, -} from './prevent-link-loss'; +} from './prevent-link-loss.js'; function replacePrCommitLink(string: string): string { return string.replace(prCommitUrlRegex, preventPrCommitLinkLoss); diff --git a/source/github-helpers/prevent-link-loss.ts b/source/github-helpers/prevent-link-loss.ts index 2cc6a5ba..350aca01 100644 --- a/source/github-helpers/prevent-link-loss.ts +++ b/source/github-helpers/prevent-link-loss.ts @@ -1,5 +1,5 @@ /* eslint-disable max-params */ -import {getRepo} from '.'; +import {getRepo} from './index.js'; const currentRepo = getRepo() ?? {nameWithOwner: 'refined-github/refined-github'}; function getRepoReference(repoNameWithOwner: string, delemiter = ''): string { diff --git a/source/github-helpers/search-query.test.ts b/source/github-helpers/search-query.test.ts index 7fe16271..9c5707f9 100644 --- a/source/github-helpers/search-query.test.ts +++ b/source/github-helpers/search-query.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import SearchQuery from './search-query'; +import SearchQuery from './search-query.js'; test('.get', () => { const query = SearchQuery.from({q: 'wow'}); diff --git a/source/github-helpers/selectors.test.ts b/source/github-helpers/selectors.test.ts index c79d4f62..060e5352 100644 --- a/source/github-helpers/selectors.test.ts +++ b/source/github-helpers/selectors.test.ts @@ -2,7 +2,7 @@ import mem from 'mem'; import {test, assert, describe} from 'vitest'; import {JSDOM} from 'jsdom'; -import * as exports from './selectors'; +import * as exports from './selectors.js'; const fetchDocument = mem(async (url: string): Promise<JSDOM> => JSDOM.fromURL(url)); diff --git a/source/helpers/add-after-branch-selector.tsx b/source/helpers/add-after-branch-selector.tsx index e2e1c0fb..5ed5d35a 100644 --- a/source/helpers/add-after-branch-selector.tsx +++ b/source/helpers/add-after-branch-selector.tsx @@ -2,7 +2,7 @@ import React from 'dom-chef'; import select from 'select-dom'; import elementReady from 'element-ready'; -import {wrapAll} from './dom-utils'; +import {wrapAll} from './dom-utils.js'; export default async function addAfterBranchSelector(button: Element): Promise<void> { button.classList.add('ml-2'); diff --git a/source/helpers/attach-element.ts b/source/helpers/attach-element.ts index 381b301b..031925cf 100644 --- a/source/helpers/attach-element.ts +++ b/source/helpers/attach-element.ts @@ -2,7 +2,7 @@ import select from 'select-dom'; import {RequireAtLeastOne} from 'type-fest'; import {isDefined} from 'ts-extras'; -import getCallerID from './caller-id'; +import getCallerID from './caller-id.js'; type Position = 'append' | 'prepend' | 'before' | 'after' | 'forEach'; diff --git a/source/helpers/bisect.tsx b/source/helpers/bisect.tsx index 82d3c2ba..d7014ca5 100644 --- a/source/helpers/bisect.tsx +++ b/source/helpers/bisect.tsx @@ -3,8 +3,8 @@ import cache from 'webext-storage-cache'; import select from 'select-dom'; import elementReady from 'element-ready'; -import pluralize from './pluralize'; -import featureLink from './feature-link'; +import pluralize from './pluralize.js'; +import featureLink from './feature-link.js'; import {importedFeatures} from '../../readme.md'; // Split current list of features in half and create an options-like object to be applied on load diff --git a/source/helpers/calculate-css-calc-string.test.ts b/source/helpers/calculate-css-calc-string.test.ts index c3d86439..fb670a37 100644 --- a/source/helpers/calculate-css-calc-string.test.ts +++ b/source/helpers/calculate-css-calc-string.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import calculateCssCalcString from './calculate-css-calc-string'; +import calculateCssCalcString from './calculate-css-calc-string.js'; test('calculateCssCalcString', () => { assert.equal(calculateCssCalcString('calc(1px)'), 1); diff --git a/source/helpers/calculate-css-calc-string.ts b/source/helpers/calculate-css-calc-string.ts index e711ca85..18527afd 100644 --- a/source/helpers/calculate-css-calc-string.ts +++ b/source/helpers/calculate-css-calc-string.ts @@ -1,4 +1,4 @@ -import looseParseInt from './loose-parse-int'; +import looseParseInt from './loose-parse-int.js'; /** Compute the sum in a `calc()`. Only works with very simple sums of px values. diff --git a/source/helpers/caller-id.test.ts b/source/helpers/caller-id.test.ts index 42d93783..3cfa5ce5 100644 --- a/source/helpers/caller-id.test.ts +++ b/source/helpers/caller-id.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import {getStackLine} from './caller-id'; +import {getStackLine} from './caller-id.js'; test('getCallerID: getStackLine', () => { assert.equal(getStackLine('A\nB', 0), 'A'); diff --git a/source/helpers/caller-id.ts b/source/helpers/caller-id.ts index a4fcefb1..91e1ab0e 100644 --- a/source/helpers/caller-id.ts +++ b/source/helpers/caller-id.ts @@ -1,4 +1,4 @@ -import hashString from './hash-string'; +import hashString from './hash-string.js'; /** Get unique ID by using the line:column of the call (or its parents) as seed. Every call from the same place will return the same ID, as long as the index is set to the parents that matters to you. diff --git a/source/helpers/clean-commit-message.test.ts b/source/helpers/clean-commit-message.test.ts index 0ba95ec5..680d82dd 100644 --- a/source/helpers/clean-commit-message.test.ts +++ b/source/helpers/clean-commit-message.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import cleanCommitMessage from './clean-commit-message'; +import cleanCommitMessage from './clean-commit-message.js'; test('cleanCommitMessage', () => { const coauthors = [ diff --git a/source/helpers/click-all.ts b/source/helpers/click-all.ts index 45dda857..9d38adff 100644 --- a/source/helpers/click-all.ts +++ b/source/helpers/click-all.ts @@ -2,7 +2,7 @@ import mem from 'mem'; import select from 'select-dom'; import {DelegateEvent} from 'delegate-it'; -import preserveScroll from './preserve-scroll'; +import preserveScroll from './preserve-scroll.js'; type EventHandler = (event: DelegateEvent<MouseEvent, HTMLElement>) => void; export default mem((selector: string | ((clickedItem: HTMLElement) => string)): EventHandler => event => { diff --git a/source/helpers/fetch-dom.ts b/source/helpers/fetch-dom.ts index 39f5d9b2..7c7ffe65 100644 --- a/source/helpers/fetch-dom.ts +++ b/source/helpers/fetch-dom.ts @@ -1,8 +1,8 @@ import mem from 'mem'; import domify from 'doma'; -import type {ParseSelector} from 'typed-query-selector/parser'; +import type {ParseSelector} from 'typed-query-selector/parser.js'; -import features from '../feature-manager'; +import features from '../feature-manager.js'; async function fetchDom(url: string): Promise<DocumentFragment>; async function fetchDom<Selector extends string, TElement extends HTMLElement = ParseSelector<Selector, HTMLElement>>(url: string, selector: Selector): Promise<TElement | undefined>; diff --git a/source/helpers/get-items-between.test.ts b/source/helpers/get-items-between.test.ts index ddeb12f0..9e9fe39f 100644 --- a/source/helpers/get-items-between.test.ts +++ b/source/helpers/get-items-between.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import getItemsBetween from './get-items-between'; +import getItemsBetween from './get-items-between.js'; test('getItemsBetween', () => { const list = ['❤️', '💛', '💚', '💙']; diff --git a/source/helpers/hotfix.tsx b/source/helpers/hotfix.tsx index 83dab02f..7ac7657d 100644 --- a/source/helpers/hotfix.tsx +++ b/source/helpers/hotfix.tsx @@ -4,8 +4,8 @@ import {isEnterprise} from 'github-url-detection'; import compareVersions from 'tiny-version-compare'; import {any as concatenateTemplateLiteralTag} from 'code-tag'; -import {RGHOptions} from '../options-storage'; -import isDevelopmentVersion from './is-development-version'; +import {RGHOptions} from '../options-storage.js'; +import isDevelopmentVersion from './is-development-version.js'; function parseCsv(content: string): string[][] { const lines = []; diff --git a/source/helpers/is-low-quality-comment.test.ts b/source/helpers/is-low-quality-comment.test.ts index d24806b2..c01c602a 100644 --- a/source/helpers/is-low-quality-comment.test.ts +++ b/source/helpers/is-low-quality-comment.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import isLowQualityComment from './is-low-quality-comment'; +import isLowQualityComment from './is-low-quality-comment.js'; test('isLowQualityComment', () => { assert.isTrue(isLowQualityComment('+1')); diff --git a/source/helpers/loose-parse-int.test.ts b/source/helpers/loose-parse-int.test.ts index 06d058a8..a6662566 100644 --- a/source/helpers/loose-parse-int.test.ts +++ b/source/helpers/loose-parse-int.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import looseParseInt from './loose-parse-int'; +import looseParseInt from './loose-parse-int.js'; test('looseParseInt', () => { assert.equal(looseParseInt('1,234'), 1234); diff --git a/source/helpers/on-element-replacement.ts b/source/helpers/on-element-replacement.ts index a4ec40ae..27c555e4 100644 --- a/source/helpers/on-element-replacement.ts +++ b/source/helpers/on-element-replacement.ts @@ -1,6 +1,6 @@ import select from 'select-dom'; -import onElementRemoval from './on-element-removal'; +import onElementRemoval from './on-element-removal.js'; /** Tracks the replacement of an element, identified via selector. diff --git a/source/helpers/pluralize.test.ts b/source/helpers/pluralize.test.ts index e5764970..07179189 100644 --- a/source/helpers/pluralize.test.ts +++ b/source/helpers/pluralize.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import pluralize from './pluralize'; +import pluralize from './pluralize.js'; test('pluralize', () => { assert.equal(pluralize(0, 'A number', '$$ numbers'), '0 numbers'); diff --git a/source/helpers/pr-commit-cleaner.test.ts b/source/helpers/pr-commit-cleaner.test.ts index f7771ddf..d7b36d53 100644 --- a/source/helpers/pr-commit-cleaner.test.ts +++ b/source/helpers/pr-commit-cleaner.test.ts @@ -1,6 +1,6 @@ import {test, assert} from 'vitest'; -import cleanPrCommitTitle from './pr-commit-cleaner'; +import cleanPrCommitTitle from './pr-commit-cleaner.js'; test('cleanPrCommitTitle', () => { const clean = 'Something done'; diff --git a/source/helpers/select-has.test.ts b/source/helpers/select-has.test.ts index 13d4500b..251b6ae5 100644 --- a/source/helpers/select-has.test.ts +++ b/source/helpers/select-has.test.ts @@ -1,7 +1,7 @@ import {JSDOM} from 'jsdom'; import {test, assert} from 'vitest'; -import select from './select-has'; +import select from './select-has.js'; test('basic :has() support', () => { const fragment = JSDOM.fragment(` diff --git a/source/helpers/select-has.ts b/source/helpers/select-has.ts index 1ed5f86a..29dd6756 100644 --- a/source/helpers/select-has.ts +++ b/source/helpers/select-has.ts @@ -1,4 +1,4 @@ -import {ParseSelector} from 'typed-query-selector/parser'; +import {ParseSelector} from 'typed-query-selector/parser.js'; const _isHasSelectorSupported = globalThis.CSS?.supports('selector(:has(a))'); export const isHasSelectorSupported = (): boolean => _isHasSelectorSupported; diff --git a/source/helpers/selector-observer.tsx b/source/helpers/selector-observer.tsx index 1beb3aca..522d1953 100644 --- a/source/helpers/selector-observer.tsx +++ b/source/helpers/selector-observer.tsx @@ -1,10 +1,10 @@ import React from 'dom-chef'; import {css} from 'code-tag'; import onetime from 'onetime'; -import {ParseSelector} from 'typed-query-selector/parser'; +import {ParseSelector} from 'typed-query-selector/parser.js'; -import getCallerID from './caller-id'; -import isDevelopmentVersion from './is-development-version'; +import getCallerID from './caller-id.js'; +import isDevelopmentVersion from './is-development-version.js'; type ObserverListener<ExpectedElement extends Element> = (element: ExpectedElement, options: SignalAsOptions) => void; @@ -17,7 +17,7 @@ const getListener = < selector: Selector, callback: ObserverListener<ExpectedElement>, signal?: AbortSignal, -) => function (event: AnimationEvent) { +) => (event: AnimationEvent) => { const target = event.target as ExpectedElement; // The target can match a selector even if the animation actually happened on a ::before pseudo-element, so it needs an explicit exclusion here if (target.classList.contains(seenMark) || !target.matches(selector)) { diff --git a/source/helpers/show-whitespace-on-line.test.ts b/source/helpers/show-whitespace-on-line.test.ts index 33df817b..2b0f95f6 100644 --- a/source/helpers/show-whitespace-on-line.test.ts +++ b/source/helpers/show-whitespace-on-line.test.ts @@ -2,7 +2,7 @@ import {assert, test} from 'vitest'; import hl from 'highlight.js/lib/common'; -import showWhiteSpacesOnLine from './show-whitespace-on-line'; +import showWhiteSpacesOnLine from './show-whitespace-on-line.js'; function highlight(html: string): string { // Use highlighter to create multiple text nodes diff --git a/source/helpers/show-whitespace-on-line.tsx b/source/helpers/show-whitespace-on-line.tsx index 05f24526..8a60b18f 100644 --- a/source/helpers/show-whitespace-on-line.tsx +++ b/source/helpers/show-whitespace-on-line.tsx @@ -1,6 +1,6 @@ import React from 'dom-chef'; -import getTextNodes from './get-text-nodes'; +import getTextNodes from './get-text-nodes.js'; // `splitText` is used before and after each whitespace group so a new whitespace-only text node is created. This new node is then wrapped in a <span> export default function showWhiteSpacesOnLine(line: Element, shouldAvoidSurroundingSpaces = false): Element { diff --git a/source/helpers/types.d.ts b/source/helpers/types.d.ts index e3224b49..2299c002 100644 --- a/source/helpers/types.d.ts +++ b/source/helpers/types.d.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions -- Declaration merging necessary */ /* eslint-disable @typescript-eslint/ban-types -- The API does return `null`, not `undefined` */ -import type {StrictlyParseSelector} from 'typed-query-selector/parser'; +import type {StrictlyParseSelector} from 'typed-query-selector/parser.js'; declare global { interface ParentNode { diff --git a/source/options.tsx b/source/options.tsx index 2d8b56e5..cccc5d73 100644 --- a/source/options.tsx +++ b/source/options.tsx @@ -11,13 +11,13 @@ import * as indentTextarea from 'indent-textarea'; import delegate, {DelegateEvent} from 'delegate-it'; import {isChrome, isFirefox} from 'webext-detect-page'; -import featureLink from './helpers/feature-link'; -import clearCacheHandler from './helpers/clear-cache-handler'; -import {getLocalHotfixes} from './helpers/hotfix'; -import {createRghIssueLink} from './helpers/rgh-issue-link'; +import featureLink from './helpers/feature-link.js'; +import clearCacheHandler from './helpers/clear-cache-handler.js'; +import {getLocalHotfixes} from './helpers/hotfix.js'; +import {createRghIssueLink} from './helpers/rgh-issue-link.js'; import {importedFeatures, featuresMeta} from '../readme.md'; -import getStorageBytesInUse from './helpers/used-storage'; -import {isBrowserActionAPopup, perDomainOptions} from './options-storage'; +import getStorageBytesInUse from './helpers/used-storage.js'; +import {isBrowserActionAPopup, perDomainOptions} from './options-storage.js'; type Status = { error?: true; diff --git a/test/get-current-committish.test.ts b/test/get-current-committish.test.ts index 2e53b225..3df976c0 100644 --- a/test/get-current-committish.test.ts +++ b/test/get-current-committish.test.ts @@ -1,7 +1,7 @@ import {assert, test} from 'vitest'; import './fixtures/globals'; -import {getCurrentCommittish} from '../source/github-helpers'; +import {getCurrentCommittish} from '../source/github-helpers/index.js'; // The titles supplied here listed here are real, not guessed, except the error tester test('getCurrentCommittish', () => { diff --git a/test/shorten-link.test.ts b/test/shorten-link.test.ts index b21483b4..ee5ff2ee 100644 --- a/test/shorten-link.test.ts +++ b/test/shorten-link.test.ts @@ -2,7 +2,7 @@ import {JSDOM} from 'jsdom'; import {expect, test} from 'vitest'; import './fixtures/globals'; -import {shortenLink} from '../source/github-helpers/dom-formatters'; +import {shortenLink} from '../source/github-helpers/dom-formatters.js'; function shortenLinksInFragment(html: string): string { const fragment = JSDOM.fragment(html); diff --git a/webpack.config.ts b/webpack.config.ts index 18bcc9a8..29e4b97c 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -67,6 +67,10 @@ const config: Configuration = { '.ts', '.js', ], + extensionAlias: { + // Explanation: https://www.npmjs.com/package/resolve-typescript-plugin + '.js': ['.ts', '.tsx', '.js'], + }, }, optimization: { // Keeps it somewhat readable for AMO reviewers |