Skip to content
Merged

Lint #3437

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/features/ci-link.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './ci-link.css';
import select from 'select-dom';
import oneTime from 'onetime';
import onetime from 'onetime';
import * as pageDetect from 'github-url-detection';

import features from '.';
import fetchDom from '../helpers/fetch-dom';
import {getRepoURL} from '../github-helpers';

// Look for the CI icon in the latest 2 days of commits #2990
const getIcon = oneTime(fetchDom.bind(null,
const getIcon = onetime(fetchDom.bind(null,
`/${getRepoURL()}/commits`, [
'.commit-group:nth-of-type(-n+2) .commit-build-statuses', // Pre "Repository refresh" layout
'.TimelineItem--condensed:nth-of-type(-n+2) .commit-build-statuses'
Expand All @@ -22,7 +22,7 @@ async function init(): Promise<false | void> {
}

icon.classList.add('rgh-ci-link');
if (oneTime.callCount(getIcon) > 1) {
if (onetime.callCount(getIcon) > 1) {
icon.style.animation = 'none';
}

Expand Down
4 changes: 2 additions & 2 deletions source/features/clean-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './clean-sidebar.css';
import React from 'dom-chef';
import select from 'select-dom';
import oneTime from 'onetime';
import onetime from 'onetime';
import * as pageDetect from 'github-url-detection';

import features from '.';
import onElementRemoval from '../helpers/on-element-removal';
import onReplacedElement from '../helpers/on-replaced-element';

const canEditSidebar = oneTime((): boolean => select.exists('.sidebar-labels .octicon-gear'));
const canEditSidebar = onetime((): boolean => select.exists('.sidebar-labels .octicon-gear'));

function getNodesAfter(node: Node): Range {
const range = new Range();
Expand Down
14 changes: 6 additions & 8 deletions source/features/keyboard-navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {isEditable} from '../helpers/dom-utils';

const isCommentGroupMinimized = (comment: HTMLElement): boolean =>
select.exists('.minimized-comment:not(.d-none)', comment) ||
Boolean(comment.closest(`
.js-resolvable-thread-contents.d-none,
.js-resolvable-timeline-thread-container:not([open])
`));
Boolean(comment.closest([
'.js-resolvable-thread-contents.d-none', // Regular comments
'.js-resolvable-timeline-thread-container:not([open])' // Review comments
].join()));

function runShortcuts(event: KeyboardEvent): void {
if (isEditable(event.target)) {
Expand All @@ -23,10 +23,8 @@ function runShortcuts(event: KeyboardEvent): void {

const items = select
.all([
// Files in diffs
'.js-targetable-element[id^="diff-"]',
// Comments (to be `.filter()`ed)
'.js-minimizable-comment-group'
'.js-targetable-element[id^="diff-"]', // Files in diffs
'.js-minimizable-comment-group'// Comments (to be `.filter()`ed)
])
.filter(element =>
element.classList.contains('js-minimizable-comment-group') ?
Expand Down
5 changes: 3 additions & 2 deletions source/features/linkify-user-edit-history-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from 'dom-chef';
import {observe} from 'selector-observer';
import * as pageDetect from 'github-url-detection';

import features from '.';
import {wrap} from '../helpers/dom-utils';
import features from '.';

function init(): void {
observe('details-dialog .Box-header .mr-3 > img:not([alt*="[bot]"])', {
constructor: HTMLImageElement,
add(avatar) {
const userName = (avatar as HTMLImageElement).alt.slice(1);
const userName = avatar.alt.slice(1);
// Linkify name first
wrap(avatar.nextElementSibling!, <a className="link-gray-dark" href={`/${userName}`}/>);

Expand Down
5 changes: 4 additions & 1 deletion source/features/mark-merge-commits-in-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ async function init(): Promise<void> {
for (const commit of pageCommits) {
if (mergeCommits.includes(getCommitHash(commit))) {
commit.classList.add('rgh-merge-commit');
select('.commit-title', commit)!.prepend(<PullRequestIcon/>);
select([
'.commit-title', // Pre "Repository refresh" layout
'div > p'
], commit)!.prepend(<PullRequestIcon/>);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion source/features/more-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export function createDropdownItem(label: string, url: string, attributes?: Reco
}

async function init(): Promise<void> {
await elementReady('.pagehead + *'); // Wait for the tab bar to be loaded
// Wait for the tab bar to be loaded
await elementReady([
'.pagehead + *', // Pre "Repository refresh" layout
'.UnderlineNav-body + *'
].join());

const reference = getCurrentBranch();
const compareUrl = `/${repoUrl}/compare/${reference}`;
Expand Down
6 changes: 5 additions & 1 deletion source/features/releases-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ async function init(): Promise<false | void> {
return false;
}

await elementReady('.pagehead + *, .UnderlineNav-body + *'); // Wait for the tab bar to be loaded
// Wait for the tab bar to be loaded
await elementReady([
'.pagehead + *', // Pre "Repository refresh" layout
'.UnderlineNav-body + *'
].join());

const repoNavigationBar = select('.js-repo-nav.UnderlineNav');
if (repoNavigationBar) {
Expand Down
1 change: 1 addition & 0 deletions source/features/show-followers-you-know.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function init(): Promise<false | void> {

void features.add({
id: __filebasename,
disabled: '#3345',
description: 'Followers you know are shown on profile pages',
screenshot: 'https://user-images.githubusercontent.com/2906365/42009293-b1503f62-7a57-11e8-88f5-9c2fb3651a14.png'
}, {
Expand Down
6 changes: 5 additions & 1 deletion source/features/show-open-prs-of-forks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ const countPRs = cache.function(async (forkedRepo: string): Promise<[number, num
});

async function getPRs(): Promise<[number, string] | []> {
await elementReady('.pagehead + *, .UnderlineNav-body + *'); // Wait for the tab bar to be loaded
// Wait for the tab bar to be loaded
await elementReady([
'.pagehead + *', // Pre "Repository refresh" layout
'.UnderlineNav-body + *'
].join());
if (!pageDetect.canUserEditRepo()) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion source/features/tag-changelog-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const getPreviousTag = (current: number, allTags: TagDetails[]): string | undefi
async function init(): Promise<void> {
const tagsSelector = [
// https://github.com/facebook/react/releases (release in releases list)
'.release',
'.release:not(.label-draft)',

// https://github.com/facebook/react/releases?after=v16.7.0 (tags in releases list)
'.release-main-section .commit',
Expand Down
4 changes: 2 additions & 2 deletions source/features/update-pr-from-base-branch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ async function addButton(): Promise<void> {
}

// Draft PRs already have this info on the page
const [outOfDateContainer] = select.all('.completeness-indicator-problem + .status-heading')
.filter(title => title.textContent!.includes('out-of-date'));
const outOfDateContainer = select.all('.completeness-indicator-problem + .status-heading')
.find(title => title.textContent!.includes('out-of-date'));
if (outOfDateContainer) {
const meta = outOfDateContainer.nextElementSibling!;
meta.after(' ', createButton());
Expand Down
4 changes: 2 additions & 2 deletions source/features/warning-for-disallow-edits.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import './warning-for-disallow-edits.css';
import React from 'dom-chef';
import select from 'select-dom';
import oneTime from 'onetime';
import onetime from 'onetime';
import delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';

import features from '.';

const getWarning = oneTime(() => (
const getWarning = onetime(() => (
<div className="flash flash-error mt-3 rgh-warning-for-disallow-edits">
<strong>Note:</strong> Maintainers may require changes. It’s easier and faster to allow them to make direct changes before merging.
</div>
Expand Down
4 changes: 2 additions & 2 deletions source/github-helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import select from 'select-dom';
import oneTime from 'onetime';
import onetime from 'onetime';
import compareVersions from 'tiny-version-compare';
import * as pageDetect from 'github-url-detection/esm/index.js'; // eslint-disable-line import/extensions -- Required for Node tests compatibility
import elementReady from 'element-ready';

// This never changes, so it can be cached here
export const getUsername = oneTime(pageDetect.utils.getUsername);
export const getUsername = onetime(pageDetect.utils.getUsername);
export const {getRepoPath, getCleanPathname} = pageDetect.utils;

export const getConversationNumber = (): string | undefined => {
Expand Down
10 changes: 0 additions & 10 deletions source/options-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ const defaults = Object.assign({
const migrations = [
// Merged on July 2nd
featureWasRenamed('sticky-discussion-list-toolbar', 'sticky-conversation-list-toolbar'),
featureWasRenamed('highlight-collaborators-and-own-discussions', 'highlight-collaborators-and-own-conversations'),
featureWasRenamed('discussion-filters', 'conversation-filters'),
featureWasRenamed('global-discussion-list-filters', 'global-conversation-list-filters'),
featureWasRenamed('extend-discussion-status-filters', 'extend-conversation-status-filters'),
featureWasRenamed('discussion-links-on-repo-lists', 'conversation-links-on-repo-lists'),
featureWasRenamed('format-discussion-titles', 'format-conversation-titles'),
featureWasRenamed('sticky-discussion-sidebar', 'sticky-conversation-sidebar'),
featureWasRenamed('batch-open-issues', 'batch-open-conversations'),
featureWasRenamed('sort-issues-by-update-time', 'sort-conversations-by-update-time'),
featureWasRenamed('clean-issue-filters', 'clean-conversation-filters'),

// Removed features will be automatically removed from the options as well
OptionsSyncPerDomain.migrations.removeUnused
Expand Down