sindresorhus/refined-github

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Minor codebase updates and fixes #4008

fregante posted onGitHub

I'll use this issue to add small tasks that could be done, treat it as a wishlist or a good way to start getting acquainted with the codebase.

  • Find fickle selectors and change them with select(something more specific).closest(the parent);

    GitHub has been removing some feature-specific classes like .js-file-list which means that we end up with monstrosities like main > :first-child .mt-1 .btn which mean nothing and could change at any time. Ideally instead we should find the best selector inside the target element (for example its icon, select('.octicon-branch[aria-label="Create branch"]')) and then reach the desired element with .closest('.btn'):

    - select('main > :first-child .mt-1 .btn')
    + select('.octicon-branch[aria-label="Create branch"]')!.closest('.btn')

Hi, I'm taking on this

posted by doc-han about 4 years ago
- const foo = mem(() => {return something});
+ @mem.decorator();
+ function foo() {return something}
posted by fregante about 4 years ago

Use mem.decorator wherever possible sindresorhus/mem#61

Sadly, TypeScript decorators can only be used inside classes: https://www.typescriptlang.org/docs/handbook/decorators.html#decorators

posted by cheap-glitch about 4 years ago
posted by fregante about 4 years ago

The last 2 I have included in my june refresh PR (un committed). If you want I can commit them now. But I would rather wait for then so we know that we are breaking GHE in one PR 😄

posted by yakov116 about 4 years ago
  • Move negative exclusions to their own list of required tests

https://github.com/sindresorhus/refined-github/blob/936eedbb0bb37a30fc44a2cc7e5f3af31f24a3fc/source/features/fork-source-link-same-view.tsx#L24-L32

Could be

    required: [ // name TBD
        pageDetect.isForkedRepo
    ],
    include: [
        pageDetect.isSingleFile,
        pageDetect.isRepoTree,
        pageDetect.isEditingFile
    ],
    exclude: [
        pageDetect.isRepoRoot
    ],

Side note: https://github.com/sindresorhus/refined-github/pull/4797/files#r711719028

posted by fregante about 4 years ago
- const deinit: VoidFunction[] = [];

function init(): void {
    const listener = delegate(…);
    const observer = observe(…);
-    deinit.push(listener.destroy, observer.abort);
+    return [listener.destroy, observer.abort];
}

void features.add(__filebasename, {
    init,
-     deinit
});
posted by fregante about 4 years ago
posted by fregante about 4 years ago
  • These should be 4 checkboxes as originally intended:

<img width="593" alt="Screen Shot 2021-04-04 at 00 46 42" src="https://user-images.githubusercontent.com/1402241/113486909-40295300-94df-11eb-8efd-98b1a570d00c.png">

This makes it clearer to users that a no-scope token is still fine for read-only operations. Currently instead no error is shown, but the user still sees

❌ ❌ ❌

Instead of

✅ ❌ ❌ ❌

posted by fregante about 4 years ago

Seems like GitHub moved the tooltips orientation in the editor's toolbar, and now RGH's tooltips don't match: image Worth fixing?

posted by cheap-glitch almost 4 years ago

Yes

posted by yakov116 almost 4 years ago
  • Replace exclude: [isEmptyRepo] and related exclusions with a check in the try init() catch block in features/index.

Instead of having to explicitly specify these exclusions, RG should just understand that the current page is incomplete and ignore every error. Maybe it should just show once a log: “This page is incomplete. Some features have been disabled.”

The feature logger might also display a log with a 💢 emoji or similar.

Edit: Same goes for features that fail when you’re logged out.

posted by fregante almost 4 years ago

This means we can stop using unnecessary generics like .closest<HMTLElement>('.hi')

Edit: closest is already typed, but it defaults to Element instead of HTMLElement: https://github.com/g-plane/typed-query-selector/issues/16

It should updated

posted by fregante almost 4 years ago
  • Add a direct "rate" link to the options page, to encourage the user to rate the extension in the Mac App Store / Chrome Store / Firefox Addons.
posted by sindresorhus almost 4 years ago

Maybe this: https://github.com/sindresorhus/refined-github/blob/2d165c692e2fcdd5b0a01a01ee0bc37af7acefd1/source/features/clean-repo-sidebar.css#L13 could be replaced by .mt-n3 (source: https://primer.style/css/utilities/margin#negative-margins)

<details> <summary>Same for others negative margin/paddings:</summary>

$ rg '(margin|padding)-.+?: -'

source/features/clean-conversation-sidebar.css
3:margin-bottom: -5px;

source/features/hide-readme-header.css
6:margin-bottom: -40px;

source/features/remove-label-faster.css
4:margin-right: -7px;

source/features/quick-mention.css
7:margin-bottom: -30px; /* Avoids pushing app badges down #2630 */

source/features/reactions-avatars.css
9:margin-bottom: -1px; /* Makes up for `order-bottom` */
13:margin-top: -1px; /* Makes up for `.reaction-summary-item {border-top}` */
20:margin-top: -0.3em;
21:margin-left: -0.5em;
37:margin-top: -1px;

source/features/clean-dashboard.css
45:margin-top: -5px;
46:margin-bottom: -5px;

source/features/forked-to.css
3:margin-left: -1px;

source/features/clean-mergeability-box.css
25:margin-top: -4px;
29:margin-top: -6px;

source/features/fix-first-tab-length.css
16:margin-left: -37px !important; /* GitHub sets this to -28px */

source/features/clean-pinned-issues.css
37:margin-top: -2px;
42:margin-left: -10px;

source/features/dim-bots.css
39:margin-bottom: -1.6em;
46:margin-bottom: -2em;

source/features/toggle-files-button.css
3:margin-right: -10px;

source/features/clean-repo-sidebar.css
13:margin-top: -16px !important;

</details>

posted by cheap-glitch almost 4 years ago

Exclusively if we already create/alter the element via JS

posted by fregante almost 4 years ago
posted by fregante almost 4 years ago

@fregante what updates should I know about for typescript 4.3?

posted by yakov116 almost 4 years ago

@fregante what updates should I know about for typescript 4.3?

🤷‍♂️

posted by fregante almost 4 years ago
posted by cheap-glitch almost 4 years ago
  • Replace manual deduplication checks with deduplicate

https://github.com/sindresorhus/refined-github/blob/40ed43f6cdd23178b6c6ee7c04a5731cb2342012/source/features/clean-conversation-sidebar.tsx#L60-L63

This should just be deduplicate: '.rgh-clean-sidebar' I think

posted by fregante over 3 years ago

Nope deduplucate will not work on additionalListeners

posted by yakov116 over 3 years ago

Darn it, again 😃

posted by fregante over 3 years ago

I think that tool lets us extend the dictionary by editing a file at the root of the repo. It would be ok if it worked out of the box or with a dozen of new words in the dictionary, but if it requires us to add a hundred words then it’s not worth it anymore.

posted by fregante over 3 years ago
  • Fix some TODOs 😅
posted by fregante over 3 years ago

From https://github.com/sindresorhus/refined-github/issues/4197#issuecomment-820954304

  • Rewrite copy-file so that it uses the native clipboard-copy element.

I'm not sure if this is possible, but I'm imagining that if we use a "capture: true" we can run before their event and set the required attribute:

  1. Onclick -> button.setAttribute('value', blob.innerText)
  2. clipboard-copy takes care of showing the tooltip and actually copying to the clipboard

Also our onclick handler only needs to run once (if this optimization is possible)

posted by fregante over 3 years ago
  • Fix every instance of unicorn/no-array-callback-reference and make it an error in XO’s config
posted by fregante over 3 years ago

Can I post here as well? Would like to add back the username in reaction-avatars: https://github.com/sindresorhus/refined-github/pull/4608#discussion_r678439504

posted by kidonng over 3 years ago

You can, but this issue is about refactoring and other meta improvements, not fixes/changes to specific features. That specific tooltip was removed at some point, so it's worth blaming the line and opening a new issue, if you want.

posted by fregante over 3 years ago

The content would probably be just *.* but it needs to be tested

posted by fregante over 3 years ago

The solution seems awkward, it needs to be reconsidered.

posted by fregante over 3 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests